コード例 #1
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.SssToken.EType.eS;

            // S -> S + S
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.SssGrammar.EGrammar.eSSS);
            rule.AddLhsSymbol((int)ail.net.test.SssToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.SssToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.SssToken.EType.ePlus, ail.net.parser.GrammarSymbol.EType.eTerminal, "+");
            rule.AddRhsSymbol((int)ail.net.test.SssToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S -> S
            rule = AddRule((int)ail.net.test.SssGrammar.EGrammar.eSS);
            rule.AddLhsSymbol((int)ail.net.test.SssToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.SssToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S -> n
            rule = AddRule((int)ail.net.test.SssGrammar.EGrammar.eSn);
            rule.AddLhsSymbol((int)ail.net.test.SssToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.SssToken.EType.eN, ail.net.parser.GrammarSymbol.EType.eTerminal, "n");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #2
0
ファイル: SAaBbLR1e.cs プロジェクト: aamshukov/miscellaneous
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.SAaBbLR1eToken.EType.eS0;

            // S' -> S
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.SAaBbLR1eGrammar.EGrammar.eS0_S);
            rule.AddLhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eS0, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S'");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S  -> A a A b
            rule = AddRule((int)ail.net.test.SAaBbLR1eGrammar.EGrammar.eS_AaAb);
            rule.AddLhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S  -> B b B a
            rule = AddRule((int)ail.net.test.SAaBbLR1eGrammar.EGrammar.eS_BbBa);
            rule.AddLhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A  -> e(psilon)
            rule = AddRule((int)ail.net.test.SAaBbLR1eGrammar.EGrammar.eA_e);
            rule.AddLhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // B  -> e(psilon)
            rule = AddRule((int)ail.net.test.SAaBbLR1eGrammar.EGrammar.eB_e);
            rule.AddLhsSymbol((int)ail.net.test.SAaBbLR1eToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            BuildFirstSet();
            BuildFollowSet();

            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #3
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.AhoLR1conflictsToken.EType.eE;

            // E0 -> E
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.AhoLR1conflictsGrammar.EGrammar.eE0_E);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE0, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E'");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // E -> E + E
            rule = AddRule((int)ail.net.test.AhoLR1conflictsGrammar.EGrammar.eE_EpE);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.ePlus, ail.net.parser.GrammarSymbol.EType.eTerminal, "+");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // E -> E * E
            rule = AddRule((int)ail.net.test.AhoLR1conflictsGrammar.EGrammar.eE_EmE);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eMult, ail.net.parser.GrammarSymbol.EType.eTerminal, "*");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // E -> ( E )
            rule = AddRule((int)ail.net.test.AhoLR1conflictsGrammar.EGrammar.eE_lEr);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eLeftParens, ail.net.parser.GrammarSymbol.EType.eTerminal, "(");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eRightParens, ail.net.parser.GrammarSymbol.EType.eTerminal, ")");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // E -> a
            rule = AddRule((int)ail.net.test.AhoLR1conflictsGrammar.EGrammar.eE_a);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1conflictsToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            BuildFirstSet();

            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #4
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.KarpovLR1eToken.EType.eS0;

            // S' -> # S # $
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.KarpovLR1eGrammar.EGrammar.eS0_sSs);
            rule.AddLhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.eS0, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S'");
            rule.AddRhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.es, ail.net.parser.GrammarSymbol.EType.eTerminal, "#");
            rule.AddRhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.es, ail.net.parser.GrammarSymbol.EType.eTerminal, "#");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S  -> a S c
            rule = AddRule((int)ail.net.test.KarpovLR1eGrammar.EGrammar.eS_aSc);
            rule.AddLhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.KarpovLR1eToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S -> e(psilon)
            rule = AddRule((int)ail.net.test.AhoLR1eGrammar.EGrammar.eS_e);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1eToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
//            BuildFirstSet();
//            BuildFollowSet();
            BuildFirstKSet(1);
            BuildFollowKSet(1);

            Console.WriteLine("Pool:\n" + ail.net.parser.GrammarPool.Instance.DecoratePool());

            string firstset = DecorateFirstKSet();
            string effset   = DecorateEFFirstKSet();

            Console.WriteLine();
            Console.WriteLine(Decorate());
            Console.WriteLine();

            Console.WriteLine("First set: \n" + firstset);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("EFF set: \n" + effset);
        }
