checkpoint
[sbp.git] / src / edu / berkeley / sbp / meta / MetaGrammarBindings.java
index b381360..e3299cb 100644 (file)
@@ -116,7 +116,7 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
             this.name = prefix + name;
             this.sequences = sequences;
             this.rep = rep;
-            this.sep = prefix + sep;
+            this.sep = sep==null?null:(prefix + sep);
         }
         public Element build(Context cx, NonTerminalNode cnt) { return cx.get(name); }
         public void build(Context cx, Union u, NonTerminalNode cnt) {
@@ -125,7 +125,10 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
 
             Union urep = new Union();
             urep.add(Sequence.empty);
-            urep.add(Sequence.singleton(new Element[] { cx.get(sep), u }, 1));
+            if (sep != null)
+                urep.add(Sequence.singleton(new Element[] { cx.get(sep), u }, 1));
+            else
+                urep.add(Sequence.singleton(new Element[] { u }, 0));
 
             for(int i=0; i<sequences.length; i++) {
                 Seq[] group = sequences[i];
@@ -318,10 +321,10 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
             this.e = e; this.sep = sep; this.zero = zero; this.many = many; this.max = max;}
         public Element build(Context cx, NonTerminalNode cnt) {
             return (!max)
-                ? Sequence.repeat(e.build(cx, null),        zero, many, sep==null ? null : sep.build(cx, null), cx.rm.repeatTag())
+                ? Sequence.repeat(e.build(cx, null), zero, many, sep==null ? null : sep.build(cx, null), cx.rm.repeatTag())
                 : sep==null
-                ? Sequence.repeatMaximal(infer(e.build(cx, null)), zero, many,                                   cx.rm.repeatTag())
-                : Sequence.repeatMaximal(e.build(cx, null),                    zero, many, infer(sep.build(cx, null)), cx.rm.repeatTag());
+                ? Sequence.repeatMaximal(infer(e.build(cx, null)), zero, many, cx.rm.repeatTag())
+                : Sequence.repeatMaximal(e.build(cx, null), zero, many, infer(sep.build(cx, null)), cx.rm.repeatTag());
         }
     }
 
@@ -403,7 +406,6 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
             map.put(name, ret);
             NonTerminalNode nt = grammar.get(name);
             if (nt==null) {
-                //System.err.println("*** warning could not find " + name);
                 throw new Error("warning could not find " + name);
             } else {
                 String old = cnt;