public GSS(Input input, Parser parser) { this.input = input; this.parser = parser;}
public Input getInput() { return input; }
public GSS(Input input, Parser parser) { this.input = input; this.parser = parser;}
public Input getInput() { return input; }
- class Phase<Tok> implements Invokable<State, StateNode, Forest>, IntegerMappable, GraphViz.ToGraphViz, Iterable<StateNode> {
+ class Phase<Tok> implements Invokable<State, StateNode, Forest>, IntegerMappable, GraphViz.ToGraphViz /*, Iterable<StateNode>*/ {
// FIXME: right now, these are the performance bottleneck
private HashMapBag<Integer,Integer> performed = new HashMapBag<Integer,Integer>();
// FIXME: right now, these are the performance bottleneck
private HashMapBag<Integer,Integer> performed = new HashMapBag<Integer,Integer>();
- good |= next.newNode(f, null, pred, st, false);
+ good |= next.newNode(f, null, pred, st);
- newNode(null, null, null, startState, true);
+ newNode(null, null, null, startState);
}
public Phase(Phase prev, Forest forest) throws ParseFailed, IOException {
this.location = input.getLocation();
}
public Phase(Phase prev, Forest forest) throws ParseFailed, IOException {
this.location = input.getLocation();
if (token == null && n.state().isAccepting()) {
if (finalResult==null) finalResult = new Forest.Many();
for(ResultNode r : n)
if (token == null && n.state().isAccepting()) {
if (finalResult==null) finalResult = new Forest.Many();
for(ResultNode r : n)
performed.add(pos, reduction.provides());
Parser.Table.State state = (Parser.Table.State)pred.state().gotoSetNonTerminals.get(reduction);
if (state!=null)
performed.add(pos, reduction.provides());
Parser.Table.State state = (Parser.Table.State)pred.state().gotoSetNonTerminals.get(reduction);
if (state!=null)
- newNode(f, reduction, pred, state, reduction.numPops()<=0);
+ newNode(f, reduction, pred, state);
}
/** 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
}
/** 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
- private boolean newNode(Forest f, Pos reduction, StateNode pred, State state, boolean fromEmptyReduction) {
+ private boolean newNode(Forest f, Pos reduction, StateNode pred, State state) {
if (token != null && state.canShift(token)) break;
if (state.isAccepting()) break;
if (token==null) break;
if (!state.canReduce(token)) return false;
} while(false);
if (token != null && state.canShift(token)) break;
if (state.isAccepting()) break;
if (token==null) break;
if (!state.canReduce(token)) return false;
} while(false);
- StateNode n = new StateNode(Phase.this, f, reduction, pred, state, fromEmptyReduction); // ALLOC
+ StateNode n = new StateNode(Phase.this, new ResultNode(f, reduction, pred), state); // ALLOC
/** FIXME: this null-result can be used to notice bogus/dead states */
for(Object s : state.conjunctStates)
/** FIXME: this null-result can be used to notice bogus/dead states */
for(Object s : state.conjunctStates)
- newNode(null, null, n, (State)s, fromEmptyReduction);
+ newNode(null, null, n, (State)s);
public int size() { return hash==null ? 0 : hash.size(); }
public int pos() { return pos; }
public Tok getToken() { return token; }
public int size() { return hash==null ? 0 : hash.size(); }
public int pos() { return pos; }
public Tok getToken() { return token; }
public GSS getGSS() { return GSS.this; }
// GraphViz //////////////////////////////////////////////////////////////////////////////
public GSS getGSS() { return GSS.this; }
// GraphViz //////////////////////////////////////////////////////////////////////////////
FileOutputStream fos = new FileOutputStream(filename);
PrintWriter p = new PrintWriter(new OutputStreamWriter(fos));
GraphViz gv = new GraphViz();
FileOutputStream fos = new FileOutputStream(filename);
PrintWriter p = new PrintWriter(new OutputStreamWriter(fos));
GraphViz gv = new GraphViz();