projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
145a9ca
)
checkpoint
author
adam
<adam@megacz.com>
Wed, 4 Jan 2006 10:53:17 +0000
(
05:53
-0500)
committer
adam
<adam@megacz.com>
Wed, 4 Jan 2006 10:53:17 +0000
(
05:53
-0500)
darcs-hash:
20060104105317
-5007d-
bed73d0e9cb6781fca85c4837237d63133667a5a
.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
817aea6
..
a24c523
100644
(file)
--- a/
src/edu/berkeley/sbp/Parser.java
+++ b/
src/edu/berkeley/sbp/Parser.java
@@
-312,9
+312,8
@@
public abstract class Parser<T extends Token, R> {
public String toString() { return "[reduce " + position + "]"; }
public Forest reduce(GSS.Phase.Node parent) {
public String toString() { return "[reduce " + position + "]"; }
public Forest reduce(GSS.Phase.Node parent) {
- Forest rex = numPop==0 ? zero() : null;
- Forest ret = reduce(parent, numPop-1, rex, null, parent.phase());
- return ret;
+ if (numPop==0) return finish(parent, zero(), parent.phase());
+ return reduce(parent, numPop-1, null, null, parent.phase());
}
public Forest reduce(GSS.Phase.Node parent, GSS.Phase.Node onlychild) {
}
public Forest reduce(GSS.Phase.Node parent, GSS.Phase.Node onlychild) {
@@
-357,12
+356,16
@@
public abstract class Parser<T extends Token, R> {
for(GSS.Phase.Node child : parent.parents())
reduce(child, pos-1, rex, null, target);
} else {
for(GSS.Phase.Node child : parent.parents())
reduce(child, pos-1, rex, null, target);
} else {
- State state = parent.state.gotoSetNonTerminals.get(position.owner());
- if (state!=null)
- target.newNode(parent, rex, state, numPop<=0, parent.phase());
+ return finish(parent, rex, target);
}
return rex;
}
}
return rex;
}
+ private Forest finish(GSS.Phase.Node parent, Forest result, GSS.Phase target) {
+ State state = parent.state.gotoSetNonTerminals.get(position.owner());
+ if (state!=null)
+ target.newNode(parent, result, state, numPop<=0, parent.phase());
+ return result;
+ }
}
}
}
}