-// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+// Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
package edu.berkeley.sbp;
import edu.berkeley.sbp.util.*;
private final List<Sequence> alternatives = new ArrayList<Sequence>();
public Union(String name) { this(name, false); }
- public Union(String name, Sequence s) { this(name, false); add(s); }
+ public Union(String name, Sequence s) { this(name, s, false); }
+ public Union(String name, Sequence s, boolean synthetic) { this(name, synthetic); add(s); }
/**
* Since every cycle in a non-degenerate grammar contains at
add(Sequence.create(e));
}
-
- // Epsilon Form //////////////////////////////////////////////////////////////////////////////
-
- private Forest.Many epsilonForm = null;
- Forest epsilonForm(Input.Region loc) {
- // FIXME: this is pretty ugly...
+ /** the Forest which results from matching this Union against the empty string at region <tt>region</tt> */
+ Forest epsilonForm(Input.Region region) {
viewed = true;
- if (epsilonForm != null) return epsilonForm;
Forest.Many epsilonForm = new Forest.Many();
- Cache cache = new Cache(null, null);
for(Sequence s : this)
- if (cache.possiblyEpsilon(s))
- epsilonForm.merge(s.epsilonForm(loc));
+ if (Element.possiblyEpsilon(s))
+ epsilonForm.merge(s.epsilonForm(region));
return epsilonForm;
}