From f13be78d4291906d2f4c7588567cb114f0cc3b54 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 4 Jan 2006 06:07:06 -0500 Subject: [PATCH] checkpoint darcs-hash:20060104110706-5007d-717b083eff757438e1f41a3dc103655e0bd7b7b3.gz --- src/edu/berkeley/sbp/Parser.java | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 65f3dc3..d258b78 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -311,6 +311,13 @@ public abstract class Parser { } public String toString() { return "[reduce " + position + "]"; } + private Forest zero = null; + public Forest zero() { + if (zero != null) return zero; + if (numPop > 0) throw new Error(); + return zero = position.rewrite(null); + } + public Forest reduce(GSS.Phase.Node parent) { if (numPop==0) return finish(parent, zero(), parent.phase()); return reduce(parent, numPop-1, null, parent.phase()); @@ -320,21 +327,11 @@ public abstract class Parser { if (numPop<=0) throw new Error("called wrong form of reduce()"); int pos = numPop-1; holder[pos] = parent.pending(); - Forest rex = null; if (pos==0) { - if (rex==null) { - System.arraycopy(holder, 0, position.holder, 0, holder.length); - rex = position.rewrite(parent.phase().getLocation()); - } + System.arraycopy(holder, 0, position.holder, 0, holder.length); + return finish(onlychild, position.rewrite(parent.phase().getLocation()), parent.phase()); } - return reduce(onlychild, pos-1, rex, parent.phase()); - } - - private Forest zero = null; - public Forest zero() { - if (zero != null) return zero; - if (numPop > 0) throw new Error(); - return zero = position.rewrite(null); + return reduce(onlychild, pos-1, null, parent.phase()); } // FIXME: this could be more elegant and/or cleaner and/or somewhere else @@ -346,6 +343,8 @@ public abstract class Parser { rex = position.rewrite(target.getLocation()); } for(GSS.Phase.Node child : parent.parents()) + //if (pos==0) finish(parent, rex, target); + //else reduce(child, pos-1, rex, target); return rex; } -- 1.7.10.4