From fe7ce9d1b3c76ee1bc4043eca2dfef25f7a932fe Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Tue, 13 Dec 2022 20:42:22 +0900 Subject: [PATCH] Update parse.rs --- compiler/erg_parser/parse.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/erg_parser/parse.rs b/compiler/erg_parser/parse.rs index 474870a6..ca8bb6ed 100644 --- a/compiler/erg_parser/parse.rs +++ b/compiler/erg_parser/parse.rs @@ -3071,7 +3071,18 @@ impl Parser { "???", )), }, - // TODO: App, Record, BinOp, UnaryOp, + Expr::BinOp(bin) => { + let mut args = bin.args.into_iter(); + let lhs = Self::validate_const_expr(*args.next().unwrap())?; + let rhs = Self::validate_const_expr(*args.next().unwrap())?; + Ok(ConstExpr::BinOp(ConstBinOp::new(bin.op, lhs, rhs))) + } + Expr::UnaryOp(unary) => { + let mut args = unary.args.into_iter(); + let arg = Self::validate_const_expr(*args.next().unwrap())?; + Ok(ConstExpr::UnaryOp(ConstUnaryOp::new(unary.op, arg))) + } + // TODO: App, Record, other => Err(ParseError::syntax_error( line!() as usize, other.loc(),