/** the imaginary position before or after an element of a sequence; corresponds to an "LR item" */
public class Position {
+ private Forest zero = null;
+ public Forest zero() {
+ if (zero != null) return zero;
+ if (pos > 0) throw new Error();
+ return zero = rewrite(null);
+ }
+
+
final int pos;
private final Position next;
final Forest[] holder;
/** true iff this Position is the last one in the sequence */
public boolean isLast() { return next()==null; }
- // Reduction /////////////////////////////////////////////////////////////////////////////////
+ // Position /////////////////////////////////////////////////////////////////////////////////
final <T> Forest<T> rewrite(Token.Location loc) {
if (this==firstp()) return epsilonForm();