1 // Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
3 package edu.berkeley.sbp.chr;
6 import java.lang.reflect.*;
7 import java.lang.ref.*;
8 import edu.berkeley.sbp.*;
9 import edu.berkeley.sbp.util.*;
10 import edu.berkeley.sbp.misc.*;
11 import edu.berkeley.sbp.Input.Location;
13 public class CharParser extends Parser<Character,String> {
15 public Forest<String> parse(InputStream is) throws IOException, ParseFailed { return super.parse(new CharInput(is)); }
16 public Forest<String> parse(Reader r) throws IOException, ParseFailed { return super.parse(new CharInput(r)); }
17 public Forest<String> parse(String s) throws IOException, ParseFailed { return parse(new StringReader(s)); }
19 public CharParser(Union u) { super(u, new CharTopology()); }
21 private Location oldloc;
23 public Forest<String> shiftToken(Character ct, Location newloc) {
24 if (oldloc==null) oldloc = newloc;
25 Forest<String> ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null);