X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fchr%2FCharParser.java;h=b5e6dfcda264b6a68f91fdaa15db9d5cf68cbdfd;hb=61539aaf02d0537fd1df08b5d5bd03189992cf1e;hp=8630161d8feefb81f4cb56bfb004174c6f9fb48b;hpb=5ea3b9182192a0fbb7a0bd86b919384ddaeff29a;p=sbp.git diff --git a/src/edu/berkeley/sbp/chr/CharParser.java b/src/edu/berkeley/sbp/chr/CharParser.java index 8630161..b5e6dfc 100644 --- a/src/edu/berkeley/sbp/chr/CharParser.java +++ b/src/edu/berkeley/sbp/chr/CharParser.java @@ -1,3 +1,5 @@ +// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license + package edu.berkeley.sbp.chr; import java.io.*; import java.util.*; @@ -12,11 +14,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; } }