Adding support for sum expressions.
[repair.git] / Repair / RepairCompiler / MCC / CDL.cup
index cc67fbe387d78d07d0d5293ea906f0d03a9d4d61..f491a6e556567f337e575b0b0f162a057acb4c5c 100755 (executable)
@@ -132,6 +132,7 @@ parser code {:
     terminal SUB; 
     terminal MULT; 
     terminal DIV;
+    terminal SUM;
 
     terminal NOT;
     terminal LT;
@@ -141,7 +142,6 @@ parser code {:
     terminal EQ;
     terminal NE;
 
-
     terminal FORALL;
     terminal IN;
     terminal INTEST;
@@ -478,8 +478,17 @@ setexpr ::=
        ;
        
 expr ::=
-       
-       ID:var
+
+       SUM OPENPAREN ID:set DOT ID:relation CLOSEPAREN
+       {:
+       debugMessage(PRODSTRING);
+       ParseNode expr = new ParseNode("sumexpr", parser.curLine(3));
+       expr.addChild("dot").addChild("set", parser.curLine(3)).addChild(set);
+       expr.getChild("dot").addChild("relation", parser.curLine(1)).addChild(relation);
+       RESULT = expr;
+       :}
+
+       | ID:var
        {:
        debugMessage(PRODSTRING);
        ParseNode expr = new ParseNode("expr", parser.curLine(1));      
@@ -629,6 +638,12 @@ literal ::=
        debugMessage(PRODSTRING);
        RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild(dec).getRoot();
        :}
+
+       | SUB DECIMAL:dec
+       {:
+       debugMessage(PRODSTRING);
+       RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild("-"+dec).getRoot();
+       :}
         
        | STRING:str
        {: