-
-
- // Exceptions //////////////////////////////////////////////////////////////////////////////
-
- public static class Failed extends Exception {
- private final Token.Location location;
- private final String message;
- public Failed() { this("", null); }
- public Failed(String message, Token.Location loc) { this.location = loc; this.message = message; }
- public Token.Location getLocation() { return location; }
- public String toString() { return message + (location==null ? "" : (" at " + location)); }
- }
-
- public static class Ambiguous extends RuntimeException {
- public final Forest ambiguity;
- public Ambiguous(Forest ambiguity) { this.ambiguity = ambiguity; }
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("unresolved ambiguity "/*"at " + ambiguity.getLocation() + ":"*/);
- for(Object result : ambiguity.expand(false))
- sb.append("\n " + result);
- return sb.toString();
- }
- }
-