projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
summary patch for Nov->Jan work
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
Sequence.java
diff --git
a/src/edu/berkeley/sbp/Sequence.java
b/src/edu/berkeley/sbp/Sequence.java
index
9535357
..
d3d8d8a
100644
(file)
--- a/
src/edu/berkeley/sbp/Sequence.java
+++ b/
src/edu/berkeley/sbp/Sequence.java
@@
-14,6
+14,8
@@
public abstract class Sequence implements Iterable<Element>, SequenceOrElement {
protected final Element[] elements;
protected final Element[] elements;
+ public boolean needed_or_hated = false;
+
final HashSet<Sequence> hated = new HashSet<Sequence>();
final HashSet<Sequence> needs = new HashSet<Sequence>();
final HashSet<Sequence> hated = new HashSet<Sequence>();
final HashSet<Sequence> needs = new HashSet<Sequence>();
@@
-65,14
+67,20
@@
public abstract class Sequence implements Iterable<Element>, SequenceOrElement {
////////////////////////////////////////////////////////////////////////////////
/** return a new sequence identical to this one, but with a positive conjunct <tt>s</tt> */
////////////////////////////////////////////////////////////////////////////////
/** return a new sequence identical to this one, but with a positive conjunct <tt>s</tt> */
- public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); return ret; }
+ public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); s.needed_or_hated=true; return ret; }
/** return a new sequence identical to this one, but with a negative conjunct <tt>s</tt> */
/** return a new sequence identical to this one, but with a negative conjunct <tt>s</tt> */
- public Sequence andnot(Sequence s) { Sequence ret = dup(); ret.hates.add(s); s.hated.add(ret); return ret; }
+ public Sequence andnot(Sequence s) { Sequence ret = dup(); ret.hates.add(s); s.hated.add(ret); s.needed_or_hated=true; return ret; }
/** return a new sequence identical to this one, but with a follow-set restricted to <tt>a</tt> */
public Sequence followedBy(Atom a) { Sequence ret = dup(); ret.follow = a; return ret; }
/** return a new sequence identical to this one, but with a follow-set restricted to <tt>a</tt> */
public Sequence followedBy(Atom a) { Sequence ret = dup(); ret.follow = a; return ret; }
+ boolean hatesAny(Iterable<Sequence> it) {
+ if (hates.isEmpty()) return false;
+ for(Sequence s : it) if (hates.contains(s)) return true;
+ return false;
+ }
+
Iterable<Sequence> needs() { return needs; }
Iterable<Sequence> hates() { return hates; }
Iterable<Sequence> needs() { return needs; }
Iterable<Sequence> hates() { return hates; }