}
public static class Maximal extends Repeat {
- public Maximal(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, Object tag) {
+ public Maximal(final Element e, boolean zeroOkay, boolean manyOkay, final Atom separator, Object tag) {
super(e, zeroOkay, manyOkay, separator, true, tag);
if (zeroOkay && separator != null)
throw new RuntimeException("cannot create a maximal repetition of zero or more items with a separator (yet): " + this);
for(Sequence s : this)
- s.follow = new edu.berkeley.sbp.misc.MetaGrammar.Invert(new edu.berkeley.sbp.misc.MetaGrammar.Infer(separator));
+ s.follow = new edu.berkeley.sbp.misc.MetaGrammar.Invert(separator);
}
- public Maximal(final Element e, boolean zeroOkay, boolean manyOkay, Object tag) {
+ public Maximal(final Atom e, boolean zeroOkay, boolean manyOkay, Object tag) {
super(e, zeroOkay, manyOkay, null, true, tag);
for(Sequence s : this)
- s.follow = new edu.berkeley.sbp.misc.MetaGrammar.Invert(new edu.berkeley.sbp.misc.MetaGrammar.Infer(e));
+ s.follow = new edu.berkeley.sbp.misc.MetaGrammar.Invert(e);
}
}
public static Repeat many1(Element e, Element sep, Object tag) { return new Repeat(e, false, true, sep, tag); }
/** repeat zero or more times, matching a maximal sequence of atoms */
- public static Repeat maximal0(Element e) { return new Repeat.Maximal(e, true, true, null); }
- public static Repeat maximal0(Element e, Object tag) { return new Repeat.Maximal(e, true, true, tag); }
+ public static Repeat maximal0(Atom e) { return new Repeat.Maximal(e, true, true, null); }
+ public static Repeat maximal0(Atom e, Object tag) { return new Repeat.Maximal(e, true, true, tag); }
/** repeat one or more times, matching a maximal sequence of atoms */
- public static Repeat maximal1(Element e) { return new Repeat.Maximal(e, false, true, null); }
- public static Repeat maximal1(Element e, Object tag) { return new Repeat.Maximal(e, false, true, tag); }
+ public static Repeat maximal1(Atom e) { return new Repeat.Maximal(e, false, true, null); }
+ public static Repeat maximal1(Atom e, Object tag) { return new Repeat.Maximal(e, false, true, tag); }
/** repeat one or more times, separated by an atom <tt>sep</tt>, matching a maximal sequence */
- public static Repeat maximal1(Element e, Element sep) { return new Repeat.Maximal(e, false, true, sep, null); }
- public static Repeat maximal1(Element e, Element sep, Object tag) { return new Repeat.Maximal(e, false, true, sep, tag); }
+ public static Repeat maximal1(Element e, Atom sep) { return new Repeat.Maximal(e, false, true, sep, null); }
+ public static Repeat maximal1(Element e, Atom sep, Object tag) { return new Repeat.Maximal(e, false, true, sep, tag); }
}
public String toString() { return e.toString(); }
}
+ public static Atom infer(Element e) { return new CharRange((Topology<Character>)Atom.toAtom(e)); }
+
/** an atom which tracks the inverse of some other atom */
public static class Invert<T extends Input> extends Atom<T> {
private final Atom<T> a;
if (idx != -1) ret = Sequence.singleton(els, idx);
else ret = Sequence.drop(els, false);
}
- if (this.followedBy != null) ret.follow = new Hack(new Infer(this.followedBy.build(bc)));
+ if (this.followedBy != null) ret.follow = new Hack(infer(this.followedBy.build(bc)));
return ret;
}
private MetaConjunct(Tree<String> t) {
return !maximal
? new Repeat(element.build(bc), zero, many, separator==null?null:separator.build(bc), null)
: separator==null
- ? new Repeat.Maximal(element.build(bc), zero, many, null)
- : new Repeat.Maximal(element.build(bc), zero, many, separator.build(bc), null);
+ ? new Repeat.Maximal(infer(element.build(bc)), zero, many, null)
+ : new Repeat.Maximal(element.build(bc), zero, many, infer(separator.build(bc)), null);
}
public MetaRepeat(MetaClause element, boolean maximal, MetaClause separator, boolean zero, boolean many) {
this.separator = separator;
public MetaClause element;
public MetaInvert(Tree<String> t, MetaConjunct c) { this.element = make(t, c); }
public String toString() { return "~"+element; }
- public Element build(BuildContext bc) { return new Hack(new Invert(new Infer(element.build(bc)))); }
+ public Element build(BuildContext bc) { return new Hack(new Invert(infer(element.build(bc)))); }
}
}
+
+
+
// DO NOT EDIT STUFF BELOW: IT IS AUTOMATICALLY GENERATED
new edu.berkeley.sbp.Tree(null, "grammar", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "=", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "G", new edu.berkeley.sbp.Tree[] { }),
new edu.berkeley.sbp.Tree(null, "r", new edu.berkeley.sbp.Tree[] { }),
+
+
+