From: adam Date: Fri, 20 Apr 2007 03:20:10 +0000 (-0400) Subject: better tracking of locations in GSS X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=c78e4efbba69fc058bbe487319b3abf5d94df3cb;ds=sidebyside better tracking of locations in GSS darcs-hash:20070420032010-5007d-0a6156137472587ef81326d97c66a8514d4e67d6.gz --- diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index 3c6beac..a726297 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -52,7 +52,6 @@ class GSS { private Phase prev; private Input.Location location; private Input.Location nextLocation; - private Input.Location prevLocation; private Forest forest; @@ -62,13 +61,12 @@ class GSS { newNode(primordealResult, startState, true); } public Phase(Phase prev, Forest forest) throws ParseFailed, IOException { - this.prevLocation = input.getLocation(); - this.token = (Tok)input.next(); this.location = input.getLocation(); + this.token = (Tok)input.next(); + this.nextLocation = input.getLocation(); this.prev = prev; this.forest = forest; this.pos = prev==null ? 0 : prev.pos+1; - this.nextLocation = input.getLocation(); if (prev != null) prev.shift(this, forest); numReductions = 0; @@ -112,9 +110,7 @@ class GSS { return true; } - public Input.Location getPrevLocation() { return prevLocation; } public Input.Location getLocation() { return location; } - public Input.Region getRegion() { return prevLocation.createRegion(location); } public Input.Location getNextLocation() { return nextLocation; } public boolean isFrontier() { return hash!=null; } @@ -126,8 +122,7 @@ class GSS { IntPairMap h = prev.hash; prev.hash = null; prev.performed = null; - for(Node n : h) - n.check(); + for(Node n : h) n.check(); } numOldNodes = hash.size(); for(Node n : hash.values()) { @@ -161,6 +156,10 @@ class GSS { for(Node n : hash) n.check(); } + Input.Region getRegionFromThisToNext() { + return getLocation().createRegion(getNextLocation()); + } + void newNodeFromReduction(Result result, State state, Position reduction) { int pos = result.phase().pos; Sequence owner = reduction.owner();