X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=c41be4ff9d62da6ba0537477b13c3db22aaed42d;hp=968d78f555c968c85cba4e58192456ffb94d04cb;hb=2afdfe14e78fa0597186614937c679a09d74ecdf;hpb=c78e4efbba69fc058bbe487319b3abf5d94df3cb diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index 968d78f..c41be4f 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -54,6 +54,11 @@ public abstract class Sequence implements Iterable, SequenceOrElement { ? new Unwrap(e, head, drop) : new RewritingSequence(head, e, drop); } + public static Sequence createLeft(Object head, Element[] e, boolean[] drop, boolean foster) { + return foster + ? new UnwrapLeft(e, head, drop) + : new RewritingSequence(head, e, drop); + } /** return a new sequence identical to this one, but with a positive conjunct s */ public Sequence and(Sequence s) { @@ -256,6 +261,27 @@ public abstract class Sequence implements Iterable, SequenceOrElement { } } + static class UnwrapLeft extends Sequence { + private boolean[] drops; + private final Object tag; + public UnwrapLeft(Element[] e, Object tag) { this(e, tag, null); } + public UnwrapLeft(Element[] e, Object tag, boolean[] drops) { super(e); this.drops = drops; this.tag = tag; } + Sequence _clone() { return new UnwrapLeft(elements, tag, drops); } + public Forest postReduce(Input.Region loc, Forest[] args, Position p) { + for(int i=0; i[] args2 = new Forest[count]; + int j = 0; + for(int i=0; i