diff --git a/src/front/parse.ts b/src/front/parse.ts index d4af4bb..eff2636 100644 --- a/src/front/parse.ts +++ b/src/front/parse.ts @@ -229,6 +229,10 @@ export class Parser { const value = Number(this.current.value); this.step(); return ast.Node.create(loc, "IntExpr", { value }); + } else if (this.eat("(")) { + const expr = this.parseExpr(); + this.mustEat(")"); + return expr; } else { this.mustEat(""); throw new Error(); diff --git a/tests/operators.ethlang b/tests/operators.ethlang index 7aaf880..1a7ae06 100644 --- a/tests/operators.ethlang +++ b/tests/operators.ethlang @@ -5,6 +5,8 @@ // expect: 2 // expect: -5 // expect: 123 +// expect: 10 +// expect: 14 fn main() { @@ -23,5 +25,8 @@ fn main() if not c { print_int(123); } + + print_int(2 * 3 + 4); + print_int(2 * (3 + 4)); }