Update transpile.rs

This commit is contained in:
Shunsuke Shibayama 2022-11-18 15:45:35 +09:00
parent 8149305ca5
commit b95f043cb1

View file

@ -133,14 +133,18 @@ impl ScriptGenerator {
Expr::Lit(lit) => lit.token.content.to_string(), Expr::Lit(lit) => lit.token.content.to_string(),
Expr::Call(call) => self.transpile_call(call), Expr::Call(call) => self.transpile_call(call),
Expr::BinOp(bin) => { 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 += &bin.op.content;
code += &self.transpile_expr(*bin.rhs); code += &self.transpile_expr(*bin.rhs);
code += ")";
code code
} }
Expr::UnaryOp(unary) => { 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 += &self.transpile_expr(*unary.expr);
code += ")";
code code
} }
Expr::Array(array) => match array { Expr::Array(array) => match array {