- private Phase next = null;
-
- /** perform all shift operations, adding promoted nodes to <tt>next</tt> */
- public void shift(Phase next, Forest result) {
- this.next = next;
- closed = true;
- Forest res = null;
- boolean ok = false;
- for(Phase.Node n : hash.values()) {
- if (n.holder==null) continue;
- n.holder.resolve();
- if (token == null && n.state.isAccepting()) {
- ok = true;
- if (finalResult==null) finalResult = new Forest.Ref();
- finalResult.merge(n.holder);
- }
- if (!n.holder.valid()) continue;
- if (token == null) continue;
- n.state.invokeShifts(token, this, result, n);
- /*
- for(Parser.Table.State st : n.state.getShifts(token)) {
- if (res == null) res = result;
- next.newNode(n, res, st, true, this);
- ok = true;
- }
- */
- }
-
- if (!ok && token != null) {
- StringBuffer error = new StringBuffer();
- error.append("error: unable to shift token \"" + token + "\"\n");
- //error.append(" before: " +pendingReductions+ "\n");
- //error.append(" before: " +totalReductions+ "\n");
- //for(Phase.Node n : hash.values()) {
- //n.queueReductions();
- //n.queueEmptyReductions();
- //}
- //error.append(" after: " +pendingReductions+ "\n");
- //error.append(" candidate states:\n");
- //for(Phase.Node n : hash.values()) {
- //for(Sequence.Position p : n.state) error.append(" " + p + "\n");
- //error.append(" --\n");
- //for(Parser.Table.Reduction r : n.state.getReductions(token)) error.append(" " + r + "\n");
- //error.append(" ==\n");
- //}
- next.error = error.toString();
- }
-
- // this massively improves GC performance
- hash = null;
- }
-
-
- // GSS Nodes //////////////////////////////////////////////////////////////////////////////
-
- /** a node in the GSS */
- public final class Node extends FastSet<Node> implements Invokable<Parser.Table.Reduction, Node, Node> {
-
- private Forest.Ref holder = null;
- private boolean allqueued = false;
-
- /** what state this node is in */
- public final Parser.Table.State state;