package edu.berkeley.sbp;
import edu.berkeley.sbp.*;
import edu.berkeley.sbp.util.*;
package edu.berkeley.sbp;
import edu.berkeley.sbp.*;
import edu.berkeley.sbp.util.*;
public Forest.Ref finalResult;
/** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
public Forest.Ref finalResult;
/** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
- public class Phase implements Invokable<State, Forest, GSS.Phase.Node>, IntegerMappable {
+ public class Phase<Tok> implements Invokable<State, Forest, Phase<Tok>.Node>, IntegerMappable {
+
+ public void invoke(State st, Forest result, Node n) {
+ good |= next.newNode(n, result, st, false);
+ }
- public Phase(Phase prev, Parser parser, Phase previous, Token token, Token.Location location, Forest forest) {
+ public Phase(Phase prev, Parser parser, Phase previous, Tok token, Token.Location location, Forest forest) {
- public void invoke(State st, Forest result, Node n) {
- good |= next.newNode(n, result, st, false);
- }
-
/** perform all shift operations, adding promoted nodes to <tt>next</tt> */
public void shift(Phase next, Forest result) throws ParseFailed {
// this massively improves GC performance
/** perform all shift operations, adding promoted nodes to <tt>next</tt> */
public void shift(Phase next, Forest result) throws ParseFailed {
// this massively improves GC performance
/** which Phase this Node belongs to (node that Node is also a non-static inner class of Phase) */
public Phase phase() { return Phase.this; }
/** which Phase this Node belongs to (node that Node is also a non-static inner class of Phase) */
public Phase phase() { return Phase.this; }
- public void reduce(Position r, int pos, GSS.Phase target, Forest[] holder) {
+ public void reduce(Position r, int pos, Phase target, Forest[] holder) {
Forest old = holder[pos];
holder[pos] = this.pending();
if (pos==0) {
System.arraycopy(holder, 0, r.holder, 0, holder.length);
for(int i=0; i<r.pos; i++) if (r.holder[i]==null) throw new Error("realbad");
Forest rex = r.rewrite(target.getLocation());
Forest old = holder[pos];
holder[pos] = this.pending();
if (pos==0) {
System.arraycopy(holder, 0, r.holder, 0, holder.length);
for(int i=0; i<r.pos; i++) if (r.holder[i]==null) throw new Error("realbad");
Forest rex = r.rewrite(target.getLocation());
- for(GSS.Phase.Node child : this.parents()) child.finish(r, rex, target, holder);
+ for(Node child : this.parents()) child.finish(r, rex, target, holder);
- for(GSS.Phase.Node child : this.parents()) child.reduce(r, pos-1, target, holder);
+ for(Node child : this.parents()) child.reduce(r, pos-1, target, holder);
- public void finish(Position r, Forest result, GSS.Phase target, Forest[] holder) {
- State state0 = state.gotoSetNonTerminals.get(r.owner());
+ public void finish(Position r, Forest result, Phase<Tok> target, Forest[] holder) {
+ Parser.Table<Tok>.State<Tok> state0 = state.gotoSetNonTerminals.get(r.owner());
if (result==null) throw new Error();
if (state0!=null)
target.newNode(this, result, state0, r.pos<=0, r);
if (result==null) throw new Error();
if (state0!=null)
target.newNode(this, result, state0, r.pos<=0, r);