- protected Parser(Union u) { this.pt = new Table(u, top()); }
- protected Parser(Table pt) { this.pt = pt; }
-
- public abstract Forest<R> shiftedToken(T t, Token.Location loc);
- public abstract Topology<T> top();
-
+ public Parser(Union u, Topology<Token> top) { this.pt = new Table<Token>(u, top); }
+ Parser(Table<Token> pt) { this.pt = pt; }
+
+ /** implement this method to create the output forest corresponding to a lone shifted input token */
+ public abstract Forest<NodeType> shiftToken(Token t, Input.Location newloc);
+
+ boolean helpgc = true;
+
+ public String toString() { return pt.toString(); }
+
+ /** parse <tt>input</tt>, and return the shared packed parse forest (or throw an exception) */
+ public Forest<NodeType> parse(Input<Token> input) throws IOException, ParseFailed {
+ GSS gss = new GSS(input);
+ Input.Location loc = input.getLocation();
+ Token tok = input.next();
+ GSS.Phase current = gss.new Phase<Token>(null, null, tok, loc, input.getLocation(), null);
+ current.newNode(new Result(Forest.create(loc.createRegion(loc), null, null, false), null, null), pt.start, true);
+ int count = 1;
+ for(int idx=0;;idx++) {
+ Input.Location oldloc = loc;
+ current.reduce();
+ Forest forest = current.token==null ? null : shiftToken((Token)current.token, loc);
+ loc = input.getLocation();
+ Token nextToken = input.next();
+ GSS.Phase next = gss.new Phase<Token>(current, current, nextToken, loc, input.getLocation(), forest);