X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParseFailed.java;h=316caafe6bc6d284fdb83da30792f5ad9ba26426;hp=2245b67bd3bc58b5ecd25de100101becb2da3b70;hb=b8a597c8d1a29afc24f9b89f726d5b1a9b9aeec1;hpb=2a11d8ca5ae3af89ac2bdea58f71e463b6e4affe diff --git a/src/edu/berkeley/sbp/ParseFailed.java b/src/edu/berkeley/sbp/ParseFailed.java index 2245b67..316caaf 100644 --- a/src/edu/berkeley/sbp/ParseFailed.java +++ b/src/edu/berkeley/sbp/ParseFailed.java @@ -9,16 +9,17 @@ import java.util.*; /** thrown when the parser arrives at a state from which it is clear that no valid parse can result */ public class ParseFailed extends Exception { + private final Input.Location location; private final String message; - public ParseFailed() { this("", null); } - public ParseFailed(String message, Input.Location loc) { this.location = loc; this.message = message; } + ParseFailed() { this("", null); } + ParseFailed(String message, Input.Location loc) { this.location = loc; this.message = message; } public Input.Location getLocation() { return location; } public String toString() { return message/* + (location==null ? "" : (" at " + location))*/; } // FIXME private static HashSet touched = new HashSet(); - public static void complain(GSS.Phase.Node n, HashMap> errors, boolean force) { + static void complain(GSS.Phase.Node n, HashMap> errors, boolean force) { if (touched.contains(n)) return; touched.add(n); for(Position p : n.state) { @@ -34,9 +35,9 @@ public class ParseFailed extends Exception { } } - public static String el(Object e) { + static String el(Object e) { String s = e.toString(); - if (s.length()==0 || s.charAt(0)!='\"' || s.charAt(s.length()-1)!='\"') return ANSI.yellow(s); + if (s.length()==0 || s.charAt(0)!='\"' || s.charAt(s.length()-1)!='\"') return /*ANSI.yellow(s)*/s; s = s.substring(1); s = s.substring(0, s.length()-1); StringBuffer ret = new StringBuffer(); @@ -44,13 +45,14 @@ public class ParseFailed extends Exception { if (s.charAt(i)=='\\' && i nodes) { + static String error(String message, Object token, Iterable nodes) { String lookAhead = token==null ? "" : token.toString(); StringBuffer ret = new StringBuffer(); ret.append("\n "); ret.append(message); + /* HashMap> errors = new HashMap>(); for(Node n : nodes) { //System.out.println(n.state); @@ -71,6 +73,7 @@ public class ParseFailed extends Exception { ret.append("\n"); } } + */ return ret.toString(); }