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