agtest/test/arith.ag
2021-09-30 17:39:08 -05:00

16 lines
252 B
Text

iface HasValue {
val: int,
}
node Expr : HasValue {
<l:Expr> "+" <r:Expr> => {
self.val = l.val + r.val;
}
<l:Expr> "*" <r:Expr> => {
self.val = l.val * r.val;
}
<n:"[0-9]+"> => { self.val = parseInt(n); }
}