OK, the parser now looks more decent.
[repair.git] / Repair / RepairCompiler / MCC / MDL.cup
index b8a2ad16e16e96205ba9c2a63e6347ad1ce67b2f..efd49425a8caba6817f45243149a42306158cf8e 100755 (executable)
@@ -63,9 +63,27 @@ parser code {:
 
                CUP$MDLParser$actions.errors = true;
                Symbol symbol = (Symbol) current;
-               report_error(filename+": Syntax error at line " +
-(symbol.line + 1) + ", column " + LineCount.getColumn(symbol.left) +
-": " + current.value, current);
+
+               //System.out.println("current.value = "+current.value + " " + current.value.equals("true"));
+               //System.out.println("current = " + 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+")?");
+              
+                       if (LineCount.getColumn(symbol.left) == 0)      
+                  System.out.println("Did you forget a semicolon on the previous line?");    
+               
+
+               System.out.println();
+               System.exit(0);
        }
 
        public void report_fatal_error (String message, Object info) {