checkSymbols(g, rules, tokenNames);
}
@Test public void testLiteralInParserAndLexer() throws Exception {
// 'x' is token and char in lexer rule
Grammar g = new Grammar(
"grammar t;\n" +
"a : 'x' E ; \n" +
"E: 'x' '0' ;\n");
String literals = "['x']";
String foundLiterals = g.stringLiteralToTypeMap.keySet().toString();
assertEquals(literals, foundLiterals);
foundLiterals = g.implicitLexer.stringLiteralToTypeMap.keySet().toString();
assertEquals("['x']", foundLiterals); // pushed in lexer from parser
String[] typeToTokenName = g.getTokenDisplayNames();
Set<String> tokens = new LinkedHashSet<String>();
for (String t : typeToTokenName) if ( t!=null ) tokens.add(t);
assertEquals("[<INVALID>, 'x', E]", tokens.toString());
}