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