X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fchr%2FCharParser.java;h=c901388643a37eb8f2c11243381dd40717751fab;hb=2c1c0293545f3d12c23220fd05c663e6aa3f3de1;hp=0a050118c407caf3a5e7fa44192cd0c9ac96b298;hpb=c8a17fdd2e149fe5feecd96c71b7f2cab286ab96;p=sbp.git diff --git a/src/edu/berkeley/sbp/chr/CharParser.java b/src/edu/berkeley/sbp/chr/CharParser.java index 0a05011..c901388 100644 --- a/src/edu/berkeley/sbp/chr/CharParser.java +++ b/src/edu/berkeley/sbp/chr/CharParser.java @@ -12,11 +12,17 @@ public class CharParser extends Parser { public Forest parse(InputStream is) throws IOException, ParseFailed { return super.parse(new CharInput(is)); } public Forest parse(Reader r) throws IOException, ParseFailed { return super.parse(new CharInput(r)); } + public Forest parse(String s) throws IOException, ParseFailed { return parse(new StringReader(s)); } public CharParser(Union u) { super(u, new CharTopology()); } - public Forest shiftToken(Location oldloc, Character ct, Location newloc) { - return Forest.create(new Input.Region(oldloc, newloc), ct.toString(), null, false, false, null); + private Location oldloc; + + public Forest shiftToken(Character ct, Location newloc) { + if (oldloc==null) oldloc = newloc; + Forest ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null); + oldloc = newloc; + return ret; } }