From 0743717ce5865ae6c40aedd860025bd1ca7fe798 Mon Sep 17 00:00:00 2001 From: Natapat Samutpong Date: Thu, 10 Mar 2022 14:50:46 +0700 Subject: [PATCH] Update lib.rs --- crates/parser/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index e31c693..79cc2fa 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -6,12 +6,12 @@ pub type Spanned = (T, std::ops::Range); #[derive(Clone, Debug)] pub enum Expr { Int(i64), Float(f64), Boolean(bool), - String(String), Identifier(String), + String(String), Identifier(String), Unary { op: String, rhs: Box> }, Binary { lhs: Box>, op: String, rhs: Box> }, Call { name: Box>, args: Spanned>> }, - + Let { name: String, type_hint: String, @@ -24,7 +24,7 @@ pub enum Expr { body: Box> }, Return { expr: Box> }, - + If { cond: Box>, then: Box>, @@ -69,13 +69,15 @@ fn expr_parser() -> impl Parser>, Error = Simple ) .repeated() ) - .foldl(|name, args| {( + .foldl(|name, args| { + ( Expr::Call { name: Box::new(name.clone()), args: (args, name.1.clone()), }, name.1, - )}); + ) + }); let unary = choice(( just(Token::Plus),