added group
All checks were successful
Check / Explore-Gitea-Actions (push) Successful in 8s

This commit is contained in:
sfja 2026-03-11 19:25:38 +01:00
parent 856618d113
commit 27b4e89694
2 changed files with 9 additions and 0 deletions

View File

@ -229,6 +229,10 @@ export class Parser {
const value = Number(this.current.value); const value = Number(this.current.value);
this.step(); this.step();
return ast.Node.create(loc, "IntExpr", { value }); return ast.Node.create(loc, "IntExpr", { value });
} else if (this.eat("(")) {
const expr = this.parseExpr();
this.mustEat(")");
return expr;
} else { } else {
this.mustEat("<expression>"); this.mustEat("<expression>");
throw new Error(); throw new Error();

View File

@ -5,6 +5,8 @@
// expect: 2 // expect: 2
// expect: -5 // expect: -5
// expect: 123 // expect: 123
// expect: 10
// expect: 14
fn main() fn main()
{ {
@ -23,5 +25,8 @@ fn main()
if not c { if not c {
print_int(123); print_int(123);
} }
print_int(2 * 3 + 4);
print_int(2 * (3 + 4));
} }