X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FMetaGrammar.java;h=a4ee08f55164326b86c82cf02fc2b5b0bac64478;hb=b9da5584ad66f98290fa46dae32622aae8f7cf5c;hp=dd9436803a015537d54975da6ec6b96632d6c46c;hpb=58255f1146299de97dcc40a0392866308f44006d;p=sbp.git diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index dd94368..a4ee08f 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -16,7 +16,7 @@ public class MetaGrammar extends ReflectiveWalker { } // FIXME - private static HashSet dropAll = new HashSet(); + private static HashSet dropAll = new HashSet(); // Statics ////////////////////////////////////////////////////////////////////////////// @@ -78,16 +78,8 @@ public class MetaGrammar extends ReflectiveWalker { } return ret; } - //public Element _tilde__slash__tilde_(final Element r) { return Repeat.maximal(r); } - 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 Object _star__slash_(final Element r, Object s) { - if (s instanceof String) s = CharToken.string((String)s); - return new Rep(r, (Element)s, false, true); - } - //public Element _star__slash_(final Element r, Element s) { return Repeat.many0(r, s); } + public Object _plus__slash_(final Element r, Object s) { return new Rep(r, (Element)s, false, false); } + public Object _star__slash_(final Element r, Object s) { return new Rep(r, (Element)s, false, true); } public Object _star__star_(final Element r) { return new Rep(r, null, true, true); } public Object _plus__plus_(final Element r) { return new Rep(r, null, true, false); } public Element _question_(final Element r) { return Repeat.maybe(r); } @@ -96,8 +88,14 @@ public class MetaGrammar extends ReflectiveWalker { public MetaGrammar grammar(Object o, Union[] u, Object x) { return this; } public char _backslash_n() { return '\n'; } public char _backslash_r() { return '\r'; } - public String literal(String s) { return s; } - //public Element literal(String s) { return CharToken.string(s); } + //public String literal(String s) { return s; } + + public Object literal(String s) { + Element e = CharToken.string(s); + return new MyDrop(e); + //dropAll.add(e); + //return e; + } public Range range0(char a) { return new Range(a, a); } public Range range0(char a, char b) { return new Range(a, b); } @@ -169,6 +167,7 @@ public class MetaGrammar extends ReflectiveWalker { g = new Union(str); startSymbol = str; nt = new HashMap(); + dropAll = new HashSet(); nt.put(str, g); this.dws = Repeat.maximal(Repeat.many0(nonTerminalY("w"))); return ret; @@ -249,7 +248,6 @@ public class MetaGrammar extends ReflectiveWalker { if (oi instanceof PreSequence) o2[j] = ((PreSequence)oi).buildUnion(); else if (oi==SELF) o2[j] = u.new Subset("(("+u+"))", set); else if (oi instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = true; } - else if (oi instanceof String) { o2[j] = CharToken.string( ((String)oi) ); drops[j] = true; } else if (oi instanceof Rep) o2[j] = ((Rep)oi).build(); else o2[j] = (Element)oi; @@ -361,6 +359,10 @@ public class MetaGrammar extends ReflectiveWalker { + + + + // DO NOT EDIT STUFF BELOW: IT IS AUTOMATICALLY GENERATED new Tree(null, "gram", new Tree[] { new Tree(null, null, new Tree[] { }), new Tree(null, "grammar", new Tree[] { new Tree(null, null, new Tree[] { new Tree(null, "::=", new Tree[] { new Tree(null, "sify", new Tree[] { new Tree(null, null, new Tree[] { new Tree(null, "s", new Tree[] { })})}), @@ -945,3 +947,7 @@ new Tree(null, "gram", new Tree[] { new Tree(null, null, new Tree[] { }), + + + +