projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
keep track of which reduction created each result (if any)
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
Union.java
diff --git
a/src/edu/berkeley/sbp/Union.java
b/src/edu/berkeley/sbp/Union.java
index
1843a46
..
8f3ea2e
100644
(file)
--- a/
src/edu/berkeley/sbp/Union.java
+++ b/
src/edu/berkeley/sbp/Union.java
@@
-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.*;
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); }
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
/**
* 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));
}
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;
viewed = true;
- if (epsilonForm != null) return epsilonForm;
Forest.Many epsilonForm = new Forest.Many();
Forest.Many epsilonForm = new Forest.Many();
- Cache cache = new Cache(null, null);
for(Sequence s : this)
for(Sequence s : this)
- if (cache.possiblyEpsilon(s))
- epsilonForm.merge(s.epsilonForm(loc));
+ if (Element.possiblyEpsilon(s))
+ epsilonForm.merge(s.epsilonForm(region));
return epsilonForm;
}
return epsilonForm;
}