checkpoint
[sbp.git] / src / edu / berkeley / sbp / chr / CharParser.java
1 package edu.berkeley.sbp.chr;
2 import java.io.*;
3 import java.util.*;
4 import java.lang.reflect.*;
5 import java.lang.ref.*;
6 import edu.berkeley.sbp.*;
7 import edu.berkeley.sbp.util.*;
8 import edu.berkeley.sbp.misc.*;
9 import edu.berkeley.sbp.Input.Location;
10
11 public class CharParser extends Parser<Character,String> {
12
13     public Forest<String> parse(InputStream is) throws IOException, ParseFailed { return super.parse(new CharInput(is)); }
14     public Forest<String> parse(Reader r)       throws IOException, ParseFailed { return super.parse(new CharInput(r)); }
15     public Forest<String> parse(String s)       throws IOException, ParseFailed { return parse(new StringReader(s)); }
16
17     public CharParser(Union u) { super(u, new CharTopology()); }
18
19     private Location oldloc;
20
21     public Forest<String> shiftToken(Character ct, Location newloc) {
22         if (oldloc==null) oldloc = newloc;
23         Forest<String> ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null);
24         oldloc = newloc;
25         return ret;
26     }
27
28 }