- final String shortForm;
- final boolean synthetic;
- private final List<Sequence> alternatives = new ArrayList<Sequence>();
-
- public Iterator<Sequence> iterator() { return alternatives.iterator(); }
- public boolean contains(Sequence s) { return alternatives.contains(s); }
-
- Topology toAtom() {
- if (alternatives.size()==0) throw new RuntimeException("cannot build an Atom from a Union with no productions");
- Topology ret = null;
- for(Sequence s : this) {
- Topology a = s.toAtom();
- if (ret==null) ret = a;
- else ret = ret.union(a);
- }
- if (ret==null) throw new RuntimeException("confusion on " + this);
- return ret;
- }
-
- /** adds an alternative */
- public void add(Sequence s) {
- alternatives.add(s);
- for(Sequence n : s.needs) add(n);
- for(Sequence n : s.hates) add(n);
- if (/*!synthetic &&*/ shortForm!=null
- //&& Character.isUpperCase(shortForm.charAt(0))
- )
- s.setName(toString());
- }
-