X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmeta%2FMetaGrammarBindings.java;fp=src%2Fedu%2Fberkeley%2Fsbp%2Fmeta%2FMetaGrammarBindings.java;h=c51f71f137c316f11dfa53fa3c5001757839df74;hp=cae45c0c75485ab94ba5e3fbf8bc634330200933;hb=972303162555284f8066047d3caead8df139afd4;hpb=c042bb0dcce5d64f09b2788b2dfb722145162d2b diff --git a/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java b/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java index cae45c0..c51f71f 100644 --- a/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java +++ b/src/edu/berkeley/sbp/meta/MetaGrammarBindings.java @@ -266,6 +266,10 @@ 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); } @@ -389,15 +393,19 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings { public static @bind.as("~") ElementNode tilde(final ElementNode e) { return new ElementNodeWrapper(e) { public Atom toAtom(Context cx) { - return infer((Topology)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"; }