From 0903e4350b8d9d066efdf918f0674a45696c631a Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 2 Jul 2006 15:40:55 -0400 Subject: [PATCH] checkpoint darcs-hash:20060702194055-5007d-963f40ff133cf30dd56a7f82d36d834136461578.gz --- src/edu/berkeley/sbp/misc/Demo.java | 2 +- src/edu/berkeley/sbp/tib/TibDoc.java | 51 ++++++++++++++++++++++++++++++++-- tests/tibdoc.g | 4 +-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/edu/berkeley/sbp/misc/Demo.java b/src/edu/berkeley/sbp/misc/Demo.java index 6b183e9..dd56ea0 100644 --- a/src/edu/berkeley/sbp/misc/Demo.java +++ b/src/edu/berkeley/sbp/misc/Demo.java @@ -207,7 +207,7 @@ public class Demo { tag t = getTag(); if (t != null && (t.value().equals(p.tag) || - (t.value().equals("") && p.tag.equals(getName())))) + (t.value().equals("") && getName().equals(p.tag)))) return buildSequence(p)!=null; nonterminal n = getNonTerminal(); diff --git a/src/edu/berkeley/sbp/tib/TibDoc.java b/src/edu/berkeley/sbp/tib/TibDoc.java index d8f24ff..e264029 100644 --- a/src/edu/berkeley/sbp/tib/TibDoc.java +++ b/src/edu/berkeley/sbp/tib/TibDoc.java @@ -357,12 +357,41 @@ toContex ll = prefix ++ (concatMap tl ll) ++ suffix public static class Paragraph extends Dump { } public @tag("P") static class P extends Paragraph { - Object text; + public Text[] text; } public @tag("HR") static class HR extends Paragraph { } public @tag("Blockquote") static class Blockquote extends Paragraph { Object text; } + + public static class Text extends Dump { } + public @tag static class Chars extends Text { + public String text; + } + public @tag static class Block extends Text { public Text[] text; } + public static class TextWrap extends Text { + public Text text; + } + public static @tag class Verbatim extends Text { public char[] c; } + //public @tag class Blockquote extends TextWrap { } + public static @tag class Underline extends TextWrap { } + public static @tag class Footnote extends TextWrap { } + public static @tag class TT extends TextWrap { } + //public @tag class Citation extends Text { "[" word "]" } + public static @tag class Strikethrough extends TextWrap { } + //public @tag class Superscript extends TextWrap { } + //public @tag class Subscript extends TextWrap { } + public static @tag class Smallcap extends TextWrap { } + //public @tag class Keyword extends TextWrap { } + public static @tag class Bold extends TextWrap { } + public static @tag class Italic extends TextWrap { } + + public static class Command extends Text { } + public static @tag class Today extends Command { } + public static @tag class LineBreak extends Command { } + + public static class Glyph extends Text { } + public static @tag("emdash") class Emdash extends Glyph { } } public static void main(String[] s) throws Exception { @@ -379,7 +408,25 @@ toContex ll = prefix ++ (concatMap tl ll) ++ suffix TibDoc.TD.P.class, TibDoc.TD.HR.class, TibDoc.TD.Blockquote.class, - TibDoc.TD.KeyVal.class + TibDoc.TD.KeyVal.class, + TibDoc.TD.Text.class, + TibDoc.TD.TextWrap.class, + TibDoc.TD.Verbatim.class, + TibDoc.TD.Blockquote.class, + TibDoc.TD.Underline.class, + TibDoc.TD.Footnote.class, + TibDoc.TD.TT.class, + TibDoc.TD.Strikethrough.class, + //TibDoc.TD.Superscript.class, + //TibDoc.TD.Subscript.class, + TibDoc.TD.Smallcap.class, + TibDoc.TD.Bold.class, + //TibDoc.TD.Keyword.class, + TibDoc.TD.Italic.class, + TibDoc.TD.Today.class, + TibDoc.TD.LineBreak.class, + TibDoc.TD.Chars.class, + TibDoc.TD.Emdash.class, }); Tree res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); MetaGrammar.Meta.MetaGrammarFile mgf = m.new MetaGrammarFile(res); diff --git a/tests/tibdoc.g b/tests/tibdoc.g index 5043716..ed71ad3 100644 --- a/tests/tibdoc.g +++ b/tests/tibdoc.g @@ -91,10 +91,10 @@ Item = blockquote > "[]":: link Itemx > "[]":: structured Itemx > "[]":: styled Itemx - > "[]":: (Chars:: text:alphanum++) Itemx + > "[]":: (Chars:: alphanum++) Itemx > "[]":: "\"" text "\"" Itemx > "[]":: (Symbol:: sym++) Itemx - > "[]":: { text } Itemx + > "[]":: { Block:: text } Itemx blockquote = Blockquote:: "\"\"" text "\"\"" | Blockquote:: "\"\"" block -- 1.7.10.4