update changes file, tweak parser interp test to use new api

This commit is contained in:
Terence Parr 2013-11-20 14:28:51 -08:00
parent f4bb91d758
commit 5a6709aba6
2 changed files with 26 additions and 3 deletions

View File

@ -1,5 +1,30 @@
ANTLR v4 Honey Badger
November 20, 2013
* Sam added method stuff like expr() that calls expr(0). Makes it possible
to call expr rule from TestRig (grun).
November 14, 2013
* Added Sam's ParserInterpreter implementation that uses ATN after
deserialization.
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n" +
"A : 'a' ;\n" +
"B : 'b' ;\n" +
"C : 'c' ;\n");
Grammar g = new Grammar(
"parser grammar T;\n" +
"s : (A{;}|B)* C ;\n",
lg);
LexerInterpreter lexEngine = lg.createLexerInterpreter(new ANTLRInputStream(input));
CommonTokenStream tokens = new CommonTokenStream(lexEngine);
ParserInterpreter parser = g.createParserInterpreter(tokens);
ParseTree t = parser.parse(g.rules.get(startRule).index);
November 13, 2013
* move getChildren() from Tree into Trees (to avoid breaking change)

View File

@ -201,9 +201,7 @@ public class TestParserInterpreter extends BaseTest {
{
LexerInterpreter lexEngine = lg.createLexerInterpreter(new ANTLRInputStream(input));
CommonTokenStream tokens = new CommonTokenStream(lexEngine);
ATN atn = createATN(g, true);
ParserInterpreter parser = new ParserInterpreter(g.fileName, Arrays.asList(g.getTokenNames()), Arrays.asList(g.getRuleNames()), atn, tokens);
ParserInterpreter parser = g.createParserInterpreter(tokens);
ParseTree t = parser.parse(g.rules.get(startRule).index);
System.out.println("parse tree: "+t.toStringTree(parser));
assertEquals(parseTree, t.toStringTree(parser));