import java.lang.reflect.*;
/** a node in the GSS */
-final class Node
+final class StateNode
implements Invokable<Pos, Result, Object>,
IntegerMappable,
GraphViz.ToGraphViz,
Iterable<Result> {
- /** which GSS.Phase this Node belongs to */
+ /** which GSS.Phase this StateNode belongs to */
public GSS.Phase phase() { return phase; }
public Iterator<Result> iterator() { return results.iterator(); }
public Parser.Table.State state() { return state; }
private void reduce(Pos r, int pos, GSS.Phase target, Result only) {
for(Result res : results)
if (only == null || res == only)
- for(Node pred : res.getPreds())
+ for(StateNode pred : res.getPreds())
reduce2(r, pos, target, pred, res.getForest());
}
- void reduce2(Pos r, int pos, GSS.Phase target, Node pred, Forest f) {
+ void reduce2(Pos r, int pos, GSS.Phase target, StateNode pred, Forest f) {
Forest[] holder = r.holder;
Forest old = pos >= holder.length ? null : holder[pos];
if (pos < holder.length) holder[pos] = f;
if (pos < holder.length) holder[pos] = old;
}
- Node(GSS.Phase phase, Forest f, Pos reduction, Node pred, State state, boolean fromEmptyReduction) {
+ StateNode(GSS.Phase phase, Forest f, Pos reduction, StateNode pred, State state, boolean fromEmptyReduction) {
this(phase, new Result(f, reduction, pred), state, fromEmptyReduction);
}
- Node(GSS.Phase phase, Result pred, State state, boolean fromEmptyReduction) {
+ StateNode(GSS.Phase phase, Result pred, State state, boolean fromEmptyReduction) {
this.phase = phase;
this.state = state;
this.fromEmptyReduction = fromEmptyReduction;
public void addSucc(Result succ) {
successors.add(succ);
}
- public void addResult(Forest f, Pos reduction, Node pred) {
+ public void addResult(Forest f, Pos reduction, StateNode pred) {
for(Result r : results)
if (r.predecessorsContains(pred)) {
r.merge(f);
// GraphViz //////////////////////////////////////////////////////////////////////////////
- public GraphViz.Node toGraphViz(GraphViz gv) {
+ public GraphViz.StateNode toGraphViz(GraphViz gv) {
if (results.size()==0) return null;
if (gv.hasNode(this)) return gv.createNode(this);
- GraphViz.Node n = gv.createNode(this);
+ GraphViz.StateNode n = gv.createNode(this);
n.label = "state["+state.toInt()+"]";
n.shape = "rectangle";
boolean haspreds = false;