fix javadoc generation
[sbp.git] / src / edu / berkeley / sbp / Union.java
index 1843a46..8f3ea2e 100644 (file)
@@ -1,4 +1,4 @@
-// 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.*;
@@ -26,7 +26,8 @@ public class Union extends Element implements Iterable<Sequence> {
     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
@@ -72,19 +73,13 @@ public class Union extends Element implements Iterable<Sequence> {
         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;
     }