checkpoint harmony
authoradam <adam@megacz.com>
Wed, 11 Jan 2006 01:46:10 +0000 (20:46 -0500)
committeradam <adam@megacz.com>
Wed, 11 Jan 2006 01:46:10 +0000 (20:46 -0500)
darcs-hash:20060111014610-5007d-ee248eecb15fa5a4f6b65ea93b71b81148752e42.gz

src/edu/berkeley/sbp/GSS.java
src/edu/berkeley/sbp/Parser.java
src/edu/berkeley/sbp/Union.java

index a8f8053..e4859d4 100644 (file)
@@ -132,7 +132,10 @@ class GSS {
             ret.append("\n  ");
             ret.append(message);
             HashMap<String,HashSet<String>> errors = new HashMap<String,HashSet<String>>();
             ret.append("\n  ");
             ret.append(message);
             HashMap<String,HashSet<String>> errors = new HashMap<String,HashSet<String>>();
-            for(Node n : hash.values()) complain(n, errors, false);
+            for(Node n : hash.values()) {
+                //System.out.println(n.state);
+                complain(n, errors, false);
+            }
             for(String s : errors.keySet()) {
                 ret.append("    while parsing " + yellow(s));
                 HashSet<String> hs = errors.get(s);
             for(String s : errors.keySet()) {
                 ret.append("    while parsing " + yellow(s));
                 HashSet<String> hs = errors.get(s);
@@ -294,7 +297,11 @@ class GSS {
         class Reset extends RuntimeException { }
 
         public void invoke(State st, Forest result, Node n) {
         class Reset extends RuntimeException { }
 
         public void invoke(State st, Forest result, Node n) {
-            good |= next.newNode(n, result, st, false);
+            boolean ok = next.newNode(n, result, st, false);
+            if (ok && !good) {
+                good = !st.lame();
+                //if (good) System.out.println(st);
+            }
         }
 
         /** perform all shift operations, adding promoted nodes to <tt>next</tt> */
         }
 
         /** perform all shift operations, adding promoted nodes to <tt>next</tt> */
index 95c3985..b16a33d 100644 (file)
@@ -162,10 +162,18 @@ public abstract class Parser<T extends Token, R> {
         }
 
         /** a single state in the LR table and the transitions possible from it */
         }
 
         /** a single state in the LR table and the transitions possible from it */
-        public class State implements Comparable<Table.State>, Iterable<Position>, IntegerMappable {
+
+        public class State implements Comparable<Table.State>, IntegerMappable, Iterable<Position> {
         
             public int toInt() { return idx; }
 
         
             public int toInt() { return idx; }
 
+            public boolean lame() {
+                for(Position p : this)
+                    for(Position p2 = p; p2!=null; p2=p2.next())
+                        if (p2.isLast() && !p2.owner().lame)
+                            return false;
+                return true;
+            }
             /*
             public boolean isResolvable(Token t) {
                 boolean found = false;
             /*
             public boolean isResolvable(Token t) {
                 boolean found = false;
@@ -313,7 +321,13 @@ public abstract class Parser<T extends Token, R> {
                 }
             }
 
                 }
             }
 
-            public String toString() { return "state["+idx+"]"; }
+            public String toString() {
+                //return "state["+idx+"]";
+                StringBuffer ret = new StringBuffer();
+                ret.append("state["+idx+"]: ");
+                for(Position p : this) ret.append("{"+p+"}  ");
+                return ret.toString();
+            }
 
             public int compareTo(Table.State s) { return idx==s.idx ? 0 : idx < s.idx ? -1 : 1; }
         }
 
             public int compareTo(Table.State s) { return idx==s.idx ? 0 : idx < s.idx ? -1 : 1; }
         }
index ea2e2db..b690450 100644 (file)
@@ -33,7 +33,7 @@ public class Union extends Element implements Iterable<Sequence> {
     public void add(Sequence s) {
         alternatives.add(s);
         if (/*!synthetic &&*/ shortForm!=null
     public void add(Sequence s) {
         alternatives.add(s);
         if (/*!synthetic &&*/ shortForm!=null
-            && Character.isUpperCase(shortForm.charAt(0))
+            //&& Character.isUpperCase(shortForm.charAt(0))
             )
             s.setName(toString());
     }
             )
             s.setName(toString());
     }