if (start0.contains(p.owner()) && p.next()==null)
state.accept = true;
- if (p.isRightNullable(cache)) {
+ if (isRightNullable(p)) {
Walk.Follow wf = new Walk.Follow(top.empty(), p.owner(), all_elements, cache);
Reduction red = new Reduction(p);
}
}
+ private boolean isRightNullable(Position p) {
+ if (p.isLast()) return true;
+ if (!p.element().possiblyEpsilon(this)) return false;
+ return isRightNullable(p.next());
+ }
+
/** a single state in the LR table and the transitions possible from it */
public class State implements Comparable<Table.State>, IntegerMappable, Iterable<Position> {
}
boolean isFirst() { return pos==0; }
- boolean isRightNullable(Walk.Cache cache) {
- if (isLast()) return true;
- if (!element().possiblyEpsilon(cache)) return false;
- return next().isRightNullable(cache);
- }
/** the element immediately after this Position, or null if this is the last Position */
public Element element() { return pos>=elements.length ? null : elements[pos]; }
for(Position p = Sequence.this.firstp(); p != null; p = p.next()) {
ret.append(' ');
if (p==this) ret.append(" | ");
- if (p.element()!=null) ret.append(p.element().possiblyEpsilon(null) ? "["+p.element()+"]" : p.element());
+ if (p.element()!=null) ret.append(p.element());
else ret.append(' ');
}
ret.append("}>");
public final HashMap<Element,Boolean> possiblyEpsilon = new HashMap<Element,Boolean>();
public HashMap<Element,Boolean> eof = new HashMap<Element,Boolean>();
public HashMap<Element,Topology> follow = new HashMap<Element,Topology>();
- //public HashMap<Element,HashSet<Element>> ys = new HashMap<Element,HashSet<Element>>();
public HashMapBag<Element,Element> ys = new HashMapBag<Element,Element>();
public HashMap<Element,Topology> atoms = new HashMap<Element,Topology>();
}