X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FGSS.java;h=e4859d4513ec6fb8c1d7cdf5e84e23d97be9d949;hp=1adb8e445ee2dfb192f5a242b0a619bac940383e;hb=90500a338733b6ba0d5b9c0cdc5a7afea38173ae;hpb=526da96dd06e152d194ec92c9ef9df6085a1251b diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index 1adb8e4..e4859d4 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -24,7 +24,8 @@ class GSS { HashSet tail = new HashSet(); /** corresponds to a positions between tokens the input stream; same as Tomita's U_i's */ - public class Phase implements Invokable { + public class Phase implements Invokable, IntegerMappable { + public int toInt() { return pos+1; } /** the token immediately after this phase */ public final Token token; @@ -131,7 +132,10 @@ class GSS { ret.append("\n "); ret.append(message); HashMap> errors = new HashMap>(); - 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 hs = errors.get(s); @@ -293,7 +297,11 @@ class GSS { 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 next */ @@ -304,7 +312,6 @@ class GSS { Forest res = null; boolean ok = false; for(Phase.Node n : hash.values()) { - //if (n.holder().empty() && pos>0) continue; if (token == null && n.state.isAccepting()) { if (finalResult==null) finalResult = new Forest.Ref(); finalResult.merge(n.holder); @@ -398,7 +405,6 @@ class GSS { this.fe = fe; this.state = state; this.holder().merge(pending); - //if (holder().empty()) throw new Error(holder()+""); Phase start = parent==null ? null : parent.phase(); if (parent != null) parents().add(parent, true); if (Phase.this.hash.get(code(state, start)) != null) throw new Error("severe problem!");