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 public final Forest ambiguity;
11 public Ambiguous(Forest ambiguity) {
12 this.ambiguity = ambiguity;
14 public String toString() {
15 // FEATURE: more legible printout desperately needed
16 StringBuffer sb = new StringBuffer();
17 sb.append("unresolved ambiguity ");
18 HashSet<Forest> hf = new HashSet<Forest>();
20 HashSet<Tree> ht = new HashSet<Tree>();
21 ambiguity.expand(ht, hf, new Tree(null, "...", null, false));
22 for(Tree<?> result : ht) {
24 result.toPrettyString(sb);