This commit is contained in:
parent
856618d113
commit
27b4e89694
@ -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("<expression>");
|
||||
throw new Error();
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user