X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fchr%2FCharAtom.java;h=1d76aa7c7e3179f7637893ccb66586062ef1d38b;hp=c0df627c090ce29edc5ebbec67289f73d645e6e4;hb=75d0fa39d405292f4b831a6d1743f2aeea01ebd4;hpb=189d68c64f7aaec90b7cdef0fb2c358fe4f0dd21 diff --git a/src/edu/berkeley/sbp/chr/CharAtom.java b/src/edu/berkeley/sbp/chr/CharAtom.java index c0df627..1d76aa7 100644 --- a/src/edu/berkeley/sbp/chr/CharAtom.java +++ b/src/edu/berkeley/sbp/chr/CharAtom.java @@ -10,9 +10,11 @@ import edu.berkeley.sbp.Input.Location; public class CharAtom extends Atom { + public CharAtom() { this(new CharTopology()); } public CharAtom(char a) { this(a,a); } public CharAtom(char a, char b) { this(new CharTopology(a, b)); } public CharAtom(CharTopology t) { this.t = t; } + public CharAtom(Topology t) { this(t instanceof CharTopology ? (CharTopology)t : new CharTopology(t)); } private CharTopology t; public Topology top() { return t; } @@ -24,7 +26,6 @@ public class CharAtom extends Atom { public static final Atom braces = new CharAtom(left,right) { public String toString() { return "[{}]"; } }; public static Atom set(Range.Set r) { return new CharAtom(new CharTopology(r)); } - public String toString() { return t.toString(); } /** returns an element which exactly matches the string given */ @@ -42,12 +43,29 @@ public class CharAtom extends Atom { public String toString() { return escapified; } }; Element[] refs = new Element[s.length()]; for(int i=0; i> unwrap() { return this; } + public Topology> empty() { return new CharAtom(); } + public Topology getTokenTopology() { return top(); } + + public boolean contains(Atom v) { return top().containsAll(((CharAtom)v).top()); } + public boolean disjoint(Topology> t) { return top().disjoint(((CharAtom)t).top()); } + public boolean containsAll(Topology> t) { return top().containsAll(((CharAtom)t).top()); } + + public Topology> complement() { return new CharAtom(top().complement()); } + public Topology> intersect(Topology> t) { return new CharAtom(top().intersect(((CharAtom)t).top())); } + public Topology> minus(Topology> t) { return new CharAtom(top().minus(((CharAtom)t).top())); } + public Topology> union(Topology> t) { return new CharAtom(top().union(((CharAtom)t).top())); } + + public int hashCode() { return top().hashCode(); } + public boolean equals(Object o) { return o != null && (o instanceof CharAtom) && ((CharAtom)o).top().equals(top()); } + }