1 tree grammar Simplify; 2 3 options { 4 tokenVocab=VecMath; 5 ASTLabelType=CommonTree; 6 output=AST; 7 language=CSharp3; 8 filter=true; 9 //rewrite=true; 10 } 11 12 @members 13 { 14 public override IAstRuleReturnScope Topdown() { return topdown(); } 15 public override IAstRuleReturnScope Bottomup() { return bottomup(); } 16 } 17 18 19 topdown 20 : ^( MULT INT ^(VEC (e+=.)+) ) -> ^(VEC ^(MULT INT $e)+) 21 ; 22 23 bottomup 24 : ^(MULT a=. b=INT {$b.int==0}?) -> $b // x*0 -> 0 25 ; 26