projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b0ec1ef
)
checkpoint
author
adam
<adam@megacz.com>
Wed, 4 Jan 2006 11:07:06 +0000
(06:07 -0500)
committer
adam
<adam@megacz.com>
Wed, 4 Jan 2006 11:07:06 +0000
(06:07 -0500)
darcs-hash:
20060104110706
-5007d-
717b083eff757438e1f41a3dc103655e0bd7b7b3
.gz
src/edu/berkeley/sbp/Parser.java
patch
|
blob
|
history
diff --git
a/src/edu/berkeley/sbp/Parser.java
b/src/edu/berkeley/sbp/Parser.java
index
65f3dc3
..
d258b78
100644
(file)
--- a/
src/edu/berkeley/sbp/Parser.java
+++ b/
src/edu/berkeley/sbp/Parser.java
@@
-311,6
+311,13
@@
public abstract class Parser<T extends Token, R> {
}
public String toString() { return "[reduce " + position + "]"; }
}
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());
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<T extends Token, R> {
if (numPop<=0) throw new Error("called wrong form of reduce()");
int pos = numPop-1;
holder[pos] = parent.pending();
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 (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
}
// FIXME: this could be more elegant and/or cleaner and/or somewhere else
@@
-346,6
+343,8
@@
public abstract class Parser<T extends Token, R> {
rex = position.rewrite(target.getLocation());
}
for(GSS.Phase.Node child : parent.parents())
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;
}
reduce(child, pos-1, rex, target);
return rex;
}