MAJOR: huge revamp of Sequence, Result, Reduction, Parser, Node, GSS
[sbp.git] / src / edu / berkeley / sbp / meta / MetaGrammarBindings.java
index b0b86da..927cd62 100644 (file)
@@ -225,9 +225,9 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
         }
         public Sequence build(Context cx, Union u, NonTerminalNode cnt) {
             Sequence ret = build0(cx, cnt);
-            for(Seq s : and) { Sequence dork = s.build(cx, u, cnt); ret = ret.and(dork); }
-            for(Seq s : not) { Sequence dork = s.build(cx, u, cnt); ret = ret.andnot(dork); }
-            u.add(ret);
+            for(Seq s : and) { Sequence dork = s.build(cx, null, cnt); ret = ret.and(dork); }
+            for(Seq s : not) { Sequence dork = s.build(cx, null, cnt); ret = ret.andnot(dork); }
+            if (u!=null) u.add(ret);
             return ret;
         }
         public Sequence build0(Context cx, NonTerminalNode cnt) {
@@ -266,10 +266,6 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
     public static @bind.as("Elements")  Seq  seq2(ElementNode[] elements)               { return new Seq(elements); }
     public static @bind.as        Seq  psx(Seq s)                        { return s; }
     public static @bind.as(":")   ElementNode   colon(String s, ElementNode e)             { return new Label(s, e); }
-    public static @bind.as("{") ElementNode   leftBrace() {
-        return new Drop(new CharClass(new Range[] { new Range(CharAtom.left, CharAtom.left) })); }
-    public static @bind.as("}") ElementNode   rightBrace() {
-        return new Drop(new CharClass(new Range[] { new Range(CharAtom.right, CharAtom.right) })); }
     public static @bind.as(")")   void close(String foo)                 { throw new Error("not supported"); }
     public static @bind.as("()")  ElementNode   epsilon()                         { return new Constant(epsilon); }
 
@@ -325,6 +321,11 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
         }
     }
 
+    public static @bind.as("\\{") ElementNode   leftBrace() {
+        return new Drop(new CharClass(new Range[] { new Range(CharAtom.left, CharAtom.left) })); }
+    public static @bind.as("\\}") ElementNode   rightBrace() {
+        return new Drop(new CharClass(new Range[] { new Range(CharAtom.right, CharAtom.right) })); }
+
     public static @bind.as("{")           class XTree                 extends ElementNode {
         public @bind.arg Seq body;
         public Element build(Context cx, NonTerminalNode cnt) {