aboutsummaryrefslogtreecommitdiff
path: root/runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g3
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g3')
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g325
1 files changed, 25 insertions, 0 deletions
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g3 b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g3
new file mode 100644
index 0000000..fd1fded
--- /dev/null
+++ b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/Composition/Simplify.g3
@@ -0,0 +1,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
+ ;