X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmeta%2FMetaGrammarBindings.java;h=b0b86da4b86b33be7aaaeed99290b0d3029eada2;hb=fb8694140dd9736855795e64a9bd4c3d50f7f2ea;hp=3c0575158586ab26060732ca533755240e1e56a4;hpb=e6be1f03f79b16cd410991d7e64cfa7beab6de59;p=sbp.git diff --git a/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java b/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java index 3c05751..b0b86da 100644 --- a/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java +++ b/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java @@ -1,3 +1,5 @@ +// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license + package edu.berkeley.sbp.meta; import edu.berkeley.sbp.util.*; import edu.berkeley.sbp.*; @@ -77,14 +79,13 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings { Seq[] group = sequences[i]; Union u2 = new Union(null, false); if (sequences.length==1) u2 = u; - for(int j=0; j bad2 = new HashSet(); Union urep = new Union(null, false); - urep.add(Sequence.empty()); + urep.add(Sequence.create()); if (sep != null) - urep.add(Sequence.singleton(new Element[] { cx.get(sep), u }, 1)); + urep.add(Sequence.create(new Element[] { cx.get(sep), u }, 1)); else - urep.add(Sequence.singleton(new Element[] { u }, 0)); + urep.add(Sequence.create(new Element[] { u }, 0)); for(int i=0; i, **, ++, or a similar character-class operator on a [potentially] multicharacter production"); return elements[0].toAtom(cx); } public Seq tag(String tag) { this.tag = prefix+tag; return this; } @@ -224,13 +226,11 @@ 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.not(dork); } + for(Seq s : not) { Sequence dork = s.build(cx, u, cnt); ret = ret.andnot(dork); } u.add(ret); return ret; } public Sequence build0(Context cx, NonTerminalNode cnt) { - boolean dropAll = false; - if (tag!=null && tag.endsWith("()")) dropAll = true; boolean[] drops = new boolean[elements.length]; Element[] els = new Element[elements.length]; for(int i=0; i)e.toAtom(cx).complement().minus(CharAtom.braces)); + return infer((Topology)e.toAtom(cx).complement()/*.minus(CharAtom.braces)*/); } public Element build(Context cx, NonTerminalNode cnt) { - return infer((Topology)e.toAtom(cx).complement().minus(CharAtom.braces)); + return infer((Topology)e.toAtom(cx).complement()/*.minus(CharAtom.braces)*/); } }; } public static @bind.as("Word") String word(String s) { return s; } public static @bind.as("Quoted") String quoted(String s) { return s; } - public static @bind.as("escaped") String c(char c) { return c+""; } + public static @bind.as("escaped") String c(char c) { + if (c=='{') return CharAtom.left+""; + if (c=='}') return CharAtom.right+""; + return c+""; + } public static @bind.as("EmptyString") String emptystring() { return ""; } public static @bind.as("\n") String retur() { return "\n"; } public static @bind.as("\r") String lf() { return "\r"; }