X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fchr%2FCharParser.java;h=c901388643a37eb8f2c11243381dd40717751fab;hp=8630161d8feefb81f4cb56bfb004174c6f9fb48b;hb=2c1c0293545f3d12c23220fd05c663e6aa3f3de1;hpb=5ea3b9182192a0fbb7a0bd86b919384ddaeff29a diff --git a/src/edu/berkeley/sbp/chr/CharParser.java b/src/edu/berkeley/sbp/chr/CharParser.java index 8630161..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); + 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; } }