From: adam Date: Fri, 20 Apr 2007 03:25:12 +0000 (-0400) Subject: support for left recursion in Repeat.java X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=dd88c14e959ecbd46bc4437102f27031bc33055a support for left recursion in Repeat.java darcs-hash:20070420032512-5007d-e84093647c01a5e74d615db5fcd520ed2db1e946.gz --- diff --git a/src/edu/berkeley/sbp/meta/Repeat.java b/src/edu/berkeley/sbp/meta/Repeat.java index 25581b2..a8739d9 100644 --- a/src/edu/berkeley/sbp/meta/Repeat.java +++ b/src/edu/berkeley/sbp/meta/Repeat.java @@ -28,6 +28,11 @@ public class Repeat extends Union { ? "" : ("/"+separator)), true); + if (follow != null) { + Sequence s = Sequence.create(new Repeat(e, zeroOkay, manyOkay, separator, maximal, tag, null)).followedBy(follow); + add(s); + return; + } if (zeroOkay && !manyOkay) { // FIXME add(Sequence.create(tag, new Element[] { }, null, false).followedBy(follow)); @@ -39,10 +44,26 @@ public class Repeat extends Union { add(Sequence.create(many1(e, separator, tag)).followedBy(follow)); } else { add(Sequence.create(tag, new Element[] { e }, null, false).followedBy(follow)); + /* if (separator==null) add(Sequence.create(tag, new Element[] { e, Repeat.this }, new boolean[] { false, false }, true).followedBy(follow)); else add(Sequence.create(tag, new Element[] { e, separator, Repeat.this }, new boolean[] { false, true, false }, true).followedBy(follow)); + */ + if (separator==null) + /* + add(Sequence.create(tag, new Element[] { e, Repeat.this }, new boolean[] { false, false }, true).followedBy(follow)); + */ + add(Sequence.createLeft(tag, new Element[] { Repeat.this, e }, + new boolean[] { false, false }, true)); + else { + /* + add(Sequence.create(tag, new Element[] { e, separator, Repeat.this }, new boolean[] { false, true, false }, true).followedBy(follow)); + */ + add(Sequence.createLeft(tag, new Element[] { Repeat.this, separator, e }, + new boolean[] { false, true, false }, true)); + } + } }