public Element _rightparen_(Object e) { return SELF; }
public Element _bang_(Element r) { return r; }
public Object _caret_(String s) { return new MyLift(s); }
- public Object _leftparen__rightparen_() { return epsilon; }
+ public Object _leftparen__rightparen_(Object o) { return epsilon; }
public Union nonTerminal(String s) { return nonTerminal(s, null, false, false); }
public Union _colon__colon__equals_(String s, PreSequence[][] p) { return nonTerminal(s, p, false, false); }
public Union _bang__colon__colon__equals_(String s, PreSequence[][] p) { return nonTerminal(s, p, false, true); }
}
public Object _backslash__leftbrace_(String s) { return SELF; }
- public Object _leftbrace_(String s) { return SELF; }
- public Object _plus_(final Element r) { return Repeat.many1(r); }
+ public Object _leftbrace_(PreSequence p) {
+ return nonTerminal("braced"+(anon++),
+ new PreSequence[][] {
+ new PreSequence[] {
+ new PreSequence(CharToken.leftBrace),
+ p,
+ new PreSequence(CharToken.rightBrace)
+ }
+ },
+ false,
+ false);
+ }
- public PreSequence rewrite(Object[] o) { return new PreSequence(o, null); }
- public PreSequence _equals__greater_(Object[] o, String s) { return new PreSequence(o, s); }
+ public Object _plus_(final Element r) { return Repeat.many1(r); }
+ public PreSequence rewrite(Object[] o) { return new PreSequence(o, null); }
+ public PreSequence _equals__greater_(Object[] o, String s) { return new PreSequence(o, s); }
public PreSequence seq(Object[] o, Object sep, String tag) { return new PreSequence(sep==null ? o : _slash_(o, sep), tag); }
- public Object[] seq(Object[] o) { return o; }
+ public Object[] seq(Object[] o) { return o; }
public Object[] _slash_(Object[] o, Object sep) {
if (o.length <= 1) return o;
Object[] ret = new Object[o.length * 2 - 1];
public /*final*/ String tag;
public final Object[] o;
+ public PreSequence(Object o) { this(new Object[] { o }, null); }
+ public PreSequence(Object[] o) { this(o, null); }
public PreSequence(Object[] o, String tag) { this.o = o; this.tag = tag; }
boolean[] drops = null;
public Union buildUnion() {
for(Sequence s : not) u.add(s);
HashSet<Sequence> set = new HashSet<Sequence>();
Element[] o2 = o==null ? new Element[0] : new Element[o.length];
+ int nonDrop = 0;
if (o != null) {
drops = new boolean[o.length];
int j = 0;
if (oi instanceof MyDrop) { oi = ((MyDrop)oi).o; drops[j] = true; }
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 MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = o.length>1; }
else o2[j] = (Element)oi;
if (MetaGrammar.dropAll.contains(o2[j])) drops[j] = true;
+ nonDrop += drops[j] ? 0 : 1;
o2[j] = o2[j];
j++;
}