X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FCharToken.java;h=02c67e90dfe5efc3200ef540a03cc78d42067add;hp=eccac6a2949ce1ee58b84081eb9da62d0846df94;hb=574d2f85990e11f0a45e9028fbadf08aaedfd93a;hpb=2724e3d1df836f6ce40bc4227f1509e777de2e48 diff --git a/src/edu/berkeley/sbp/misc/CharToken.java b/src/edu/berkeley/sbp/misc/CharToken.java index eccac6a..02c67e9 100644 --- a/src/edu/berkeley/sbp/misc/CharToken.java +++ b/src/edu/berkeley/sbp/misc/CharToken.java @@ -50,8 +50,10 @@ public class CharToken implements Token, IntegerTopology.IntegerMappable { return new CharRange(new IntegerTopology(new Range.Set(new Range((int)start, (int)end)).complement().intersect(all))); } - public static final Atom leftBrace = new Atom(new IntegerTopology(-3)) { public String toString() { return "{"; } }; - public static final Atom rightBrace = new Atom(new IntegerTopology(-4)) { public String toString() { return "}"; } }; + public static CharToken left(int row, int col) { return new CharToken((char)9998, 0, 0) { public String toString() { return "{"; } }; } + public static CharToken right(int row, int col) { return new CharToken((char)9999, 0, 0) { public String toString() { return "}"; } }; } + public static final Atom leftBrace = new Atom(new IntegerTopology(9998)) { public String toString() { return "{"; } }; + public static final Atom rightBrace = new Atom(new IntegerTopology(9999)) { public String toString() { return "}"; } }; private static final Range.Set all = new Range.Set(new Range(0, Character.MAX_VALUE)); public static final Atom any = new CharRange(new IntegerTopology(all)); @@ -61,7 +63,7 @@ public class CharToken implements Token, IntegerTopology.IntegerMappable { /** returns an element which exactly matches the string given */ public static Element string(String s) { - if (s.length() == 0) return MetaGrammar.epsilon; + if (s.length() == 0) return Union.epsilon; final String escapified = "\""+StringUtil.escapify(s, "\"\r\n\\")+"\""; Element ret; if (s.length() == 1) { @@ -89,7 +91,7 @@ public class CharToken implements Token, IntegerTopology.IntegerMappable { public final char c; public final Location location; - private CharToken(char c, int line, int col) { this(c, new CartesianLocation(line, col)); } + public CharToken(char c, int line, int col) { this(c, new CartesianLocation(line, col)); } private CharToken(char c, Location loc) { this.c = c; this.location = loc; } public String result() { return c+""; } public Location getLocation() { return location; }