checkpoint harmony
authoradam <adam@megacz.com>
Wed, 11 Jan 2006 07:48:02 +0000 (02:48 -0500)
committeradam <adam@megacz.com>
Wed, 11 Jan 2006 07:48:02 +0000 (02:48 -0500)
darcs-hash:20060111074802-5007d-8d18df8a7b99acfa3017c1a4d59243b55443100c.gz

src/edu/berkeley/sbp/Parser.java
src/edu/berkeley/sbp/misc/CharToken.java

index 0d04f3f..d04c49f 100644 (file)
@@ -11,15 +11,12 @@ public abstract class Parser<T extends Token, R> {
     private final Table pt;
 
     /** create a parser to parse the grammar with start symbol <tt>u</tt> */
-    protected Parser(Union u)  { this.pt = new Table(u, top()); }
-    protected Parser(Table pt) { this.pt = pt; }
+    protected Parser(Union u, Topology<T> top)  { this.pt = new Table(u, top); }
+    protected Parser(Table pt)                  { this.pt = pt; }
 
     /** implement this method to create the output forest corresponding to a lone shifted input token */
     public abstract Forest<R> shiftedToken(T t, Token.Location loc);
 
-    /** this method must return an empty topology of the input token type */
-    public abstract Topology<T> top();
-
     /** parse <tt>input</tt>, using the table <tt>pt</tt> to drive the parser */
     public Forest<R> parse(Token.Stream<T> input) throws IOException, ParseFailed {
         GSS gss = new GSS();
@@ -244,11 +241,8 @@ public abstract class Parser<T extends Token, R> {
         }
     }
 
-    private static final Forest[] emptyForestArray = new Forest[0];
-
-
     // Helpers //////////////////////////////////////////////////////////////////////////////
-
+    
     private static void reachable(Element e, HashSet<Position> h) {
         if (e instanceof Atom) return;
         for(Sequence s : ((Union)e))
index 0793d80..87be340 100644 (file)
@@ -14,8 +14,7 @@ public class CharToken implements Token, IntegerMappable {
     // Public //////////////////////////////////////////////////////////////////////////////
 
     public static class CharToStringParser extends Parser<CharToken,String> {
-        public CharToStringParser(Union u) { super(u); }
-        public Topology<CharToken> top() { return new IntegerTopology<CharToken>(); }
+        public CharToStringParser(Union u) { super(u, new IntegerTopology<CharToken>()); }
         public Forest<String> shiftedToken(CharToken ct, Token.Location loc) {
             return Forest.create(loc, ct.result(), null, false, false);
         }