コード例 #5
0
ファイル: Ayc.cs プロジェクト: aamshukov/miscellaneous
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.AycToken.EType.eS0;

            // S0 -> S
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.AycGrammar.EGrammar.eS0_S);
            rule.AddLhsSymbol((int)ail.net.test.AycToken.EType.eS0, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S0");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S -> A A A A
            rule = AddRule((int)ail.net.test.AycGrammar.EGrammar.eS_AAAA);
            rule.AddLhsSymbol((int)ail.net.test.AycToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> a
            rule = AddRule((int)ail.net.test.AycGrammar.EGrammar.eA_a);
            rule.AddLhsSymbol((int)ail.net.test.AycToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> E
            rule = AddRule((int)ail.net.test.AycGrammar.EGrammar.eA_E);
            rule.AddLhsSymbol((int)ail.net.test.AycToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.AycToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // E -> e(psilon)
            rule = AddRule((int)ail.net.test.AycGrammar.EGrammar.eE_e);
            rule.AddLhsSymbol((int)ail.net.test.AycToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #6
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.AhoLR1Token.EType.eS0;

            // S' -> S
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.AhoLR1Grammar.EGrammar.eS0_S);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1Token.EType.eS0, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S'");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1Token.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S  -> C C
            rule = AddRule((int)ail.net.test.AhoLR1Grammar.EGrammar.eS_CC);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1Token.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1Token.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1Token.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // C  -> c C
            rule = AddRule((int)ail.net.test.AhoLR1Grammar.EGrammar.eC_cC);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1Token.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1Token.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1Token.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // C  -> d
            rule = AddRule((int)ail.net.test.AhoLR1Grammar.EGrammar.eC_d);
            rule.AddLhsSymbol((int)ail.net.test.AhoLR1Token.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            rule.AddRhsSymbol((int)ail.net.test.AhoLR1Token.EType.ed, ail.net.parser.GrammarSymbol.EType.eTerminal, "d");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            BuildFirstSet();
            BuildFollowSet();

            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #7
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.GlrAlwaysBrokenToken.EType.eS;

            // S -> b A
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.GlrAlwaysBrokenGrammar.EGrammar.eS_bA);
            rule.AddLhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            rule.AddRhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> a A B
            rule = AddRule((int)ail.net.test.GlrAlwaysBrokenGrammar.EGrammar.eA_aAB);
            rule.AddLhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> e(psilon)
            rule = AddRule((int)ail.net.test.GlrAlwaysBrokenGrammar.EGrammar.eA_e);
            rule.AddLhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // B -> e(psilon)
            rule = AddRule((int)ail.net.test.GlrAlwaysBrokenGrammar.EGrammar.eB_e);
            rule.AddLhsSymbol((int)ail.net.test.GlrAlwaysBrokenToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #8
0
ファイル: Epsilon.cs プロジェクト: aamshukov/miscellaneous
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.EpsToken.EType.eA;

            // A -> a A a
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.EpsGrammar.EGrammar.eAaAa);
            rule.AddLhsSymbol((int)ail.net.test.EpsToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> L
            rule = AddRule((int)ail.net.test.EpsGrammar.EGrammar.eAL);
            rule.AddLhsSymbol((int)ail.net.test.EpsToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eL, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "L");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // L -> a
            rule = AddRule((int)ail.net.test.EpsGrammar.EGrammar.eLa);
            rule.AddLhsSymbol((int)ail.net.test.EpsToken.EType.eL, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "L");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // L -> e(psilon)
            rule = AddRule((int)ail.net.test.EpsGrammar.EGrammar.eLe);
            rule.AddLhsSymbol((int)ail.net.test.EpsToken.EType.eL, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "L");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #9
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.AhoToken.EType.eE;

            // E -> T + E
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.AhoGrammar.EGrammar.eETE);
            rule.AddLhsSymbol((int)ail.net.test.AhoToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eT, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "T");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.ePlus, ail.net.parser.GrammarSymbol.EType.eTerminal, "+");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // E -> T
            rule = AddRule((int)ail.net.test.AhoGrammar.EGrammar.eET);
            rule.AddLhsSymbol((int)ail.net.test.AhoToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eT, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "T");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // T -> F * T
            rule = AddRule((int)ail.net.test.AhoGrammar.EGrammar.eTFT);
            rule.AddLhsSymbol((int)ail.net.test.AhoToken.EType.eT, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "T");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eF, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "F");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eMult, ail.net.parser.GrammarSymbol.EType.eTerminal, "*");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eT, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "T");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // T -> F
            rule = AddRule((int)ail.net.test.AhoGrammar.EGrammar.eTF);
            rule.AddLhsSymbol((int)ail.net.test.AhoToken.EType.eT, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "T");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eF, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "F");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // F -> ( E )
            rule = AddRule((int)ail.net.test.AhoGrammar.EGrammar.eFE);
            rule.AddLhsSymbol((int)ail.net.test.AhoToken.EType.eF, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "F");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eLeftParens, ail.net.parser.GrammarSymbol.EType.eTerminal, "(");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eE, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "E");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eRightParens, ail.net.parser.GrammarSymbol.EType.eTerminal, ")");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // F -> a
            rule = AddRule((int)ail.net.test.AhoGrammar.EGrammar.eFa);
            rule.AddLhsSymbol((int)ail.net.test.AhoToken.EType.eF, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "F");
            rule.AddRhsSymbol((int)ail.net.test.AhoToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();
            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
        }
