- public TestCase[] ts(Object o1, TestCase[] ts, Object o2) { return ts; }
- public TestCase[] ts(TestCase[] ts) { return ts; }
- public TestCase testcase(String input, String[] output, Union grammar) { return new TestCase(input, output, grammar); }
- public TestCase testcase(String input, Union grammar) { return new TestCase(input, new String[0], grammar); }
- public MetaGrammar grammar(Object[] o) { return this; }
- public Object walk(String tag, Object[] args) {
- if ("grammar".equals(tag)) return done("s");
- else return super.walk(tag, args);
+ public Object walk(Tree<String> tree) {
+ try {
+ if ("grammar".equals(tree.head())) { walkChildren(tree); return done("s"); }
+ else if ("output".equals(tree.head())) return string(tree.children());
+ else if ("input".equals(tree.head())) return string(tree.children());
+ else if ("tibcase".equals(tree.head()) || "testcase".equals(tree.head())) {
+ String input = string(tree.child(0));
+ String[] output = tree.numChildren()>2 ? ((String[])walk(tree, 1)) : new String[0];
+ boolean tib = "tibcase".equals(tree.head());
+ MetaGrammar gram = tib ? new Tib.Grammar() : new MetaGrammar();
+ Union grammar = (Union)((MetaGrammar)(gram.walk(tree, tree.numChildren()-1))).done("s");
+ return new TestCase(input, output, grammar, tib);
+ } else if ("ts".equals(tree.head())) return walk(tree, 0);
+ else return super.walk(tree);
+ } catch (Exception e) {
+ throw new Error(e);
+ }