From 16fca1cee671135016bd691d3bb29991c794d49b Mon Sep 17 00:00:00 2001 From: Natapat Samutpong Date: Fri, 25 Feb 2022 15:59:17 +0700 Subject: [PATCH] fix a bit of parser --- README.md | 1 + example/ex.hyc | 4 +++- src/front/parse.rs | 9 +-------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 04ac33e..ac4a5c7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Hycron Programming language that compiles to C + Note: The syntax can still be changed, if you have an idea, feel free to make an issues about it. # Prerequistie diff --git a/example/ex.hyc b/example/ex.hyc index c800236..325b37f 100644 --- a/example/ex.hyc +++ b/example/ex.hyc @@ -3,8 +3,10 @@ let bar: string = "str"; let baz: bool = true; fun qux (lhs: int rhs: int) -> int = lhs + rhs; +fun quux () -> string = "Hi, World!\n"; fun main () -> int = do - let msg: string = "Hello, World!"; + let msg: string = "Hello, World!\n"; write(msg); + write(quux()); 0; end; \ No newline at end of file diff --git a/src/front/parse.rs b/src/front/parse.rs index 77b4a2d..9e601d5 100644 --- a/src/front/parse.rs +++ b/src/front/parse.rs @@ -35,7 +35,7 @@ pub fn lexer() -> impl Parser, Error = Simple> { .map(|s: String| Token::Float(s)); let string = just('"') - .ignore_then(filter(|c| *c != '\\' && *c != '"').repeated()) + .ignore_then(filter(|c| *c != '"').repeated()) .then_ignore(just('"')) .collect::() .map(|s: String| Token::String(s)); @@ -134,8 +134,6 @@ pub enum Expr { else_: Box, }, Do { body: Vec }, - - Import(String), } fn expr_parser() -> impl Parser> + Clone { @@ -282,10 +280,6 @@ fn expr_parser() -> impl Parser> + Clone { body: Box::new(body), }).labelled("function"); - let declare_import = just(Token::Import) - .ignore_then(ident.clone()) - .map(Expr::Import); - let if_cond = just(Token::If) .ignore_then(expr.clone()) .then_ignore(just(Token::Then)) @@ -307,7 +301,6 @@ fn expr_parser() -> impl Parser> + Clone { declare_var .or(declare_fun) - .or(declare_import) .or(if_cond) .or(do_block) .or(expr)