X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=b33279352a9a6b61c4cfd4bfa3e29629c3670e6f;hp=fcff530b8db6eaff5009d3943797c80d29d031d2;hb=888e9ccbab5f458a727c16da9d9291fd8951d909;hpb=0a0227b9180534d2a431f3d6e08a398bde2244c4 diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index fcff530..b332793 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -35,6 +35,14 @@ public abstract class Sequence extends Element implements Iterable { //////////////////////////////////////////////////////////////////////////////// + public Element noFollow = null; + public final Topology noFollow() { return noFollow==null ? null : noFollow.toAtom(); } + + Topology toAtom() { + if (elements.length!=1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this); + return elements[0].toAtom(); + } + protected final Element[] elements; final HashSet needs; @@ -54,8 +62,6 @@ public abstract class Sequence extends Element implements Iterable { this.firstp = new Position(0); } - void reachable(HashSet h) { firstp().reachable(h); } - Forest epsilonForm() { return firstp().rewrite(null); } protected abstract Forest postReduce(Token.Location loc, Forest[] args); @@ -66,12 +72,6 @@ public abstract class Sequence extends Element implements Iterable { /** the imaginary position before or after an element of a sequence; corresponds to an "LR item" */ public class Position { - void reachable(HashSet h) { - if (h.contains(this)) return; - h.add(this); - if (element() != null) element().reachable(h); - } - final int pos; private final Position next; final Forest[] holder;