X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FCDL.cup;h=2f7f2daa4f08e5da2e73de250d8fe7bd101e2ed5;hb=667568773e3049fdf33ae2caaa6092b94ae88160;hp=74216907c51832266c2d7d183ce58c13f59d7466;hpb=bf67a0718614f4872c339e72708974a4229722a1;p=repair.git diff --git a/Repair/RepairCompiler/MCC/CDL.cup b/Repair/RepairCompiler/MCC/CDL.cup index 7421690..2f7f2da 100755 --- a/Repair/RepairCompiler/MCC/CDL.cup +++ b/Repair/RepairCompiler/MCC/CDL.cup @@ -56,13 +56,29 @@ action code {: init with {: :} parser code {: + + public String filename; public void syntax_error (java_cup.runtime.Symbol current) { CUP$CDLParser$actions.errors = true; Symbol symbol = (Symbol) current; - report_error("CDL: Syntax error at line " + (symbol.line + 1) - + ", column " + LineCount.getColumn(symbol.left) + ": " + current.value, current); + + boolean isInteger = true; + try{ + Integer.parseInt(current.value.toString()); + } catch(NumberFormatException e) { isInteger = false;} + + report_error(filename+":"+(symbol.line+1)+": Syntax error at column " + + (LineCount.getColumn(symbol.left)+1) +": " + current.value, current); + + /* + if (current.value.equals("true") || isInteger) + System.out.println("Did you mean literal("+current.value+")?"); + */ + + System.out.println(); + System.exit(0); } public void report_fatal_error (String message, Object info) { @@ -159,6 +175,7 @@ parser code {: terminal LABEL; terminal INT; terminal SUBTYPE; + terminal SUBCLASS; terminal OF; terminal SEMICOLON; @@ -299,6 +316,15 @@ quantifier ::= q.addChild(set); RESULT = q; :} + | FORALL LT ID:r1 COMMA ID:r2 GT IN ID:relation + {: + debugMessage(PRODSTRING); + ParseNode q = new ParseNode("quantifier", parser.curLine(7)); + q.addChild("relation", parser.curLine(1)).addChild(relation); + q.addChild("left", parser.curLine(5)).addChild(r1); + q.addChild("right", parser.curLine(3)).addChild(r2); + RESULT = q; + :} ; set ::= @@ -449,7 +475,7 @@ expr ::= RESULT = expr; :} - | LITERAL OPENPAREN literal:literal CLOSEPAREN + | literal:literal {: debugMessage(PRODSTRING); ParseNode expr = new ParseNode("expr", parser.curLine(4)); @@ -573,6 +599,12 @@ literal ::= debugMessage(PRODSTRING); RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("boolean").addChild("false").getRoot(); :} + + | NULL + {: + debugMessage(PRODSTRING); + RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild("0").getRoot(); + :} | DECIMAL:dec {: @@ -592,7 +624,7 @@ literal ::= RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("char").addChild(chr).getRoot(); :} - | ID:literal + | LITERAL OPENPAREN ID:literal CLOSEPAREN {: debugMessage(PRODSTRING); RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("token").addChild(literal).getRoot();