projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
intermediate checkpoint
[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
db0db7d
..
ea2e2db
100644
(file)
--- a/
src/edu/berkeley/sbp/Union.java
+++ b/
src/edu/berkeley/sbp/Union.java
@@
-15,23
+15,28
@@
public class Union extends Element implements Iterable<Sequence> {
private final List<Sequence> alternatives = new ArrayList<Sequence>();
public Iterator<Sequence> iterator() { return alternatives.iterator(); }
private final List<Sequence> alternatives = new ArrayList<Sequence>();
public Iterator<Sequence> iterator() { return alternatives.iterator(); }
-
- void reachable(HashSet<Sequence.Position> h) { for(Sequence s : alternatives) s.reachable(h); }
+ 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();
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.dup();
- else ret = ret.union(a.dup());
+ if (ret==null) ret = a;
+ else ret = ret.union(a);
}
if (ret==null) throw new RuntimeException("confusion on " + this);
return ret;
}
/** adds an alternative */
}
if (ret==null) throw new RuntimeException("confusion on " + this);
return ret;
}
/** adds an alternative */
- public void add(Sequence s) { alternatives.add(s); }
+ public void add(Sequence s) {
+ alternatives.add(s);
+ if (/*!synthetic &&*/ shortForm!=null
+ && Character.isUpperCase(shortForm.charAt(0))
+ )
+ s.setName(toString());
+ }
/**
* Since every cycle in a non-degenerate grammar contains at
/**
* Since every cycle in a non-degenerate grammar contains at