From b95f043cb14ab55b56c86f1f5cbe4f7f404ce3ab Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Fri, 18 Nov 2022 15:45:35 +0900 Subject: [PATCH] Update transpile.rs --- compiler/erg_compiler/transpile.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/erg_compiler/transpile.rs b/compiler/erg_compiler/transpile.rs index 09333582..2c5f9f78 100644 --- a/compiler/erg_compiler/transpile.rs +++ b/compiler/erg_compiler/transpile.rs @@ -133,14 +133,18 @@ impl ScriptGenerator { Expr::Lit(lit) => lit.token.content.to_string(), Expr::Call(call) => self.transpile_call(call), Expr::BinOp(bin) => { - let mut code = self.transpile_expr(*bin.lhs); + let mut code = "(".to_string(); + code += &self.transpile_expr(*bin.lhs); code += &bin.op.content; code += &self.transpile_expr(*bin.rhs); + code += ")"; code } Expr::UnaryOp(unary) => { - let mut code = unary.op.content.to_string(); + let mut code = "(".to_string(); + code += &unary.op.content; code += &self.transpile_expr(*unary.expr); + code += ")"; code } Expr::Array(array) => match array {