コード例 #10
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.First3KSudkampToken.EType.eS;

            // S -> A a b d
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.First3KSudkampGrammar.EGrammar.eS_Aabd);
            rule.AddLhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.ed, ail.net.parser.GrammarSymbol.EType.eTerminal, "d");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // S -> c A b c d
            rule = AddRule((int)ail.net.test.First3KSudkampGrammar.EGrammar.eS_cAbcd);
            rule.AddLhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.ed, ail.net.parser.GrammarSymbol.EType.eTerminal, "d");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> a
            rule = AddRule((int)ail.net.test.First3KSudkampGrammar.EGrammar.eA_a);
            rule.AddLhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> b
            // A -> e
            rule = AddRule((int)ail.net.test.First3KSudkampGrammar.EGrammar.eA_b);
            rule.AddLhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> e
            rule = AddRule((int)ail.net.test.First3KSudkampGrammar.EGrammar.eA_e);
            rule.AddLhsSymbol((int)ail.net.test.First3KSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);

            BuildNullabilitySet();

            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
            Console.WriteLine(Decorate());

            ClearFirstSet();
            BuildFirstSet();
            string firstset = DecorateFirstSet();

            Console.WriteLine(firstset);

            ClearFirstSet();
            BuildFirstKSet(1);
            firstset = DecorateFirstKSet();
            Console.WriteLine(firstset);

            // S: aab; bab; abd; cab; cbb; cbc
            // A: e; a; b


            // FIRST:
            // d:
            //         d
            // c:
            //         c
            // b:
            //         b
            // a:
            //         a
            // A:
            //         ~e~    a    b
            // S:
            //         a b d    a a b    b a b    c b c    c a b    c b b
            // ~$~:
            //         ~$~
            // ~e~:
            //         ~e~

            // FOLLOW:
            // A:
            //         a b d    b c d
            // S:
            //         ~e~
            ClearFirstSet();
            ClearFollowSet();
            BuildFirstKSet(3);
            Console.WriteLine(DecorateFirstKSet());
            BuildFollowKSet(3);
            Console.WriteLine(DecorateFollowKSet());
        }
