JsonGrammar { public JsonTree JSON() { return b.<JsonTree>nonterminal(JsonLexer.JSON).is( f.json( b.firstOf( ARRAY(), OBJECT()), b.token(JsonLexer.EOF))); } JsonGrammar(GrammarBuilder<InternalSyntaxToken> b, TreeFactory f); JsonTree JSON(); ObjectTree OBJECT(); SyntaxList<PairTree> PAIR_LIST(); PairTree PAIR(); ArrayTree ARRAY(); SyntaxList<ValueTree> VALUE_LIST(); ValueTree VALUE(); LiteralTree STRING(); LiteralTree NUMBER(); BuiltInValueTree BUILT_IN_VALUE();  }
@Test public void json() { Tree tree = parser.parse("{}"); assertThat(tree).isInstanceOf(JsonTree.class); assertThat(((JsonTree) tree).arrayOrObject()).isInstanceOf(ObjectTree.class); tree = parser.parse("[]"); assertThat(tree).isInstanceOf(JsonTree.class); assertThat(((JsonTree) tree).arrayOrObject()).isInstanceOf(ArrayTree.class); }