add Serializable to util classes
[sbp.git] / src / edu / berkeley / sbp / Parser.java
index 0b2229d..8af8005 100644 (file)
@@ -6,10 +6,6 @@ import edu.berkeley.sbp.Sequence.Position;
 import java.io.*;
 import java.util.*;
 
-// FEATURE: try harder to "fuse" states together along two dimensions:
-//   - identical (equivalent) states, or states that subsume each other
-//   - unnecessary intermediate states ("short cut" GLR)
-
 /** a parser which translates an Input<Token> into a Forest<NodeType> */
 public abstract class Parser<Token, NodeType> {
 
@@ -70,10 +66,10 @@ public abstract class Parser<Token, NodeType> {
         _last = c;
         switch(c) {
             case edu.berkeley.sbp.chr.CharAtom.left:
-                buf += "\033[31m{\033[0m";
+                buf += "\033[31m>\033[0m";
                 break;
             case edu.berkeley.sbp.chr.CharAtom.right:
-                buf += "\033[31m}\033[0m";
+                buf += "\033[31m<\033[0m";
                 break;
             case -1: // FIXME 
             case '\n':
@@ -110,7 +106,7 @@ public abstract class Parser<Token, NodeType> {
     // Table //////////////////////////////////////////////////////////////////////////////
 
     /** an SLR(1) parse table which may contain conflicts */
-    class Table extends Grammar<Token> {
+    class Table extends Grammar<Token> implements Serializable {
 
         /** the start state */
         final State<Token>   start;
@@ -122,13 +118,13 @@ public abstract class Parser<Token, NodeType> {
         private int master_state_idx = 0;
 
         /** all the states for this table */
-        HashSet<State<Token>>                     all_states       = new HashSet<State<Token>>();
+        private transient HashSet<State<Token>>                     all_states       = new HashSet<State<Token>>();
 
         /** all the doomed states in this table */
-        HashMap<HashSet<Position>,State<Token>>   doomed_states    = new HashMap<HashSet<Position>,State<Token>>();
+        private transient HashMap<HashSet<Position>,State<Token>>   doomed_states    = new HashMap<HashSet<Position>,State<Token>>();
 
         /** all the non-doomed states in this table */
-        HashMap<HashSet<Position>,State<Token>>   normal_states    = new HashMap<HashSet<Position>,State<Token>>();
+        private transient HashMap<HashSet<Position>,State<Token>>   normal_states    = new HashMap<HashSet<Position>,State<Token>>();
 
         Topology<Token> emptyTopology() { return Parser.this.emptyTopology(); }
     
@@ -267,10 +263,10 @@ public abstract class Parser<Token, NodeType> {
          *  space+time complexity in otherwise simple grammars.  There
          *  is an example of this in the regression suite.
          */
-        class State<Token> implements IntegerMappable, Iterable<Position> {
+        class State<Token> implements IntegerMappable, Serializable {
         
             public  final     int               idx    = master_state_idx++;
-            private final     HashSet<Position> hs;
+            private final  transient   HashSet<Position> hs;
             public HashSet<State<Token>> conjunctStates = new HashSet<State<Token>>();
 
             HashMap<Sequence,State<Token>>      gotoSetNonTerminals = new HashMap<Sequence,State<Token>>();