13 lines
257 B
Text
13 lines
257 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:"[0-9]+"> => { self.val = parseInt(n); }
|
|
}
|