Added the name of the file to the error report.
[repair.git] / Repair / RepairCompiler / MCC / SDL.cup
index 6604dcd02e35481f0e0e8be523cd9e68159cfaad..ee5172cba3e07342d01cac27efd37297c0626fbd 100755 (executable)
@@ -56,13 +56,16 @@ action code {:
 init with {: :}
 
 parser code {:
+
+       public String filename;
        
        public void syntax_error (java_cup.runtime.Symbol current) {
 
                CUP$SDLParser$actions.errors = true;
                Symbol symbol = (Symbol) current;
-               report_error("SDL: Syntax error at line " + (symbol.line + 1)
+               report_error("TDL: Syntax error at line " + (symbol.line + 1)
                + ", column " + LineCount.getColumn(symbol.left) + ": " + current.value, current);
+               System.exit(0);
        }
 
        public void report_fatal_error (String message, Object info) {
@@ -142,6 +145,7 @@ parser code {:
 
     terminal IMPLIES;
     terminal TRUE;
+    terminal FALSE;
     terminal ISVALID;
     terminal FOR;
     terminal TO;
@@ -187,6 +191,7 @@ nonterminal ParseNode               optstatic;
 nonterminal    ParseNode               optpartition;
 nonterminal    ParseNode               setlist;
 nonterminal    ParseNode               type;
+nonterminal    ParseNode               optrange;
 
 precedence left OR;
 precedence left AND;
@@ -236,20 +241,37 @@ space ::=
        if (setlist != null) set.addChild(setlist);
        RESULT = set;
        :}
-      | ID:name optstatic:optstatic COLON type:domain ARROW type:range OPENPAREN mult:domainmult ARROW mult:rangemult CLOSEPAREN SEMICOLON 
+      | ID:name optstatic:optstatic COLON type:domain ARROW type:range optrange:optrange SEMICOLON 
        {:
        debugMessage(PRODSTRING);
-       ParseNode relation = new ParseNode("relationdefinition", parser.curLine(12));
+       ParseNode relation = new ParseNode("relationdefinition", parser.curLine(8));
        if (optstatic != null) relation.addChild(optstatic);
-       relation.addChild("name", parser.curLine(11)).addChild(name);
+       relation.addChild("name", parser.curLine(7)).addChild(name);
        relation.addChild("domain").addChild(domain);
        relation.addChild("range").addChild(range);
-       relation.getChild("domain").addChild(domainmult);
-       relation.getChild("range").addChild(rangemult);
+       if (optrange != null) { 
+           relation.getChild("domain").addChild(optrange.getChild("domainmult"));
+           relation.getChild("range").addChild(optrange.getChild("rangemult"));
+       }
        RESULT = relation;
        :}
       ;
 
+optrange ::= 
+       OPENPAREN mult:domainmult ARROW mult:rangemult CLOSEPAREN 
+          {:
+            debugMessage(PRODSTRING);
+            ParseNode optrange = new ParseNode("optrange", parser.curLine(5));
+            optrange.addChild("domainmult").addChild(domainmult);
+             optrange.addChild("rangemult").addChild(rangemult);
+            RESULT = optrange;
+          :}
+        | /* nothing */
+           {:
+             RESULT = null;
+           :}
+       ;
+
 mult ::=
      DECIMAL:one
        {: