checkpoint
authoradam <adam@megacz.com>
Wed, 4 Jan 2006 10:41:31 +0000 (05:41 -0500)
committeradam <adam@megacz.com>
Wed, 4 Jan 2006 10:41:31 +0000 (05:41 -0500)
darcs-hash:20060104104131-5007d-62431bf08cdcc2722bc1b35a6ba974679fe23dce.gz

src/edu/berkeley/sbp/GSS.java
src/edu/berkeley/sbp/Parser.java
src/edu/berkeley/sbp/tib/TibDoc.java
tests/tibdoc.g

index 0d343a9..3c1b9da 100644 (file)
@@ -122,7 +122,6 @@ class GSS {
             for(int i=0; i<num; i++) {
                 Node n = reducing_list[i];
                 reducing_list[i] = null;
-                n.queueEmptyReductions();
                 n.queueReductions();
             }
         }
@@ -210,37 +209,17 @@ class GSS {
                 if (allqueued) return;
                 allqueued = true;
                 int where = parents().size();
-                for(Parser.Table.Reduction r : token==null ? state.getEofReductions() : state.getReductions(token))
+                for(Parser.Table.Reduction r : state.getReductions(token))
                     if (r.numPop >= 1)
                         r.reduce(this, null, null);
             }
 
             /** FIXME */
-            public void queueReductions(Node n2) { queueReductions(n2, true); }
-            public void queueReductions(Node n2, boolean includeLongs) {
+            public void queueReductions(Node n2) {
                 if (!allqueued) { queueReductions(); return; }
-                Node n = this;
-                for(Parser.Table.Reduction r : token==null ? n.state.getEofReductions() : n.state.getReductions(token)) {
-                    
-                    // UGLY HACK
-                    // The problem here is that a "reduction of length 1"
-                    // performed twice with different values of n2 needs
-                    // to only create a *single* new result, but must add
-                    // multiple parents to the node holding that result.
-                    // The current reducer doesn't differentiate between
-                    // the next node of an n-pop reduction and the
-                    // ultimate parent of the last pop, so we need to
-                    // cache instances here as a way of avoiding
-                    // recreating them.
-                    if (r.numPop <= 0) continue;
-                    if (r.numPop == 1) {
-                        Forest ret = n.cache().get(r);
-                        if (ret != null) r.reduce(this, n2, ret);
-                        else n.cache().put(r, r.reduce(this, n2, null));
-                    } else {
+                for(Parser.Table.Reduction r : state.getReductions(token))
+                    if (r.numPop > 0)
                         r.reduce(this, n2, null);
-                    }
-                }
             }
 
 
index dc6c1f6..90f86f2 100644 (file)
@@ -184,7 +184,7 @@ public abstract class Parser<T extends Token, R> {
             public boolean             canShift(Token t)           { return shifts.contains(t); }
             public Iterable<State>     getShifts(Token t)          { return shifts.get(t); }
             public boolean             isAccepting()               { return accept; }
-            public Iterable<Reduction> getReductions(Token t)      { return reductions.get(t); }
+            public Iterable<Reduction> getReductions(Token t)      { return t==null ? eofReductions : reductions.get(t); }
             public Iterable<Reduction> getEofReductions()          { return eofReductions; }
             public Iterator<Position>  iterator()                  { return hs.iterator(); }
 
index 347f59e..73dcc9d 100644 (file)
@@ -20,8 +20,9 @@ public class TibDoc {
         Union mg = gram.done();
         
         System.out.println("\nparsing " + s[1]);
-        res = new CharToken.CharToStringParser(mg).parse1(new Tib(new FileInputStream(s[1])));
-        System.out.println(((Tree)walk(res)).toString(0, 0, 120));
+        Forest f = new CharToken.CharToStringParser(mg).parse(new Tib(new FileInputStream(s[1])));
+        System.out.println(f);
+        System.out.println(((Tree)walk(f.expand1())).toString(0, 0, 120));
     }
 
     public static Tree<String> walk(Tree<String> tree) {
index 9cff556..5926194 100644 (file)
@@ -1,3 +1,4 @@
+x::="x"
 // indentation styling...
 // literal blocks [[need to ignore bracing]] double-colon style?
 // definition -- by prior line indentation, like headings in the original structured text
@@ -34,7 +35,7 @@ nw       ::= ~[\r\n\ ]
 
 //////////////////////////////////////////////////////////////////////////////
 
-s                 ::= {Doc} => top
+s                 ::= { Doc } => "top"
 
 Doc               ::= Header   Body                       /ws => doc
 Header            ::= "header" { kv */ ws }               /ws => header