ret.append("\n ");
ret.append(message);
HashMap<String,HashSet<String>> errors = new HashMap<String,HashSet<String>>();
- for(Node n : hash.values()) complain(n, errors, false);
+ for(Node n : hash.values()) {
+ //System.out.println(n.state);
+ complain(n, errors, false);
+ }
for(String s : errors.keySet()) {
ret.append(" while parsing " + yellow(s));
HashSet<String> hs = errors.get(s);
class Reset extends RuntimeException { }
public void invoke(State st, Forest result, Node n) {
- good |= next.newNode(n, result, st, false);
+ boolean ok = next.newNode(n, result, st, false);
+ if (ok && !good) {
+ good = !st.lame();
+ //if (good) System.out.println(st);
+ }
}
/** perform all shift operations, adding promoted nodes to <tt>next</tt> */
}
/** a single state in the LR table and the transitions possible from it */
- public class State implements Comparable<Table.State>, Iterable<Position>, IntegerMappable {
+
+ public class State implements Comparable<Table.State>, IntegerMappable, Iterable<Position> {
public int toInt() { return idx; }
+ public boolean lame() {
+ for(Position p : this)
+ for(Position p2 = p; p2!=null; p2=p2.next())
+ if (p2.isLast() && !p2.owner().lame)
+ return false;
+ return true;
+ }
/*
public boolean isResolvable(Token t) {
boolean found = false;
}
}
- public String toString() { return "state["+idx+"]"; }
+ public String toString() {
+ //return "state["+idx+"]";
+ StringBuffer ret = new StringBuffer();
+ ret.append("state["+idx+"]: ");
+ for(Position p : this) ret.append("{"+p+"} ");
+ return ret.toString();
+ }
public int compareTo(Table.State s) { return idx==s.idx ? 0 : idx < s.idx ? -1 : 1; }
}
public void add(Sequence s) {
alternatives.add(s);
if (/*!synthetic &&*/ shortForm!=null
- && Character.isUpperCase(shortForm.charAt(0))
+ //&& Character.isUpperCase(shortForm.charAt(0))
)
s.setName(toString());
}