checkpoint
[sbp.git] / src / edu / berkeley / sbp / misc / MetaGrammar.java
index 687d2d8..71782dd 100644 (file)
@@ -55,7 +55,7 @@ public class MetaGrammar extends ReflectiveWalker {
     public Element     _rightparen_(Object e)                                         { return SELF; }
     public Element     _bang_(Element r)                                              { return r; }
     public Object      _caret_(String s)                                              { return new MyLift(s); }
-    public Object      _leftparen__rightparen_()                                      { return epsilon; }
+    public Object      _leftparen__rightparen_(Object o)                              { return epsilon; }
     public Union       nonTerminal(String s)                                          { return nonTerminal(s, null, false, false); }
     public Union       _colon__colon__equals_(String s, PreSequence[][] p)            { return nonTerminal(s, p, false, false); }
     public Union       _bang__colon__colon__equals_(String s, PreSequence[][] p)      { return nonTerminal(s, p, false, true); }
@@ -154,6 +154,7 @@ public class MetaGrammar extends ReflectiveWalker {
             for(Sequence s : not) u.add(s);
             HashSet<Sequence> set = new HashSet<Sequence>();
             Element[] o2 = o==null ? new Element[0] : new Element[o.length];
+            int nonDrop = 0;
             if (o != null) {
                 drops = new boolean[o.length];
                 int j = 0;
@@ -162,10 +163,11 @@ public class MetaGrammar extends ReflectiveWalker {
                     if (oi instanceof MyDrop)      { oi = ((MyDrop)oi).o; drops[j] = true; }
 
                     if (oi==SELF)                    o2[j] = u.new Subset("(("+u+"))", set);
-                    else if (oi instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = true; }
+                    else if (oi instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = o.length>1; }
                     else                             o2[j] = (Element)oi;
 
                     if (MetaGrammar.dropAll.contains(o2[j])) drops[j] = true;
+                    nonDrop += drops[j] ? 0 : 1;
                     o2[j] = o2[j];
                     j++;
                 }