added code to check for created-by-empty-reduction
authoradam <adam@megacz.com>
Fri, 6 Jan 2006 05:23:06 +0000 (00:23 -0500)
committeradam <adam@megacz.com>
Fri, 6 Jan 2006 05:23:06 +0000 (00:23 -0500)
darcs-hash:20060106052306-5007d-023ea006cf8a3cd5c1b3ad6f7d1b58761d4fbf35.gz

TODO
src/edu/berkeley/sbp/GSS.java

diff --git a/TODO b/TODO
index 31d33a0..fd55d0b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,24 +9,19 @@ Immediately
      - hash Long->long: it's all bogus
 
   * pick back up cleaning up end of Parser.java (Reduction)
-  * some weird edge cases; check last regression test, 'make doc'
 
+  - [more] sensible tree-printout
 
-  - Sensible tree-printout
-  - make Tib.Block extend Tree<>
+  - revamp Tib.Block (do it all in the parser using indent/dedent?)
 
   - more natural phrasing of metagrammar?
-
   - finalize metagrammar and rdp-op's
 
-  - Deal with the problem of zero-rep productions and whitespace insertion
-
   - should Union.add() be there?
   - should Atom.top() be there?
 
-  - fix the location stuff, it's broken
   - decent/better error messages
-      - substring parsing required
+      - fix the location stuff, it's broken
 
   - write some grammars
       - Java grammar
@@ -34,11 +29,12 @@ Immediately
       - URL (RFC)
       - RFC2822 (email message/headers)
 
-  - PL-PATR?
 
 ______________________________________________________________________________
 Soon
 
+  - substring parsing for better error messages
+
   - clean up the whole Walk situation
 
   - "lift" cases:
@@ -60,6 +56,8 @@ Soon
 ______________________________________________________________________________
 Later
 
+  - Partly-Linear-PATR? (O(n^6) unification grammar)
+
   - Implement a k-token peek buffer (for each state, see if it "dead
     ends" during the next k Phases based solely on state -- ignoring
     result SPPF)
index 74cbb48..65c12e7 100644 (file)
@@ -5,21 +5,6 @@ import java.io.*;
 import java.util.*;
 import java.lang.reflect.*;
 
-//////////////////////////////////////////////////////////////////////////////
-// TODO:
-//
-//  - fix public/package/private status
-//
-
-//////////////////////////////////////////////////////////////////////////////
-// Optimizations to add
-//
-// ** NOTE: not all of these are appropriate for this class -- it is
-//          simply a list of optimizations not implemented.  This
-//          class is meant to remain simple and easy to understand;
-//          optimizations which obscure that do not belong here (they
-//          should go into the compiled version instead)
-
 /** implements Tomita's Graph Structured Stack */
 class GSS {
 
@@ -81,6 +66,8 @@ class GSS {
         private void newNode2(Node p, Node parent, Forest pending, Parser.Table.State state, boolean fromEmptyReduction) {
             p.holder.merge(pending);
             if (p.parents().contains(parent)) return;
+            if (p.fe && p.phase() != parent.phase()) throw new Error("yep yep");
+            if (!p.fe && p.phase() == parent.phase()) throw new Error("yep yep2");
             p.parents().add(parent, true);
             if (p!=parent && !fromEmptyReduction) p.queueReductions(parent);
         }
@@ -96,7 +83,7 @@ class GSS {
                 //return;
             } while(false);
 
-            Node n = new Node(parent, pending, state);  // ALLOC
+            Node n = new Node(parent, pending, state, fromEmptyReduction);  // ALLOC
             n.queueEmptyReductions();
             if (!fromEmptyReduction) n.queueReductions(parent);
         }
@@ -123,7 +110,7 @@ class GSS {
         }
 
         public void invoke(Parser.Table.State st, Forest result, Node n) {
-            next.newNode(n, result, st, true);
+            next.newNode(n, result, st, false);
         }
         private Phase next = null;
 
@@ -197,6 +184,7 @@ class GSS {
             public  FastSet<Node> parents() { return this; }
 
             public void queueReductions() {
+                if (!reducing) return;
                 if (allqueued) return;
                 allqueued = true;
                 int where = parents().size();
@@ -222,7 +210,9 @@ class GSS {
                 state.invokeReductions(token, this, null, null);
             }
 
-            private Node(Node parent, Forest pending, Parser.Table.State state) {
+            private boolean fe;
+            private Node(Node parent, Forest pending, Parser.Table.State state, boolean fe) {
+                this.fe = fe;
                 this.state = state;
                 Phase start = parent==null ? null : parent.phase();
                 if (pending != null) this.holder().merge(pending);