projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
eliminated Token.Location.getContext()
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
Sequence.java
diff --git
a/src/edu/berkeley/sbp/Sequence.java
b/src/edu/berkeley/sbp/Sequence.java
index
a5149f2
..
b332793
100644
(file)
--- a/
src/edu/berkeley/sbp/Sequence.java
+++ b/
src/edu/berkeley/sbp/Sequence.java
@@
-35,11
+35,11
@@
public abstract class Sequence extends Element implements Iterable<Element> {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
- public Topology noFollow() { return null; }
+ public Element noFollow = null;
+ public final Topology noFollow() { return noFollow==null ? null : noFollow.toAtom(); }
Topology toAtom() {
Topology toAtom() {
- if (elements.length>1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this);
- if (elements.length==0) return null;
+ if (elements.length!=1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this);
return elements[0].toAtom();
}
return elements[0].toAtom();
}
@@
-62,8
+62,6
@@
public abstract class Sequence extends Element implements Iterable<Element> {
this.firstp = new Position(0);
}
this.firstp = new Position(0);
}
- void reachable(HashSet<Position> h) { firstp().reachable(h); }
-
Forest epsilonForm() { return firstp().rewrite(null); }
protected abstract <T> Forest<T> postReduce(Token.Location loc, Forest<T>[] args);
Forest epsilonForm() { return firstp().rewrite(null); }
protected abstract <T> Forest<T> postReduce(Token.Location loc, Forest<T>[] args);
@@
-74,12
+72,6
@@
public abstract class Sequence extends Element implements Iterable<Element> {
/** the imaginary position before or after an element of a sequence; corresponds to an "LR item" */
public class Position {
/** the imaginary position before or after an element of a sequence; corresponds to an "LR item" */
public class Position {
- void reachable(HashSet<Position> 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;
final int pos;
private final Position next;
final Forest[] holder;