X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=e8e0dc8e641a5c5ffc52d30de57a8712c6dc3847;hp=a54fa08df2eb57ee147e1d210b402a8dae7957ea;hb=fd97655ce34c3aff1a47bfb2f45775ac711923b1;hpb=1a79f2232401c95fb0a6a0c2bddf78d4c82e612c diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index a54fa08..e8e0dc8 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -30,7 +30,7 @@ public abstract class Parser { protected Parser(Union u) { this.pt = new Table(u, top()); } protected Parser(Table pt) { this.pt = pt; } - public abstract Forest shiftedToken(T t); + public abstract Forest shiftedToken(T t, Token.Location loc); public abstract Topology top(); @@ -40,12 +40,14 @@ public abstract class Parser { /** parse input, using the table pt to drive the parser */ public Forest parse(Token.Stream input) throws IOException, Failed { GSS gss = new GSS(); - GSS.Phase current = gss.new Phase(null, input.next()); + Token.Location loc = input.getLocation(); + GSS.Phase current = gss.new Phase(null, input.next(), loc); current.newNode(null, null, pt.start, true, null); for(;;) { - GSS.Phase next = gss.new Phase(current, input.next()); + loc = input.getLocation(); + GSS.Phase next = gss.new Phase(current, input.next(), loc); current.reduce(); - Forest forest = current.token==null ? null : shiftedToken((T)current.token); + Forest forest = current.token==null ? null : shiftedToken((T)current.token, loc); current.shift(next, forest); if (current.isDone()) return (Forest)current.finalResult; current.checkFailure();