}
public PreSequence _slash_(PreSequence p, Object sep) { return p.sparse(sep); }
- public Object _star_(Element r) { return Repeat.many0(r); }
- public Object _plus_(final Element r) { return Repeat.many1(r); }
- 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 Object walk(Tree<String> tree) {
String head = tree.head();
if (tree.numChildren()==0) return super.walk(tree);
if ("\\n".equals(head)) return new Character('\n');
else if ("\\r".equals(head)) return new Character('\r');
else if ("grammar".equals(head)) { for(Tree<String> t : tree.children()) walk(t); return this; }
+ else if ("*".equals(head)) return Repeat.many0((Element)walk(tree.child(0)));
+ else if ("+".equals(head)) return Repeat.many1((Element)walk(tree.child(0)));
+ else if ("+/".equals(head)) return Repeat.many1((Element)walk(tree.child(0)), (Element)walk(tree.child(1)));
+ else if ("*/".equals(head)) return Repeat.many0((Element)walk(tree.child(0)), (Element)walk(tree.child(1)));
+ else if ("**".equals(head)) return Repeat.maximal(Repeat.many0((Element)walk(tree.child(0))));
+ else if ("++".equals(head)) return Repeat.maximal(Repeat.many1((Element)walk(tree.child(0))));
+ else if ("?".equals(head)) return Repeat.maybe((Element)walk(tree.child(0)));
else return super.walk(tree);
}
- public Object gram(Object o, Object g, Object o2) { return g; }
- public Element literal(String s) { Element ret = string(s); dropAll.add(ret); return ret; }
+ public Object gram(Object o, Object g, Object o2) { return g; }
+ public Element literal(String s) { Element ret = string(s); dropAll.add(ret); return ret; }
public Range _minus_(char a, char b) { return new Range(a, b); }
public Range range(char a) { return new Range(a, a); }
public Element _leftbracket_ (Range[] rr) { return ranges(true, rr); }