vast improvement in error reporting
[sbp.git] / src / edu / berkeley / sbp / GSS.java
index b36b293..5255a21 100644 (file)
@@ -94,9 +94,13 @@ class GSS {
         public boolean isDone() throws ParseFailed {
             if (token != null) return false;
             if (token==null && finalResult==null)
-                throw new ParseFailed(ParseFailed.error(("unexpected end of file\n"),
-                                                        token, hash.values()),
-                                      getLocation().createRegion(getLocation()), input);
+                ParseFailed.error("unexpected end of file",
+                                  getLocation(),
+                                  token,
+                                  hash.values(),
+                                  getLocation().createRegion(getLocation()),
+                                  input,
+                                  GSS.this);
             return true;
         }
 
@@ -253,14 +257,22 @@ class GSS {
             }
 
             if (!good && token!=null)
-                throw new ParseFailed(ParseFailed.error(("unexpected character ")+" \'"+
-                                                        ANSI.purple(StringUtil.escapify(token+"", "\\\'\r\n"))+
-                                                        "\' encountered at "+
-                                                        ANSI.green(next.getRegion())+"\n", token, hash.values()),
-                                        next.getRegion(), input);
+                ParseFailed.error("unexpected character",
+                                  getLocation(),
+                                  token,
+                                  hash.values(),
+                                  getRegion(),
+                                  input,
+                                  GSS.this);
+
             if (token==null && finalResult==null)
-                throw new ParseFailed(ParseFailed.error(("unexpected end of file at "+getLocation()+"\n"), token, hash.values()),
-                                      getLocation().createRegion(getLocation()), input);
+                ParseFailed.error("unexpected end of file",
+                                  getLocation(),
+                                  token,
+                                  hash.values(),
+                                  getLocation().createRegion(getLocation()),
+                                  input,
+                                  GSS.this);
         }