checkpoint
authoradam <adam@megacz.com>
Sun, 16 Jul 2006 07:53:41 +0000 (03:53 -0400)
committeradam <adam@megacz.com>
Sun, 16 Jul 2006 07:53:41 +0000 (03:53 -0400)
darcs-hash:20060716075341-5007d-f5dffd8569ffb25d2fdf4677916ddc8203a031f1.gz

TODO
src/edu/berkeley/sbp/Forest.java
src/edu/berkeley/sbp/GSS.java
src/edu/berkeley/sbp/Parser.java
src/edu/berkeley/sbp/Tree.java
src/edu/berkeley/sbp/Union.java

diff --git a/TODO b/TODO
index 7186baf..d58eb06 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,6 +2,8 @@ _____________________________________________________________________________
 Immediately
 
   - do Forest/Tree still need a Region?
+  - reconsider the degree of genericization
+  - GraphViz stuff pollutes the API...
   - Forest needs a "manual access" API
       - the unwrap bit in Forest makes it really hard to expose an API for forests
 
index 645850b..bd3b46a 100644 (file)
@@ -27,10 +27,9 @@ public abstract class Forest<T> implements GraphViz.ToGraphViz {
 
     abstract void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus);
     abstract void gather(HashSet<Forest<T>> ignore);
+    abstract void edges(GraphViz.Node n);
     boolean ambiguous() { return false; }
 
-    public abstract void edges(GraphViz.Node n);
-
 
     // One //////////////////////////////////////////////////////////////////////////////
 
index f85ec0b..9075f41 100644 (file)
@@ -8,17 +8,17 @@ import java.util.*;
 import java.lang.reflect.*;
 
 /** implements Tomita's Graph Structured Stack */
-public class GSS {
+class GSS {
 
-    public static int count = 0;
-    public static int shifts = 0;
-    public static int reductions = 0;
+    static int count = 0;
+    static int shifts = 0;
+    static int reductions = 0;
+    int resets = 0;
+    int waits = 0;
     
     public GSS() { }
 
     private Phase.Node[] reducing_list = null;
-    public int resets = 0;
-    public int waits = 0;
 
     // FIXME: right now, these are the performance bottleneck
     HashMapBag<Sequence,Phase.Waiting> waiting         = new HashMapBag<Sequence,Phase.Waiting>();
@@ -27,7 +27,7 @@ public class GSS {
     HashMapBag<Integer,Sequence>       expected        = new HashMapBag<Integer,Sequence>();
     
     /** FIXME */
-    public  Forest.Many finalResult;
+    Forest.Many finalResult;
 
     /** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
     class Phase<Tok> implements Invokable<State, Forest, Phase<Tok>.Node>, IntegerMappable, GraphViz.ToGraphViz, Iterable<Phase.Node> {
index 300ff27..744b7c0 100644 (file)
@@ -15,9 +15,9 @@ public abstract class Parser<Tok, Result> {
     protected Parser(Table<Tok> pt)               { this.pt = pt; }
 
     /** implement this method to create the output forest corresponding to a lone shifted input token */
-    public abstract Forest<Result> shiftToken(Input.Location oldloc, Tok t, Input.Location newloc);
+    protected abstract Forest<Result> shiftToken(Input.Location oldloc, Tok t, Input.Location newloc);
 
-    public boolean helpgc = true;
+    boolean helpgc = true;
 
     public String toString() { return pt.toString(); }
 
index 2f72029..2bfd187 100644 (file)
@@ -92,5 +92,4 @@ public class Tree<T>
     public boolean isTransparent() { return false; }
     public boolean isHidden() { return false; }
 
-   
 }
index 6cba89c..99ef42b 100644 (file)
@@ -10,6 +10,10 @@ import java.lang.ref.*;
 /** an element which can produce one of several alternatives */
 public class Union extends Element implements Iterable<Sequence> {
 
+    private final String name;
+    private final boolean synthetic;
+    private final List<Sequence> alternatives = new ArrayList<Sequence>();
+
     /**
      *  Since every cycle in a non-degenerate grammar contains at
      *  least one Union, every instance of this class must be able to
@@ -20,16 +24,12 @@ public class Union extends Element implements Iterable<Sequence> {
      *  @param synthetic if true, this Union's "long form" is "obvious" and should not be displayed when printing the grammar
      */
     public Union() { this(null, false); }
-    public Union(String shortForm) { this(shortForm, false); }
-    public Union(String shortForm, boolean synthetic) {
-        this.shortForm = shortForm;
+    public Union(String name) { this(name, false); }
+    public Union(String name, boolean synthetic) {
+        this.name = name;
         this.synthetic = synthetic;
     }
 
-    final String shortForm;
-    final boolean synthetic;
-    private final List<Sequence> alternatives = new ArrayList<Sequence>();
-
     public Iterator<Sequence> iterator() { return alternatives.iterator(); }
     public boolean contains(Sequence s) { return alternatives.contains(s); }
 
@@ -64,11 +64,11 @@ public class Union extends Element implements Iterable<Sequence> {
     // Display //////////////////////////////////////////////////////////////////////////////
 
     public String getName() {
-        if (shortForm != null) return shortForm;
+        if (name != null) return name;
         return "(anon_union)";
     }
     public String toString() {
-        if (shortForm != null) return shortForm;
+        if (name != null) return name;
         StringBuffer sb = new StringBuffer();
         sb.append("(");
         bodyToString(sb, "", " | ");