aboutsummaryrefslogtreecommitdiff
path: root/runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g3
blob: f1c2550b7fbfaf67fbac2ceebacff8aa7b402568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tree grammar Simplify;

options {
    tokenVocab=VecMath;    
    ASTLabelType=CommonTree;
    output=AST;
    language=CSharp3;
    filter=true;
    //rewrite=true;
}

@namespace{Antlr3.Runtime.Test.Composition}

topdown
    :   ^( MULT INT ^(VEC (e+=.)+) ) -> ^(VEC ^(MULT INT $e)+)
    ;

bottomup
    :  ^(MULT a=. b=INT {$b.int==0}?) -> $b // x*0 -> 0
    ;