I see on https://github.com/antlr/antlr4/blob/master/doc/interpreters.md public static ParseTree parse(String fileName, String combinedGrammarFileName, String startRule) throws IOException { final Grammar g = Grammar.load(combinedGrammarFileName); LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRFileStream(fileName)); CommonTokenStream tokens = new CommonTokenStream(lexEngine); ParserInterpreter parser = g.createParserInterpreter(tokens); ParseTree t = parser.parse(g.getRule(startRule).index); System.out.println("parse tree: "+t.toStringTree(parser)); return t; } but how can I use the tree to get a list of rule names and values?
What do you mean by get a list of rule names and values? Is it that you want to debug the parse? If so you could use