+++ /dev/null
-package edu.berkeley.sbp.misc;
-import java.io.*;
-import java.util.*;
-import java.lang.reflect.*;
-import java.lang.ref.*;
-import edu.berkeley.sbp.*;
-import edu.berkeley.sbp.Input.Location;
-import edu.berkeley.sbp.util.*;
-
-/** an implementation of Input for streams of Java <tt>char</tt> values */
-public class StringInput {
-
- public static final StringInput left = new StringInput(null, null) { public boolean equals(Object o) { return this==o; } };
- public static final StringInput right = new StringInput(null, null) { public boolean equals(Object o) { return this==o; } };
-
- public static final Atom leftBrace = new StringAtom(new DiscreteTopology<StringInput>(left)) { public String toString() { return "{"; } };
- public static final Atom rightBrace = new StringAtom(new DiscreteTopology<StringInput>(right)) { public String toString() { return "}"; } };
-
- private static class StringAtom extends Atom {
- private String s;
- private Topology t;
- public StringAtom(String s) { this.t = new DiscreteTopology<StringInput>(new StringInput(s, null)); this.s = s; }
- public StringAtom(Topology<StringInput> t) { this.t = t; }
- public String toString() { return "[atom \""+s+"\"]"; }
- public Topology top() { return t; }
- }
-
- /** returns an element which exactly matches the string given */
- public static Element string(String s) {
- return new StringAtom(s);
- }
-
- public static Topology<StringInput> top() { return new DiscreteTopology<StringInput>(); }
-
- public final String s;
- public final Location location;
- private StringInput(String s, Location loc) { this.s = s; this.location = loc; }
- public String result() { return s; }
- public Location getLocation() { return location; }
- public String toString() { return "\'"+StringUtil.escapify(s)+"\'"; }
-
- public boolean equals(Object o) { return o!=null && o instanceof StringInput && s.equals(((StringInput)o).s); }
- public int hashCode() { return s==null ? 0 : s.hashCode(); }
-}