• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1tree grammar Simplify;
2
3options {
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
19topdown
20    :   ^( MULT INT ^(VEC (e+=.)+) ) -> ^(VEC ^(MULT INT $e)+)
21    ;
22
23bottomup
24    :  ^(MULT a=. b=INT {$b.int==0}?) -> $b // x*0 -> 0
25    ;
26