- public Token.Location getLocation() { return location; }
-
- /** add a new node (merging with existing nodes if possible)
- * @param parent the parent of the new node
- * @param result the SPPF result corresponding to the new node
- * @param state the state that the new node is in
- * @param fromEmptyReduction true iff this node is being created as a result of a reduction of length zero (see GRMLR paper)
- * @param start the earliest part of the input contributing to this node (used to make merging decisions)
- */
- public void newNode(Node parent, Forest pending, Parser.Table.State state, boolean fromEmptyReduction) {
- Node p = hash.get(code(state, parent==null?null:parent.phase()));
- if (p != null) newNode2(p, parent, pending, state, fromEmptyReduction);
- else newNode3(parent, pending, state, fromEmptyReduction);
- }
- private void newNode2(Node p, Node parent, Forest pending, Parser.Table.State state, boolean fromEmptyReduction) {
- p.holder.merge(pending);
- if (p.parents().contains(parent)) return;
- p.parents().add(parent, true);
- if (p!=parent && !fromEmptyReduction) p.queueReductions(parent);
- }
- private void newNode3(Node parent, Forest pending, Parser.Table.State state, boolean fromEmptyReduction) {
- do {
- if (token != null && state.canShift(token)) break;
- if (state.isAccepting()) break;
- if (token==null) break;
- if (!state.canReduce(token)) return;
- //if (count > 1) break;
- //if (r.numPop == 0) break;
- //r.reduce(pending, parent, null, Phase.this, null);
- //return;
- } while(false);
+ /** the token immediately after this phase */
+ final Tok token;
+ final int pos;
+ public IntPairMap<StateNode> hash = new IntPairMap<StateNode>(); /* ALLOC */
+ private boolean good = false;
+ private Phase next = null;
+ private Phase prev;
+ private Input.Location location;
+ private Input.Location nextLocation;
+
+ private Forest forest;