X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FMetaGrammar.java;h=53aeff098f231c99e8310f3a090a4b5c3f8719fe;hp=234673f037200042a873b5088f71edc81995c8be;hb=3485f1c89ae352b5aa1b65cdfa5f628cd3859601;hpb=7ad1e0ae9ef7ee8ba5e3cc1d98b3545b92f48298 diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index 234673f..53aeff0 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -25,69 +25,6 @@ public class MetaGrammar extends ReflectiveWalker { public static Union epsilon = new Union("()"); static { epsilon.add(Sequence.empty); } - // MetaGrammar ////////////////////////////////////////////////////////////////////////////// - - public Object _star_(Element r) { return new Rep(r, null, false, true); } - public Element epsilon(Object o, Object b) { return epsilon; } - public Element _rightparen_(Object e) { return SELF; } - - public PreSequence _amp_(PreSequence p, Object[] o) { return p.and(new PreSequence(o, null, true).buildSequence(null, true, false)); } - public PreSequence _amp__tilde_(PreSequence p, Object[] o) { return p.not(new PreSequence(o, null, true).buildSequence(null, true, false)); } - - public Element _bang_(Element r) { return r; } - public Object care(String s) { return new MyLift(s); } - public Object _caret_(String s) { return new MyLift(s); } - public Object _leftparen__rightparen_() { return epsilon; } - - public Union nonTerminal(String s) { return nonTerminalX(s, false, false); } - public Union nonTerminalX(String s, boolean synthetic, boolean dropAll) { - Union n = s.equals(startSymbol) ? g : nt.get(s); - if (n == null) nt.put(s, n = new Union(s, synthetic)); - if (dropAll) this.dropAll.add(n); - return n; - } - public Union _colon__colon__equals_(String s, PreSequence[][] p) { return nonTerminalX(s, p, false, false); } - public Union _bang__colon__colon__equals_(String s, PreSequence[][] p) { return nonTerminalX(s, p, false, true); } - public Union _colon__colon__equals_(boolean q, String s, PreSequence[][] p) { return nonTerminalX(s, p, false, q); } - public Object _leftparen_(PreSequence[][] p) { return nonTerminalX("anon"+(anon++), p, false, false); } - public Object _backslash__leftbrace_(String s) { return SELF; } - public Object _leftbrace_(String s) { return SELF; } - public Object _plus_(final Element r) { return new Rep(r, null, false, false); } - public Object[] _slash_(Object[] o, Object sep) { - if (o.length <= 1) return o; - Object[] ret = new Object[o.length * 2 - 1]; - for(int i=0; i seqs = new HashSet(); for(int i=0; i set) { - if (o==null) return new Element[0]; - Element[] o2 = new Element[o.length]; - drops = new boolean[o.length]; - int j = 0; - for(int i=0; i set = new HashSet(); - Element[] expansion = expand(u, set); + Element[] o2 = o==null ? new Element[0] : new Element[o.length]; + if (o != null) { + drops = new boolean[o.length]; + int j = 0; + for(int i=0; i