minor cleanups to CharInput
[sbp.git] / src / edu / berkeley / sbp / chr / CharAtom.java
index 1d76aa7..45c85b9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+
 package edu.berkeley.sbp.chr;
 import java.io.*;
 import java.util.*;
@@ -21,9 +23,9 @@ public class CharAtom extends Atom<Character> {
 
     public static final char left       = (char)9998;
     public static final char right      = (char)9999;
-    public static final Atom leftBrace  = new CharAtom(left,left)   { public String toString() { return "[{]"; } };
-    public static final Atom rightBrace = new CharAtom(right,right) { public String toString() { return "[}]"; } };
-    public static final Atom braces     = new CharAtom(left,right)   { public String toString() { return "[{}]"; } };
+    public static final Atom leftBrace  = new CharAtom(left,left)   { public String toString() { return "\\{"; } };
+    public static final Atom rightBrace = new CharAtom(right,right) { public String toString() { return "\\}"; } };
+    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(); }
@@ -31,7 +33,7 @@ public class CharAtom extends Atom<Character> {
     /** returns an element which exactly matches the string given */
     public static Element string(String s) { return string(s, true); }
     public static Element string(String s, boolean share) {
-        if (share && s.length() == 0) return epsilon;
+        if (share && s.length() == 0) return emptyString;
         final String escapified = "\""+StringUtil.escapify(s, "\"\r\n\\")+"\"";
         Element ret;
         if (share && s.length() == 1) {
@@ -49,8 +51,11 @@ public class CharAtom extends Atom<Character> {
         return ret;
     }
 
-    private static Union epsilon = new Union("()");
-    static { epsilon.add(Sequence.create()); }
+    private static Union emptyString = new Union("()");
+    static {
+        // FIXME: force this to be dropped wherever used!
+        emptyString.add(Sequence.create(new Element[0], ""));
+    }
 
     public Topology<Atom<Character>>       unwrap() { return this; }
     public Topology<Atom<Character>>       empty()  { return new CharAtom(); }