private final Table pt;
/** create a parser to parse the grammar with start symbol <tt>u</tt> */
- protected Parser(Union u) { this.pt = new Table(u, top()); }
- protected Parser(Table pt) { this.pt = pt; }
+ protected Parser(Union u, Topology<T> top) { this.pt = new Table(u, top); }
+ protected Parser(Table pt) { this.pt = pt; }
/** implement this method to create the output forest corresponding to a lone shifted input token */
public abstract Forest<R> shiftedToken(T t, Token.Location loc);
- /** this method must return an empty topology of the input token type */
- public abstract Topology<T> top();
-
/** parse <tt>input</tt>, using the table <tt>pt</tt> to drive the parser */
public Forest<R> parse(Token.Stream<T> input) throws IOException, ParseFailed {
GSS gss = new GSS();
}
}
- private static final Forest[] emptyForestArray = new Forest[0];
-
-
// Helpers //////////////////////////////////////////////////////////////////////////////
-
+
private static void reachable(Element e, HashSet<Position> h) {
if (e instanceof Atom) return;
for(Sequence s : ((Union)e))
// Public //////////////////////////////////////////////////////////////////////////////
public static class CharToStringParser extends Parser<CharToken,String> {
- public CharToStringParser(Union u) { super(u); }
- public Topology<CharToken> top() { return new IntegerTopology<CharToken>(); }
+ public CharToStringParser(Union u) { super(u, new IntegerTopology<CharToken>()); }
public Forest<String> shiftedToken(CharToken ct, Token.Location loc) {
return Forest.create(loc, ct.result(), null, false, false);
}