projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hoisted getLocation() out of Token and into Token.Stream
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
GSS.java
diff --git
a/src/edu/berkeley/sbp/GSS.java
b/src/edu/berkeley/sbp/GSS.java
index
d8c0fd4
..
69d9eed
100644
(file)
--- a/
src/edu/berkeley/sbp/GSS.java
+++ b/
src/edu/berkeley/sbp/GSS.java
@@
-59,9
+59,11
@@
class GSS {
boolean closed = false;
boolean closed = false;
- public Phase(Phase previous, Token token) {
+ private Token.Location location;
+ public Phase(Phase previous, Token token, Token.Location location) {
this.pos = previous==null ? 0 : previous.pos+1;
this.token = token;
this.pos = previous==null ? 0 : previous.pos+1;
this.token = token;
+ this.location = location;
}
public boolean isDone() { return token == null; }
}
public boolean isDone() { return token == null; }
@@
-72,7
+74,7
@@
class GSS {
throw new Parser.Failed(error, getLocation());
}
throw new Parser.Failed(error, getLocation());
}
- public Token.Location getLocation() { return token==null ? null : token.getLocation(); }
+ public Token.Location getLocation() { return location; }
/** add a new node (merging with existing nodes if possible)
* @param parent the parent of the new node
/** add a new node (merging with existing nodes if possible)
* @param parent the parent of the new node
@@
-123,7
+125,7
@@
class GSS {
}
/** perform all shift operations, adding promoted nodes to <tt>next</tt> */
}
/** perform all shift operations, adding promoted nodes to <tt>next</tt> */
- public void shift(Phase next) {
+ public void shift(Phase next, Forest result) {
closed = true;
Forest res = null;
boolean ok = false;
closed = true;
Forest res = null;
boolean ok = false;
@@
-137,7
+139,7
@@
class GSS {
if (!n.holder.valid()) continue;
if (token == null) continue;
for(Parser.Table.State st : n.state.getShifts(token)) {
if (!n.holder.valid()) continue;
if (token == null) continue;
for(Parser.Table.State st : n.state.getShifts(token)) {
- if (res == null) res = Forest.create(token.getLocation(), token.result(), null, null, false, false);
+ if (res == null) res = result;
next.newNode(n, res, st, true, this);
ok = true;
}
next.newNode(n, res, st, true, this);
ok = true;
}