From: adam Date: Wed, 14 Dec 2005 06:59:15 +0000 (-0500) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~545 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=743c3e95b1e541982b104f690a3707e89fc10073 checkpoint darcs-hash:20051214065915-5007d-ed553d783df46529f12b7cd7384f15f78a1a608a.gz --- diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index d6e8a88..5ea2de3 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -78,10 +78,14 @@ public class MetaGrammar extends ReflectiveWalker { } return ret; } - public Object _plus__slash_(final Element r, Object s) { return rep(r, (Element)s, false, false); } - public Object _star__slash_(final Element r, Object s) { return rep(r, (Element)s, false, true); } - public Object _star__star_(final Element r) { return rep(r, null, true, true); } - public Object _plus__plus_(final Element r) { return rep(r, null, true, false); } + public Element rep(Element e, Element sep, boolean maximal, boolean zero) { + Element ret = zero ? Repeat.many0(e, sep) : Repeat.many1(e, sep); + return maximal ? Repeat.maximal(ret) : ret; + } + 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; } @@ -140,16 +144,6 @@ public class MetaGrammar extends ReflectiveWalker { o3[o3.length-1] = o2; return rewrite(o3); } - - public static class PreBrace { - public final Object[] o; - public PreBrace(Object[] o) { this.o = o; } - } - - public Element rep(Element e, Element sep, boolean maximal, boolean zero) { - 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; }