1 package edu.berkeley.sbp;
2 import edu.berkeley.sbp.*;
3 import edu.berkeley.sbp.util.*;
4 import edu.berkeley.sbp.Sequence.Position;
8 /** if ambiguity checking is enabled, this exception is thrown to signal that the parse was ambiguous */
9 public class Ambiguous extends Exception {
10 final Forest<?> ambiguity;
11 private final HashSet<Tree<?>> ht;
12 Ambiguous(Forest<?> ambiguity, HashSet<Tree<?>> ht) {
13 this.ambiguity = ambiguity;
17 public Forest<?> getAmbiguity() { return ambiguity; }
19 public String toString() {
20 // FIXME: print the input region that was ambiguously matched
21 StringBuffer sb = new StringBuffer();
22 sb.append("unresolved ambiguity; shared subtrees are shown as \"*\" ");
23 for(Tree<?> result : ht) {
24 sb.append("\n possibility: ");
25 StringBuffer sb2 = new StringBuffer();
26 result.toPrettyString(sb2);
27 sb.append(StringUtil.indent(sb2.toString(), 15));