X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=300ff27fd31156ea7a4daf2f3914fe6a7fce15b2;hp=c5ebd7e3f976abe6aae942895e5bdefdb4ce57e8;hb=c8d1c3a25e2bfa9645c4b91d3dde9c4857f636f2;hpb=e5cfb136bf7fd1352eff1bd87a458aa4ff748537 diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index c5ebd7e..300ff27 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -15,7 +15,7 @@ public abstract class Parser { 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 shiftToken(Tok t, Input.Location loc); + public abstract Forest shiftToken(Input.Location oldloc, Tok t, Input.Location newloc); public boolean helpgc = true; @@ -26,12 +26,13 @@ public abstract class Parser { GSS gss = new GSS(); Input.Location loc = input.getLocation(); GSS.Phase current = gss.new Phase(null, this, null, input.next(), loc, null); - current.newNode(null, Forest.leaf(null, null, null), pt.start, true); + current.newNode(null, Forest.create(null, null, null, false), pt.start, true); int count = 1; for(int idx=0;;idx++) { + Input.Location oldloc = loc; loc = input.getLocation(); current.reduce(); - Forest forest = current.token==null ? null : shiftToken((Tok)current.token, loc); + Forest forest = current.token==null ? null : shiftToken(oldloc, (Tok)current.token, loc); GSS.Phase next = gss.new Phase(current, this, current, input.next(), loc, forest); if (!helpgc) { FileOutputStream fos = new FileOutputStream("out-"+idx+".dot");