agtest/arith.ag

14 lines
257 B
Text
Raw Normal View History

2021-06-09 05:10:45 +00:00
iface HasValue {
2021-06-14 20:52:53 +00:00
val: int,
2021-06-09 00:56:30 +00:00
}
2021-06-09 05:10:45 +00:00
node Expr : HasValue {
2021-06-14 20:52:53 +00:00
<l:Expr> "+" <r:Expr> => {
self.val = l.val + r.val * l.val;
}
<l:Expr> "*" <r:Expr> => {
self.val = l.val * r.val;
}
2021-09-30 20:32:32 +00:00
<n:"[0-9]+"> => { self.val = parseInt(n); }
2021-06-09 00:56:30 +00:00
}