fix bug that caused hang when parsing comments in grammar files
[sbp.git] / src / edu / berkeley / sbp / meta / GrammarBuilder.java
index d9b04c2..5e1d3d9 100644 (file)
@@ -84,6 +84,7 @@ public class GrammarBuilder {
         if (head.equals("Elements")) return seq2((ElementNode[])Reflection.rebuild(walkChildren(t), ElementNode[].class));
         if (head.equals("NonTerminalReference")) return new ReferenceNode(stringifyChildren(t.child(0)));
         //if (head.equals(")")) return new ReferenceNode(stringifyChildren(t.child(0)));
+        if (head.equals("{")) return new XTree((Seq)walk(t.child(0)));
         if (head.equals("::")) return tag((String)walk(t.child(0)), (Seq)walk(t.child(1)));
         if (head.equals("++")) return plusmax((ElementNode)walk(t.child(0)));
         if (head.equals("+")) return plus((ElementNode)walk(t.child(0)));
@@ -99,7 +100,7 @@ public class GrammarBuilder {
         if (head.equals("Quoted")) return stringifyChildren(t);
         if (head.equals("Literal")) return new LiteralNode((String)walk(t.child(0)));
         if (head.equals("->")) return arrow((Seq)walk(t.child(0)), (ElementNode)walk(t.child(1)));
-        if (head.equals("DropNT")) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walk(t.child(1)), true, null, true);
+        if (head.equals("DropNT")) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walkChildren(t.child(1)), false, null, true);
         if (head.equals("=") && t.size()==2) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walk(t.child(1)), true, null, false);
         if (head.equals("=")) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walk(t.child(2)), true, (String)walk(t.child(1)), false);
         if (head.equals("&")) return and2((Seq)walk(t.child(0)), (Seq)walk(t.child(1)));
@@ -501,9 +502,9 @@ public class GrammarBuilder {
 
     }
 
-    /*
-    public            class XTree                 extends ElementNode {
-        public  Seq body;
+    public class XTree extends ElementNode {
+        public Seq body;
+        public XTree(Seq seq) { this.body = seq; }
         public Element build(Context cx, NonTerminalNode cnt, boolean dropall) {
             Union u = new Union(null, false);
             Sequence s = body.build(cx, u, null, dropall);
@@ -518,5 +519,4 @@ public class GrammarBuilder {
             return u2;
         }
     }
-    */
 }