コード例 #11
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.FirstFollowLaKToken.EType.eS;

            // S -> A c c
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.FirstFollowLaKGrammar.EGrammar.eS_Acc);
            rule.AddLhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> b B A
            rule = AddRule((int)ail.net.test.FirstFollowLaKGrammar.EGrammar.eA_bBA);
            rule.AddLhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> B c A a
            rule = AddRule((int)ail.net.test.FirstFollowLaKGrammar.EGrammar.eA_BcAa);
            rule.AddLhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> e
            rule = AddRule((int)ail.net.test.FirstFollowLaKGrammar.EGrammar.eA_e);
            rule.AddLhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");


            // B -> a c B
            rule = AddRule((int)ail.net.test.FirstFollowLaKGrammar.EGrammar.eB_acB);
            rule.AddLhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // B -> b
            rule = AddRule((int)ail.net.test.FirstFollowLaKGrammar.EGrammar.eB_b);
            rule.AddLhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstFollowLaKToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();

            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
            Console.WriteLine(Decorate());

            ClearFirstSet();
            BuildFirstSet();
            string firstset = DecorateFirstSet();

            Console.WriteLine(firstset);

            ClearFirstSet();
            BuildFirstKSet(1);
            firstset = DecorateFirstKSet();
            Console.WriteLine(firstset);

            // S: cc; ba; bb; ac; bc
            // A: e; ac; ba; bb; bc
            // B: ac, b
            ClearFirstSet();
            BuildFirstKSet(2);
            firstset = DecorateFirstKSet();
            Console.WriteLine(firstset);
        }
コード例 #12
0
        public override void Populate()
        {
            base.Populate();

            StartSymbolId = (int)ail.net.test.FirstKSudkampToken.EType.eS;

            // S -> A
            ail.net.parser.GrammarRule rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eS_A);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eS, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "S");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> a A d
            rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eA_aAd);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ed, ail.net.parser.GrammarSymbol.EType.eTerminal, "d");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // A -> B C
            rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eA_BC);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eA, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "A");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // B -> b B c
            rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eB_bBc);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eb, ail.net.parser.GrammarSymbol.EType.eTerminal, "b");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // B -> e
            rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eB_e);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eB, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "B");
            rule.AddRhsSymbol((int)ail.net.test.EpsToken.EType.eEpsilon, ail.net.parser.GrammarSymbol.EType.eTerminal, ail.net.parser.GrammarSymbol.kEpsilon);

            // C -> a c C
            rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eC_acC);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ec, ail.net.parser.GrammarSymbol.EType.eTerminal, "c");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            // C -> a d
            rule = AddRule((int)ail.net.test.FirstKSudkampGrammar.EGrammar.eC_ad);
            rule.AddLhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.eC, ail.net.parser.GrammarSymbol.EType.eNonTerminal, "C");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ea, ail.net.parser.GrammarSymbol.EType.eTerminal, "a");
            rule.AddRhsSymbol((int)ail.net.test.FirstKSudkampToken.EType.ed, ail.net.parser.GrammarSymbol.EType.eTerminal, "d");
            ail.net.framework.Assert.NonNullReference(rule.Lhs[0], "rule.Lhs[0]");
            ail.net.framework.Assert.NonNullReference(rule.Rhs[0], "rule.Rhs[0]");

            BuildNullabilitySet();

            Console.WriteLine(ail.net.parser.GrammarPool.Instance.DecoratePool());
            Console.WriteLine(Decorate());

            ClearFirstSet();
            BuildFirstSet();
            string firstset = DecorateFirstSet();

            Console.WriteLine(firstset);

            ClearFirstSet();
            BuildFirstKSet(1);
            firstset = DecorateFirstKSet();
            Console.WriteLine(firstset);

            // S: ad; bc; aa; ab; bb; ac
            // A: ad; bc; aa; ab; bb; ac
            // B: e; bc; bb
            // C: ad; ac
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            ClearFirstSet();
//            BuildFirstKSet(0);
//            firstset = DecorateFirstKSet();
            Console.WriteLine(firstset);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            ClearFirstSet();
            BuildFirstKSet(2);
            firstset = DecorateFirstKSet();
            Console.WriteLine(firstset);
            Console.WriteLine();
            Console.WriteLine();

            //
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            ClearFollowSet();
            BuildFollowKSet(2);
            string followset = DecorateFollowKSet();

            Console.WriteLine("FOLLOW:");
            Console.WriteLine(followset);
            Console.WriteLine();
            Console.WriteLine();
        }