////////////////////////////////////////////////////////////////////////////////
public Element noFollow = null;
- public String name = null;
- public void setName(String name) { this.name = name; }
- public final Topology noFollow() { return noFollow==null ? null : noFollow.toAtom(); }
+ public final Topology noFollow() { return noFollow==null ? null : Atom.toAtom(noFollow); }
Topology toAtom() {
if (elements.length!=1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this);
- return elements[0].toAtom();
+ return Atom.toAtom(elements[0]);
}
protected final Element[] elements;
// DO NOT MESS WITH THE FOLLOWING LINE!!!
private Forest.Ref epsilonForm = null;
- private boolean eps = false;
Forest epsilonForm() {
- if (epsilonForm==null) {
- epsilonForm = new Forest.Ref();
- epsilonForm.merge(firstp().rewrite2(null));
- }
+ if (epsilonForm!=null) return epsilonForm;
+ epsilonForm = new Forest.Ref();
+ epsilonForm.merge(firstp().rewrite(null, false));
return epsilonForm;
}
// Position /////////////////////////////////////////////////////////////////////////////////
- final <T> Forest<T> rewrite(Input.Location loc) {
- if (this==firstp()) return epsilonForm();
- return rewrite2(loc);
- }
-
- final <T> Forest<T> rewrite2(Input.Location loc) {
+ final <T> Forest<T> rewrite(Input.Location loc) { return rewrite(loc, true); }
+ private final <T> Forest<T> rewrite(Input.Location loc, boolean epsilonCheck) {
+ if (epsilonCheck && this==firstp()) return epsilonForm();
for(int i=0; i<pos; i++) if (holder[i]==null) throw new Error("realbad " + i);
for(int i=pos; i<elements.length; i++) {
if (holder[i]==null) holder[i] = elements[i].epsilonForm();