+ // Grammar //////////////////////////////////////////////////////////////////////////////
+
+ public static class Grammar extends MetaGrammar {
+ private int anon = 0;
+ public Object walk(Tree<String> tree) {
+ String head = tree.head();
+ if (tree.numChildren()==0) return super.walk(tree);
+ if ("{".equals(head))
+ return nonTerminal("braced"+(anon++),
+ new PreSequence[][] {
+ new PreSequence[] {
+ new PreSequence(new Element[] { CharToken.leftBrace,
+ ((PreSequence)walk(tree, 0)).buildUnion(),
+ CharToken.rightBrace
+ })
+ }
+ },
+ false,
+ false);
+ return super.walk(tree);
+ }
+ }
+