summaryrefslogtreecommitdiff
path: root/impl/EquationSystem.g
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@carlo-laptop>2012-05-29 22:42:25 +1000
committerCarlo Zancanaro <carlo@carlo-laptop>2012-05-29 22:42:25 +1000
commite043ee06a51a8d8c68f8cb0984d4f7bd8915bea8 (patch)
treecc8fd32426518808facb2efb496667b92cd22754 /impl/EquationSystem.g
parentf09ce60d45d5524e36d07e76814b6e0cbc554288 (diff)
First attempt a range parser - likely not correct.
Diffstat (limited to 'impl/EquationSystem.g')
-rw-r--r--impl/EquationSystem.g10
1 files changed, 6 insertions, 4 deletions
diff --git a/impl/EquationSystem.g b/impl/EquationSystem.g
index 3a6598a..6b721bb 100644
--- a/impl/EquationSystem.g
+++ b/impl/EquationSystem.g
@@ -11,6 +11,7 @@ tokens {
SUB = '-' ;
MULT = '*' ;
COMMA = ';' ;
+ RANGE = 'range' ;
GUARD = 'guard' ;
GREATER_EQUAL = '>=' ;
QUESTION_MARK = '?' ;
@@ -26,14 +27,15 @@ maxExpr : MAXIMUM^ '('! minExpr ( ','! minExpr )* ')'! | minExpr ;
minExpr : MINIMUM^ '('! maxExpr ( ','! maxExpr )* ')'! | expr ;
expr : '(' expr GREATER_EQUAL expr QUESTION_MARK expr ')' -> ^(GUARD expr expr expr)
- | term ( (PLUS | MULT | SUB | COMMA)^ expr )* ;
+ | term ( (PLUS | MULT | COMMA)^ expr )* ;
-term : NUMBER
+term : '[' NUMBER ',' NUMBER ']' -> ^( RANGE NUMBER NUMBER )
| VARIABLE
- | '('! expr ')'! ;
+ | '('! expr ')'!
+ | SUB^ term ;
-NUMBER : (DIGIT)+ ;
+NUMBER : (SUB) (DIGIT)+ | (DIGIT)+ ;
VARIABLE: (LETTER) (LETTER | DIGIT)* ;
WHITESPACE : ( '\t' | ' ' | '\u000C' )+
{