public void Parser_MiniPL_LL1FollowSetsTest() { MiniPL miniPL = MiniPL.GetInstance(); CFG grammar = miniPL.Grammar; Dictionary <string, Nonterminal> vars = miniPL.Nonterminals; Dictionary <string, Terminal> terms = miniPL.Terminals; ISet <Terminal> followSet = grammar.Follow(vars["program"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { Terminal.EOF })); followSet = grammar.Follow(vars["statements"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms["end"], Terminal.EOF })); followSet = grammar.Follow(vars["statements_head"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms["end"], Terminal.EOF, terms["var"], terms["assert"], terms["read"], terms["print"], terms["for"], terms["identifier"] })); followSet = grammar.Follow(vars["statements_tail"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms["end"], Terminal.EOF })); followSet = grammar.Follow(vars["statement"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[";"] })); followSet = grammar.Follow(vars["declaration"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[";"] })); followSet = grammar.Follow(vars["declaration_assignment"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[";"] })); followSet = grammar.Follow(vars["expression"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[".."], terms["do"], terms[")"], terms[";"] })); followSet = grammar.Follow(vars["unary_operation"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[".."], terms["do"], terms[")"], terms[";"] })); followSet = grammar.Follow(vars["binary_operation"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[".."], terms["do"], terms[")"], terms[";"] })); followSet = grammar.Follow(vars["operand"]); Assert.IsTrue(followSet.SetEquals(new Terminal[] { terms[".."], terms["do"], terms[")"], terms[";"], terms["binary_operator"] })); }