From: adam Date: Mon, 30 Jan 2006 07:13:59 +0000 (-0500) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~305 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=6ba9ea820f9626a7504da6cf442e2cef1601914f checkpoint darcs-hash:20060130071359-5007d-0f238e24d4872de662ac466f4b7fc622a7b9a80f.gz --- diff --git a/TODO b/TODO index 14b121e..3f7ca10 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ _____________________________________________________________________________ Immediately + - Fix the metagrammar (really?) + - Repeat, Sequence, Tree - simplify Forest (considerably) diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index 963a317..b1de3b1 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -103,6 +103,9 @@ public class MetaGrammar extends StringWalker { return ret; } + // hack, this doens't really work if you're nesting + HashSet keep = new HashSet(); + public Sequence sequence(Object o, boolean lame) { return new PreSequence((Element[])Reflection.lub((Object[])o), null).buildSequence(null, lame, false); } @@ -132,8 +135,9 @@ public class MetaGrammar extends StringWalker { carets.put(ret, s); dropAll.add(ret); return ret; - } - else if ("psx".equals(head)) return ((PreSequence)walk(tree, 0)).buildSequence(); + } else if ("^^".equals(head)) { + return new Keep(walk(tree,0)); + } else if ("psx".equals(head)) return ((PreSequence)walk(tree, 0)).buildSequence(); else if ("nonTerminal".equals(head)) return getNonTerminal(string(tree.child(0))); else if ("::=".equals(head)) return nonTerminal(string(tree.child(0)), (Sequence[][])walk(tree, 1), false, false); else if ("=".equals(head)) return nonTerminal(string(tree.child(0)), (Sequence[][])walk(tree, 1), false, false); @@ -167,6 +171,11 @@ public class MetaGrammar extends StringWalker { else return super.walk(tree); } + static class Keep { + final Object o; + public Keep(Object o) { this.o = o; } + } + public String convertLabel(String label) { return label; } public Object walk(String tag, Object[] argo) { @@ -251,10 +260,12 @@ public class MetaGrammar extends StringWalker { HashSet set = new HashSet(); Element[] o2 = o==null ? new Element[0] : new Element[o.length]; int nonDrop = 0; + int keeping = -1; if (o != null) { int j = 0; for(int i=0; i ^"(" RHS ")" /ws | ^"~" e + > "^^":: "^" e word = [a-zA-Z0-9_]++ Quoted = "\"" ((~[\"\\] | escaped)+) "\"" diff --git a/tests/regression.tc b/tests/regression.tc index eb29cf8..f911a97 100644 --- a/tests/regression.tc +++ b/tests/regression.tc @@ -344,7 +344,7 @@ testcase { testcase { input "a+2"; - output ""; + output "Plus:{left:{Foo} right:{{2}}}"; s = Expr Expr = [0-9]++ diff --git a/tests/tibdoc.g b/tests/tibdoc.g index 650b06e..442e203 100644 --- a/tests/tibdoc.g +++ b/tests/tibdoc.g @@ -13,6 +13,45 @@ x ="x" // image // figures +// "reference-style" links +// +// this[1] is fun +// +// [1] http://... +// + +// consider ++bold++ and **italic**? +// \br +// nonbreaking text? +// ellipsis detection (...) +// degree: 15^o +// Arrows: <- -> => <= <-> + +// textblocks: +// - attention, caution, danger, error, hint, important, note, tip, warning +// definition +// sidebar +// figure-with-caption +// epigraph (end-of-chapter note) +// compound paragraph (??) +// csv-table? +// table of contents +// header, footer +// #include + +// simple macros (#define) (\define) +// today's date + +// table representation +// +// \table +// a bbb c +// ddd e +// +// [a] ... +// [b] ... +// [c] ... + // FIXME: these have to go at the top so they have their dropAll bit set before PreSequence.build... ws ! = w** w ! = [\r\n\ ]