1 package edu.berkeley.sbp.misc;
4 import java.lang.reflect.*;
5 import java.lang.ref.*;
6 import edu.berkeley.sbp.*;
7 import edu.berkeley.sbp.Token.Location;
8 import edu.berkeley.sbp.util.*;
10 /** an implementation of Token for streams of Java <tt>char</tt> values */
11 public class CharToken implements IntegerMappable {
13 public static final Atom leftBrace = new CharRange(new IntegerTopology<CharToken>(null, 9998)) { public String toString() { return "{"; } };
14 public static final Atom rightBrace = new CharRange(new IntegerTopology<CharToken>(null, 9999)) { public String toString() { return "}"; } };
15 public static final CharToken left = new CharToken((char)9998);
16 public static final CharToken right = new CharToken((char)9999);
18 // Private //////////////////////////////////////////////////////////////////////////////
21 public CharToken(char c) { this.c = c; }
22 public String result() { return c+""; }
23 public String toString() { return "\'"+StringUtil.escapify(c+"")+"\'"; }
25 //////////////////////////////////////////////////////////////////////////////////////////
27 public int toInt() { return (int)c; }