agtest/arith.ag
2021-06-14 15:52:53 -05:00

13 lines
258 B
Text

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