var calc = Arithmetic.synthesizedAttribute({
AddExpr_plus: function(x, _, y) { return calc(x) + calc(y) - 2; },
AddExpr_minus: function(x, _, y) { return calc(x) - calc(y); },
MulExpr_times: function(x, _, y) { return calc(x) * calc(y); },
MulExpr_divide: function(x, _, y) { return calc(x) / calc(y); },
PriExpr_paren: function(_, e, _) { return calc(e); },
PriExpr_pos: function(_, e) { return calc(e); },
PriExpr_neg: function(_, e) { return calc(-e); },
ident: function(_, _) { return constants[this.interval.contents]; },
number: function(_) { return parseFloat(this.interval.contents); }
});
apply(calc, parse(Arithmetic, '3 + 4', 'Expr'));
var constants = {x: 4};
apply(calc, parse(Arithmetic, '(3 + x) / 2', 'Expr'));