public void TestLexerDelegatorRuleOverridesDelegateLeavingNoRules() /*throws Exception*/ { // M.Tokens has nothing to predict tokens from S. Should // not include S.Tokens alt in this case? string slave = "lexer grammar S;\n" + "A : 'a' {System.out.println(\"S.A\");} ;\n"; mkdir(tmpdir); writeFile(tmpdir, "S.g", slave); string master = "lexer grammar M;\n" + "import S;\n" + "A : 'a' {System.out.println(\"M.A\");} ;\n" + "WS : (' '|'\\n') {skip();} ;\n"; writeFile(tmpdir, "M.g", master); ErrorQueue equeue = new ErrorQueue(); ErrorManager.SetErrorListener(equeue); AntlrTool antlr = newTool(new string[] { "-lib", tmpdir }); CompositeGrammar composite = new CompositeGrammar(); Grammar g = new Grammar(antlr, tmpdir + "/M.g", composite); composite.SetDelegationRoot(g); g.ParseAndBuildAST(); composite.AssignTokenTypes(); composite.DefineGrammarSymbols(); composite.CreateNFAs(); g.CreateLookaheadDFAs(false); // predict only alts from M not S string expectingDFA = ".s0-'a'->.s1\n" + ".s0-{'\\n', ' '}->:s3=>2\n" + ".s1-<EOT>->:s2=>1\n"; Antlr3.Analysis.DFA dfa = g.GetLookaheadDFA(1); FASerializer serializer = new FASerializer(g); string result = serializer.Serialize(dfa.startState); assertEquals(expectingDFA, result); // must not be a "unreachable alt: Tokens" error assertEquals("unexpected errors: " + equeue, 0, equeue.errors.Count); }