// MetaGrammar //////////////////////////////////////////////////////////////////////////////
- public Object _star_(Element r) { return new Rep(r, null, false, true); }
+ public PreSequence _equals__greater_(Object[] o, String s) { return new PreSequence(o, s); }
+ public Object _star_(Element r) { return Repeat.many0(r); }
public Element epsilon(Object o, Object b) { return epsilon; }
public Element _rightparen_(Object e) { return SELF; }
public Object _backslash__leftbrace_(String s) { return SELF; }
public Object _leftbrace_(String s) { return SELF; }
- public Object _plus_(final Element r) { return new Rep(r, null, false, false); }
+ public Object _plus_(final Element r) { return Repeat.many1(r); }
public Object[] _slash_(Object[] o, Object sep) {
if (o.length <= 1) return o;
Object[] ret = new Object[o.length * 2 - 1];
}
return ret;
}
- public Object _plus__slash_(final Element r, Object s) { return new Rep(r, (Element)s, false, false); }
- public Object _star__slash_(final Element r, Object s) { return new Rep(r, (Element)s, false, true); }
- public Object _star__star_(final Element r) { return new Rep(r, null, true, true); }
- public Object _plus__plus_(final Element r) { return new Rep(r, null, true, false); }
+
+ public Object _plus__slash_(final Element r, Element s) { return Repeat.many1(r, s); }
+ public Object _star__slash_(final Element r, Element s) { return Repeat.many0(r, s); }
+ public Object _star__star_(final Element r) { return Repeat.maximal(Repeat.many0(r)); }
+ public Object _plus__plus_(final Element r) { return Repeat.maximal(Repeat.many1(r)); }
public Element _question_(final Element r) { return Repeat.maybe(r); }
public MetaGrammar gram(Object o, MetaGrammar g, Object o2) { return g; }
public MetaGrammar grammar(Object[] o) { return this; }
return ret;
}
- public String stringify(String s) { return StringUtil.unescapify(s); }
- public char unescape(char x, char c) { return unescape(c); }
- public char unescape(char c) { return StringUtil.unescapify("\\"+c).charAt(0); }
public PreSequence sequence(Object[] o) { return new PreSequence(o, null); }
- public PreSequence _equals__greater_(Object[] o, String s) { return new PreSequence(o, s); }
+
public PreSequence wrap(Object[] o) { return new PreSequence(o, ""); }
public PreSequence mwrap(Object[] o) { return new PreSequence(o, ""); }
public PreSequence rewrite(Object[] o) { return new PreSequence(o, null); }
o3[o3.length-1] = o2;
return rewrite(o3);
}
-
- public static class PreBrace {
- public final Object[] o;
- public PreBrace(Object[] o) { this.o = o; }
- }
-
- public static class Rep {
- private final Element e;
- private final Element s;
- private final boolean maximal;
- private final boolean zero;
- public Rep(Element e, Element s, boolean maximal, boolean zero) { this.e = e; this.s = s; this.zero = zero; this.maximal = maximal;}
- public Element build() {
- Element sep = s;
- Element ret = zero ? Repeat.many0(e, sep) : Repeat.many1(e, sep);
- return maximal ? Repeat.maximal(ret) : ret;
- }
- }
public static class PreSequence {
public PreSequence not(Sequence s) { not.add(s); return this; }
for(int i=0; i<o.length; i++) {
Object oi = o[i];
if (oi instanceof MyDrop) { oi = ((MyDrop)oi).o; drops[j] = true; }
- //if (oi instanceof PreSequence) o2[j] = ((PreSequence)oi).buildUnion();
- /*else*/ if (oi==SELF) o2[j] = u.new Subset("(("+u+"))", set);
- else if (oi instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = true; }
- else if (oi instanceof Rep) o2[j] = ((Rep)oi).build();
- else o2[j] = (Element)oi;
+ if (oi==SELF) o2[j] = u.new Subset("(("+u+"))", set);
+ else if (oi instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = true; }
+ else o2[j] = (Element)oi;
if (dropAll.contains(o2[j])) drops[j] = true;