+// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+
package edu.berkeley.sbp;
import edu.berkeley.sbp.util.*;
import edu.berkeley.sbp.*;
*/
public class Union extends Element implements Iterable<Sequence> {
- private final String name;
- private final boolean synthetic;
+ /*private*/ final String name;
+ /*private*/ final boolean synthetic;
private boolean viewed = false;
private final List<Sequence> alternatives = new ArrayList<Sequence>();
return alternatives.contains(s);
}
+ /** iterator over this Union's Sequences */
public Iterator<Sequence> iterator() {
viewed = true;
return alternatives.iterator();
/** adds an alternative */
public void add(Sequence s) {
+ /*
+ FIXME
if (viewed)
- throw new RuntimeException("attempt to add a Sequence to a Union that has already been examined");
+ throw new RuntimeException("attempt to add a Sequence to a Union that has already been examined:\n "+this);
+ */
if (alternatives.contains(s)) return;
alternatives.add(s);
}
+ /** adds a one-element sequence */
+ public void add(Element e) {
+ add(Sequence.create(e));
+ }
+
// Epsilon Form //////////////////////////////////////////////////////////////////////////////
// FIXME
- private Forest.Many epsilonForm = null;
- Forest epsilonForm() {
- if (epsilonForm != null) return epsilonForm;
- epsilonForm = new Forest.Many();
+ //private Forest.Many epsilonForm = null;
+ Forest epsilonForm(Input.Region loc) {
+ //if (epsilonForm != null) return epsilonForm;
+ Forest.Many epsilonForm = new Forest.Many();
for(Sequence s : this) {
// FIXME FIXME FIXME
if (new Walk.Cache().possiblyEpsilon(s))
- epsilonForm.merge(s.epsilonForm());
+ epsilonForm.merge(s.epsilonForm(loc));
}
return epsilonForm;
}