From: adam Date: Fri, 14 Jul 2006 00:13:44 +0000 (-0400) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~153 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=d948b6363742aa34d9269cb4a49407e439ee896d checkpoint darcs-hash:20060714001344-5007d-1a5411e9ca6022f1d69cbb1858b6e7ae3128c5b6.gz --- diff --git a/src/edu/berkeley/sbp/meta/AnnotationGrammarBindingResolver.java b/src/edu/berkeley/sbp/meta/AnnotationGrammarBindingResolver.java index 8601ee7..8a469f6 100644 --- a/src/edu/berkeley/sbp/meta/AnnotationGrammarBindingResolver.java +++ b/src/edu/berkeley/sbp/meta/AnnotationGrammarBindingResolver.java @@ -50,7 +50,7 @@ public class AnnotationGrammarBindingResolver extends GrammarBindingResolver { String prefix = key.indexOf('.')==-1 ? "" : key.substring(0, key.lastIndexOf('.')); String suffix = key.indexOf('.')==-1 ? key : key.substring(key.lastIndexOf('.')+1); - MetaGrammar.Production p = new MetaGrammar.Production(suffix, suffix, els, drops); + MetaGrammar.Production p = new MetaGrammar.Production(suffix, els, drops); for(Method m : _allMethods.get(prefix)) if (new MetaGrammar.Target(m).isCompatible(p)) return new MetaGrammar.Target(m).makeSequence(p); @@ -67,7 +67,7 @@ public class AnnotationGrammarBindingResolver extends GrammarBindingResolver { } public Sequence resolveTag(String tag, String nonTerminalName, Element[] els, boolean[] drops) { - MetaGrammar.Production p = new MetaGrammar.Production(tag, nonTerminalName, els, drops); + MetaGrammar.Production p = new MetaGrammar.Production(tag==null ? nonTerminalName : tag, els, drops); Sequence ret = tryResolveTag(tag, nonTerminalName, els, drops); if (ret != null) return ret; String message = "could not find a Java method/class/ctor matching tag \""+tag+ diff --git a/src/edu/berkeley/sbp/meta/MetaGrammar.java b/src/edu/berkeley/sbp/meta/MetaGrammar.java index 78c4b72..a55481b 100644 --- a/src/edu/berkeley/sbp/meta/MetaGrammar.java +++ b/src/edu/berkeley/sbp/meta/MetaGrammar.java @@ -57,14 +57,12 @@ public class MetaGrammar { public static class Production { public String tag; - public String nonTerminal; public boolean[] drops; public Element[] elements; public int count = 0; - public Production(String tag, String nonTerminal, Element[] elements, boolean[] drops) { + public Production(String tag, Element[] elements, boolean[] drops) { this.tag = tag; this.elements = elements; - this.nonTerminal = nonTerminal; this.drops = drops; for(int i=0; i res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); - Union tibgram = MetaGrammar.make(res, "s", new AnnotationGrammarBindingResolver(TD.class)); + AnnotationGrammarBindingResolver resolver = new AnnotationGrammarBindingResolver(TD.class); + resolver.add(MetaGrammarBindings.class, "meta"); + Union tibgram = MetaGrammar.make(res, "s", resolver); System.err.println("parsing " + s[1]); Tree t = new CharParser(tibgram).parse(new Tib(new FileInputStream(s[1]))).expand1(); diff --git a/tests/tib.in b/tests/tib.in index 0ce866c..1e052f0 100644 --- a/tests/tib.in +++ b/tests/tib.in @@ -34,7 +34,6 @@ * these * that 1. them - # thar 45) dorks * this * this diff --git a/tests/tibdoc.g b/tests/tibdoc.g index a1414d0..072c625 100644 --- a/tests/tibdoc.g +++ b/tests/tibdoc.g @@ -48,8 +48,9 @@ // [c] ... // FIXME: these have to go at the top so they have their dropAll bit set before PreSequence.build... -ws = w** -w = [\r\n\ ] +w = " " | "\n" | "\r" +ws = "()":: w** +// | "()":: w** "#" (~[\n])* "\n" ws nw = ~[\r\n\ ] ////////////////////////////////////////////////////////////////////////////// @@ -79,29 +80,34 @@ onums = nums (". "|") ")! any = ~[]* uli = "* " (ws! text &~ any (oli|uli)!) -oli = ("# "|onums)! (ws! text &~ any (oli|uli)!) +oli = onums! (ws! text &~ any (oli|uli)!) text = Item Item*/ws = blockquote +// > ^"#" ws! { ~[]* } > { UL:: uli+/ws } | { OL:: oli+/ws } > Verbatim + > InlineGrammar > link > structured > styled > (Chars:: alphanum++) > "\"" text "\"" > (Symbol:: sym++) - > { Block:: text } + > { Block:: text } word = Chars:: bareword blockquote = "adsfafewag" //blockquote = Blockquote:: "\"\"" (block | text "\"\"") -Verbatim = "[verbatim]" ws! { (~[])++ } +Verbatim = "[verbatim]" ws! { (~[])++ } + +#import meta.g as meta +InlineGrammar = "\grammar" ws! { meta.Grammar } styled = Underline:: "__" text "__" | Footnote:: "((" text "))"