X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=b4ac23a0a3285023df34427c262e921a9411e241;hb=cd979dfc5968a185c12d6eedc2aa688ef4b0f8b8;hp=8869281b97e9ef9caaa7417db16ce1a3b106b2ca;hpb=5e831dcf55eafdc17e2255e7d63b319672a4be6a;p=sbp.git diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 8869281..b4ac23a 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -32,8 +32,8 @@ public abstract class Parser { current.reduce(); Forest forest = current.token==null ? null : shiftedToken((T)current.token, loc); GSS.Phase next = gss.new Phase(current, this, current, input.next(count, gss.resets, gss.waits), loc, forest); - count = next.hash.size(); - if (current.isDone()) return (Forest)current.finalResult; + count = next.size(); + if (current.isDone()) return (Forest)gss.finalResult; current = next; } } @@ -126,7 +126,7 @@ public abstract class Parser { public final int idx = master_state_idx++; private final HashSet hs; - private transient HashMap gotoSetNonTerminals = new HashMap(); + public transient HashMap gotoSetNonTerminals = new HashMap(); private transient TopologicalBag gotoSetTerminals = new TopologicalBag(); private TopologicalBag reductions = new TopologicalBag(); @@ -272,47 +272,6 @@ public abstract class Parser { return zero = position.rewrite(null); } - public void reduce(GSS.Phase.Node parent) { - Forest[] holder = new Forest[position.pos]; - if (position.pos==0) finish(parent, zero(), parent.phase(), holder); - else reduce(parent, position.pos-1, parent.phase(), holder); - } - - public void reduce(GSS.Phase.Node parent, GSS.Phase.Node onlychild) { - Forest[] holder = new Forest[position.pos]; - if (position.pos<=0) throw new Error("called wrong form of reduce()"); - int pos = position.pos-1; - Forest old = holder[pos]; - holder[pos] = parent.pending(); - if (pos==0) { - System.arraycopy(holder, 0, position.holder, 0, holder.length); - finish(onlychild, position.rewrite(parent.phase().getLocation()), parent.phase(), holder); - } else { - reduce(onlychild, pos-1, parent.phase(), holder); - } - holder[pos] = old; - } - - // FIXME: this could be more elegant and/or cleaner and/or somewhere else - private void reduce(GSS.Phase.Node parent, int pos, GSS.Phase target, Forest[] holder) { - Forest old = holder[pos]; - holder[pos] = parent.pending(); - if (pos==0) { - System.arraycopy(holder, 0, position.holder, 0, holder.length); - for(int i=0; i