UnwrapLeft, error reporting improvements
[sbp.git] / src / edu / berkeley / sbp / ParseFailed.java
index 8e759a8..8000712 100644 (file)
@@ -138,25 +138,24 @@ public class ParseFailed extends Exception {
         return ANSI.purple(ret.toString());
     }
 
-    static void error(String message, GSS.Phase phase) throws ParseFailed {
-        error(message, phase.getLocation(), phase.getToken(),
-              phase, phase.getRegion(), phase.getGSS().getInput(), phase.getGSS());
+    static void error(String message, GSS.Phase phase, Object token, Input.Region region) throws ParseFailed {
+        error(message,
+              token,
+              phase,
+              region,
+              phase.getGSS().getInput(),
+              phase.getGSS());
     }
-    static void error(String message,
-                      Input.Location loc,
-                      Object token,
-                      Iterable<Node> nodes,
-                      Input.Region region,
-                      Input input,
-                      GSS gss) throws ParseFailed{
+    private static void error(String message,
+                              Object token,
+                              Iterable<Node> nodes,
+                              Input.Region region,
+                              Input input,
+                              GSS gss) throws ParseFailed{
         String lookAhead = token==null ? "<EOF>" : token.toString();
         StringBuffer ret = new StringBuffer();
         ret.append(ANSI.bold(ANSI.red(message)));
-        if (token != null) {
-            ret.append(" \'");
-            ret.append(ANSI.cyan(StringUtil.escapify(token+"", "\\\'\r\n")));
-            ret.append("\'");
-        }
+        String toks = token+"";
         ret.append(" at ");
         ret.append(ANSI.yellow(region+""));
         if (input != null) {