- public static Union make(Tree t, String s) {
- ReflectiveMeta rm = new ReflectiveMeta();
- Reducer red = (Reducer)t.head();
- MG.Grammar g = (MG.Grammar)red.reduce(t);
+ public static Union cached = null;
+ public static Union make() {
+ if (cached != null) return cached;
+ try {
+ ReflectiveMeta m = new ReflectiveMeta();
+ Tree<String> res = new CharParser(MetaGrammar.make()).parse(new FileInputStream("tests/meta.g")).expand1();
+ MetaGrammar.Meta.MetaGrammarFile mgf = m.new MetaGrammarFile(res);
+ MetaGrammar.BuildContext bc = new MetaGrammar.BuildContext(mgf);
+ Union meta = mgf.get("s").build(bc);
+ Tree t = new CharParser(meta).parse(new FileInputStream("tests/meta.g")).expand1();
+ return cached = make(t, "s");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ public static Union make(Tree t, String s) { return make(t, s, new ReflectiveMeta()); }
+ public static Union make(Tree t, String s, ReflectiveMeta rm) {
+ Functor<Iterable<Tree>,Object> red = (Functor<Iterable<Tree>,Object>)t.head();
+ MG.Grammar g = (MG.Grammar)red.invoke(t.children());