1 datatype Exp = INT int => _
2 | ADD (Exp, Exp) => _ "+" _
3 | SUB (Exp, Exp) => _ "-" _
4 | MUL (Exp, Exp) => _ "*" _
5 | DIV (Exp, Exp) => _ "/" _
8 instantiate datatype Exp;
10 attributegrammar class Foo
21 '(' exp ')' { $$.value = $2.value; }
22 | exp '+' exp { $$.value = $1.value + $3.value; }
23 | exp '-' exp { $$.value = $1.value - $3.value; }
24 | exp '*' exp { $$.value = $1.value * $3.value; }
25 | exp '/' exp { $$.value = $1.value / $3.value; }