From ea5d0a5e3dffb5ba0143179fd28608c2de8046e0 Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 12 Dec 2005 22:23:27 -0500 Subject: [PATCH] checkpoint darcs-hash:20051213032327-5007d-fc7a672bb831ddf34bd27ba36e0a7d0fa345b746.gz --- TODO | 20 ++++++++++---------- src/edu/berkeley/sbp/misc/MetaGrammar.java | 6 +++++- tests/meta.g | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 4931457..78baf01 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ ______________________________________________________________________________ -pre-1.0 - - - Javadoc comments +Immediately - switch maximal to not-followed-by (~/~) @@ -12,29 +10,31 @@ pre-1.0 - fix the location stuff, it's broken - decent/better error messages - - finalize metagrammar + - write some grammars - Java grammar - TeX (math?) - URL (RFC) - RFC2822 (email message/headers) - - - WIKI!!! TEX!!! + - Wiki grammar ______________________________________________________________________________ -Undecided - - - public API for hates/needs +Soon - clean up the whole Walk situation + - cleaner solution to "maximal"? + - "lift" cases: - right now I can only lift the last child in a forest... begs the question of what the right representation for Forests is if we need to be able to do lift operations on it. + - Parameterized LR + - "Regular Right Part" grammars (NP Chapman, etc) + - Attribute unification ______________________________________________________________________________ -post-1.0 +Later - Implement a k-token peek buffer (for each state, see if it "dead ends" during the next k Phases based solely on state -- ignoring diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index 9244f05..bfddf72 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -73,7 +73,10 @@ public class MetaGrammar extends ReflectiveWalker { public Object _leftbrace_(String s) { return SELF; } public Object _plus_(final Element r) { return new Rep(r, null, false, false); } //public Element _tilde__slash__tilde_(final Element r) { return Repeat.maximal(r); } - public Object _plus__slash_(final Element r, Element s) { /*return Repeat.many1(r, s);*/ return new Rep(r, s, false, false); } + public Object _plus__slash_(final Element r, Object s) { + if (s instanceof String) s = CharToken.string((String)s); + return new Rep(r, (Element)s, false, false); + } //public Element _star__slash_(final Element r, Element s) { return Repeat.many0(r, s); } //public Element _star__star_(final Element r, Element s) { return Repeat.maximal(Repeat.many0(r, s)); } public Object _plus__plus_(final Element r) { return new Rep(r, null, true, false); } @@ -240,6 +243,7 @@ public class MetaGrammar extends ReflectiveWalker { else if (o[i] instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)o[i]).s); drops[j] = true; } else if (o[i] instanceof String) { o2[j] = CharToken.string( ((String)o[i]) ); drops[j] = true; } else if (o[i] instanceof Rep) o2[j] = ((Rep)o[i]).build(ws); + //else if (o[i] instanceof PreBrace) o2[j] else o2[j] = (Element)o[i]; if (dropAll.contains(o2[j])) drops[j] = true; diff --git a/tests/meta.g b/tests/meta.g index 0920a7a..1dccbd6 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -5,7 +5,7 @@ R ::= word ^"::=" Class+/gt ec ::= [~\]\\\-\~] | escaped -Class ::= Rewrite +/ bar => "alternatives" +Class ::= Rewrite +/ "|" => "alternatives" Rewrite ::= Rewritex | Rewritex ^"&" E+ -- 1.7.10.4