public String toString() { return t.toString(); }
/** returns an element which exactly matches the string given */
- public static Element string(String s) {
- if (s.length() == 0) return Union.epsilon;
+ public static Element string(String s) { return string(s, true); }
+ public static Element string(String s, boolean share) {
+ if (share && s.length() == 0) return Union.epsilon;
final String escapified = "\""+StringUtil.escapify(s, "\"\r\n\\")+"\"";
Element ret;
- if (s.length() == 1) {
+ if (share && s.length() == 1) {
ret =
new CharRange(s.charAt(0)) {
public String toString() { return escapified; } };
public String toString() { return escapified; } };
Element[] refs = new Element[s.length()];
for(int i=0; i<refs.length; i++) refs[i] = new CharRange(s.charAt(i));
- ret2.add(Sequence.constant(refs, s, null, null));
+ ret2.add(Sequence.constant(refs, s));
ret = ret2;
}
return ret;