コード例 #1
0
        public NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum> CreateLexer()
        {
            var symbols_rep = StringRep.Create(Tuple.Create(SymbolEnum.Error, "Error"),
                                               Tuple.Create(SymbolEnum.EOF, "EOF"),
                                               Tuple.Create(SymbolEnum.LPAREN, "LPAREN"),
                                               Tuple.Create(SymbolEnum.RPAREN, "RPAREN"),
                                               Tuple.Create(SymbolEnum.NUM, "NUM"),
                                               Tuple.Create(SymbolEnum.ATOM, "ATOM"),
                                               Tuple.Create(SymbolEnum.comp, "comp"),
                                               Tuple.Create(SymbolEnum.elem, "elem"),
                                               Tuple.Create(SymbolEnum.__list___merged_elem_e____, "__list___merged_elem_e____"));
            var states_rep = StringRep.Create(Tuple.Create(StateEnum.INIT, "INIT"));
            var mre        = new DfaTable(ConnectionTable.Create(40, new int [] { 1, 4, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }), //0
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(0, false)),                                                                                                                                               //1
                                          ConnectionTable.Create(97, new int [] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, Tuple.Create(3, false)),                                                                 //2
                                          ConnectionTable.Create(48, new int [] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, Tuple.Create(2, false)),                                                                                                                 //3
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(1, false)),                                                                                                                                               //4
                                          ConnectionTable.Create(97, new int [] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, Tuple.Create(3, false)));                                                                //5
            var lexer = new NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum>(symbols_rep, states_rep, StateEnum.INIT, SymbolEnum.EOF, SymbolEnum.Error, mre);

            lexer.AddIdRule(0, "\"" + "(" + "\"", StringCaseComparison.Sensitive, SymbolEnum.LPAREN, StateEnum.INIT);
            lexer.AddIdRule(1, "\"" + ")" + "\"", StringCaseComparison.Sensitive, SymbolEnum.RPAREN, StateEnum.INIT);
            lexer.AddIdAction(2, "/" + @"[0-9]+" + "/", StringCaseComparison.Sensitive, match => { match.Token = SymbolEnum.NUM;
                                                                                                   match.Value = Convert.ToInt32(match.Text); }, StateEnum.INIT);
            lexer.AddIdRule(3, "/" + @"[A-Z][a-z]*" + "/", StringCaseComparison.Sensitive, SymbolEnum.ATOM, StateEnum.INIT);
            lexer.EofAction = (TokenMatch <SymbolEnum> match) => match.Token = SymbolEnum.EOF;
            return(lexer);
        }
コード例 #2
0
        public NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum> CreateLexer()
        {
            var symbols_rep = StringRep.Create(Tuple.Create(SymbolEnum.Error, "Error"),
                                               Tuple.Create(SymbolEnum.EOF, "EOF"),
                                               Tuple.Create(SymbolEnum.PLUS, "PLUS"),
                                               Tuple.Create(SymbolEnum.MINUS, "MINUS"),
                                               Tuple.Create(SymbolEnum.LANGLE, "LANGLE"),
                                               Tuple.Create(SymbolEnum.RANGLE, "RANGLE"),
                                               Tuple.Create(SymbolEnum.comp, "comp"),
                                               Tuple.Create(SymbolEnum.expr, "expr"),
                                               Tuple.Create(SymbolEnum.NUM, "NUM"));
            var states_rep = StringRep.Create(Tuple.Create(StateEnum.INIT, "INIT"));
            var mre        = new DfaTable(ConnectionTable.Create(32, new int [] { 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 6, -1, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1, -1, 5, -1, 4 }), //0
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(0, false)),                                                                                      //1
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(5, false)),                                                                                      //2
                                          ConnectionTable.Create(48, new int [] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, Tuple.Create(4, false)),                                                        //3
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(3, false)),                                                                                      //4
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(2, false)),                                                                                      //5
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(1, false)));                                                                                     //6
            var lexer = new NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum>(symbols_rep, states_rep, StateEnum.INIT, SymbolEnum.EOF, SymbolEnum.Error, mre);

            lexer.AddIdRule(0, "\"" + "+" + "\"", StringCaseComparison.Sensitive, SymbolEnum.PLUS, StateEnum.INIT);
            lexer.AddIdRule(1, "\"" + "-" + "\"", StringCaseComparison.Sensitive, SymbolEnum.MINUS, StateEnum.INIT);
            lexer.AddIdRule(2, "\"" + "<" + "\"", StringCaseComparison.Sensitive, SymbolEnum.LANGLE, StateEnum.INIT);
            lexer.AddIdRule(3, "\"" + ">" + "\"", StringCaseComparison.Sensitive, SymbolEnum.RANGLE, StateEnum.INIT);
            lexer.AddIdAction(4, "/" + @"[0-9]+" + "/", StringCaseComparison.Sensitive, match => { match.Token = SymbolEnum.NUM;
                                                                                                   match.Value = Convert.ToInt32(match.Text); }, StateEnum.INIT);
            lexer.AddIdAction(5, "\"" + " " + "\"", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.EofAction = (TokenMatch <SymbolEnum> match) => match.Token = SymbolEnum.EOF;
            return(lexer);
        }
コード例 #3
0
        public NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum> CreateLexer()
        {
            var symbols_rep = StringRep.Create(Tuple.Create(SymbolEnum.Error, "Error"),
                                               Tuple.Create(SymbolEnum.EOF, "EOF"),
                                               Tuple.Create(SymbolEnum.LANGLE, "LANGLE"),
                                               Tuple.Create(SymbolEnum.RANGLE, "RANGLE"),
                                               Tuple.Create(SymbolEnum.LBRACKET, "LBRACKET"),
                                               Tuple.Create(SymbolEnum.RBRACKET, "RBRACKET"),
                                               Tuple.Create(SymbolEnum.DOT, "DOT"),
                                               Tuple.Create(SymbolEnum.COMMA, "COMMA"),
                                               Tuple.Create(SymbolEnum.NEW, "NEW"),
                                               Tuple.Create(SymbolEnum.IDENTIFIER, "IDENTIFIER"),
                                               Tuple.Create(SymbolEnum.WHATEVER, "WHATEVER"),
                                               Tuple.Create(SymbolEnum.s, "s"),
                                               Tuple.Create(SymbolEnum.array, "array"),
                                               Tuple.Create(SymbolEnum.jagged_array, "jagged_array"),
                                               Tuple.Create(SymbolEnum.dot_identifier, "dot_identifier"),
                                               Tuple.Create(SymbolEnum.typename_list, "typename_list"),
                                               Tuple.Create(SymbolEnum.typename, "typename"),
                                               Tuple.Create(SymbolEnum.whatever, "whatever"),
                                               Tuple.Create(SymbolEnum.__list___merged_array_c____, "__list___merged_array_c____"),
                                               Tuple.Create(SymbolEnum.__optList___merged_array_c____, "__optList___merged_array_c____"),
                                               Tuple.Create(SymbolEnum.__list___merged_jagged_array_a____, "__list___merged_jagged_array_a____"),
                                               Tuple.Create(SymbolEnum.__list___merged_dot_identifier_id____, "__list___merged_dot_identifier_id____"),
                                               Tuple.Create(SymbolEnum.__list___merged_typename_list_t____, "__list___merged_typename_list_t____"),
                                               Tuple.Create(SymbolEnum.__list_s__, "__list_s__"),
                                               Tuple.Create(SymbolEnum.__optList_s__, "__optList_s__"));
            var states_rep = StringRep.Create(Tuple.Create(StateEnum.INIT, "INIT"));
            var mre        = new DfaTable(ConnectionTable.Create(0, new int [] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 13, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 4, 7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4, 8, 4, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 4, 11, 4, 9, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }), //0
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(0, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //1
                                          ConnectionTable.Create(160, new int [] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     //2
                                          ConnectionTable.Create(128, new int [] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     //3
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //4
                                          ConnectionTable.Create(9, new int [] { 13, 13, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13 }, Tuple.Create(7, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       //5
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(5, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //6
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(4, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //7
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(1, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //8
                                          ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, -1, -1, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, 14, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, Tuple.Create(8, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                          //9
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(2, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //10
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(3, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //11
                                          ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, -1, -1, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, 14, -1, 14, 14, 14, 14, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, Tuple.Create(8, false), Tuple.Create(9, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                          //12
                                          ConnectionTable.Create(9, new int [] { 13, 13, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13 }, Tuple.Create(7, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               //13
                                          ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, -1, -1, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, 14, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, Tuple.Create(8, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //14
                                          ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, -1, -1, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, 14, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 14, 14, 14 }, Tuple.Create(8, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //15
                                          ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, -1, -1, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -1, -1, -1, -1, 14, -1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, Tuple.Create(6, false), Tuple.Create(8, false)));                                                                                                                                                                                                                                                                                                                                                                                                                                                         //16
            var lexer = new NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum>(symbols_rep, states_rep, StateEnum.INIT, SymbolEnum.EOF, SymbolEnum.Error, mre);

            lexer.AddIdRule(0, "\"" + "<" + "\"", StringCaseComparison.Sensitive, SymbolEnum.LANGLE, StateEnum.INIT);
            lexer.AddIdRule(1, "\"" + ">" + "\"", StringCaseComparison.Sensitive, SymbolEnum.RANGLE, StateEnum.INIT);
            lexer.AddIdRule(2, "\"" + "[" + "\"", StringCaseComparison.Sensitive, SymbolEnum.LBRACKET, StateEnum.INIT);
            lexer.AddIdRule(3, "\"" + "]" + "\"", StringCaseComparison.Sensitive, SymbolEnum.RBRACKET, StateEnum.INIT);
            lexer.AddIdRule(4, "\"" + "." + "\"", StringCaseComparison.Sensitive, SymbolEnum.DOT, StateEnum.INIT);
            lexer.AddIdRule(5, "\"" + "," + "\"", StringCaseComparison.Sensitive, SymbolEnum.COMMA, StateEnum.INIT);
            lexer.AddIdRule(6, "\"" + "new" + "\"", StringCaseComparison.Sensitive, SymbolEnum.NEW, StateEnum.INIT);
            lexer.AddIdAction(7, "/" + @"[ \r\n\t]+" + "/", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.AddIdRule(8, "/" + @"[A-Za-z_][A-Za-z_0-9]*" + "/", StringCaseComparison.Sensitive, SymbolEnum.IDENTIFIER, StateEnum.INIT);
            lexer.AddIdRule(9, "/" + @"." + "/", StringCaseComparison.Sensitive, SymbolEnum.WHATEVER, StateEnum.INIT);
            return(lexer);
        }
コード例 #4
0
        public NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum> CreateLexer()
        {
            var symbols_rep = StringRep.Create(Tuple.Create(SymbolEnum.Error, "Error"),
                                               Tuple.Create(SymbolEnum.EOF, "EOF"),
                                               Tuple.Create(SymbolEnum.__term0, "__term0"),
                                               Tuple.Create(SymbolEnum.__term1, "__term1"),
                                               Tuple.Create(SymbolEnum.PLUS, "PLUS"),
                                               Tuple.Create(SymbolEnum.MINUS, "MINUS"),
                                               Tuple.Create(SymbolEnum.MULT, "MULT"),
                                               Tuple.Create(SymbolEnum.DIV, "DIV"),
                                               Tuple.Create(SymbolEnum.POWER, "POWER"),
                                               Tuple.Create(SymbolEnum.s, "s"),
                                               Tuple.Create(SymbolEnum.exp, "exp"),
                                               Tuple.Create(SymbolEnum.NUM, "NUM"));
            var states_rep = StringRep.Create(Tuple.Create(StateEnum.INIT, "INIT"),
                                              Tuple.Create(StateEnum.COMMENT, "COMMENT"));
            var mre = new DfaTable(ConnectionTable.Create(0, new int [] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 6, 4, 4, 4, 4, 1, 7, 8, 9, 4, 10, 4, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 13, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }), //0
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(0, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //1
                                   ConnectionTable.Create(160, new int [] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               //2
                                   ConnectionTable.Create(128, new int [] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               //3
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //4
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(8, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //5
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(9, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //6
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(1, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //7
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(4, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //8
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(2, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //9
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(3, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //10
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(5, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //11
                                   ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, Tuple.Create(7, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //12
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(6, false), Tuple.Create(10, false), Tuple.Create(11, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      //13
                                   ConnectionTable.Create(48, new int [] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, Tuple.Create(7, false)));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               //14
            var lexer = new NaiveLanguageTools.Lexer.Lexer <SymbolEnum, StateEnum>(symbols_rep, states_rep, StateEnum.INIT, SymbolEnum.EOF, SymbolEnum.Error, mre);

            lexer.AddIdRule(0, "\"" + "(" + "\"", StringCaseComparison.Sensitive, SymbolEnum.__term0, StateEnum.INIT);
            lexer.AddIdRule(1, "\"" + ")" + "\"", StringCaseComparison.Sensitive, SymbolEnum.__term1, StateEnum.INIT);
            lexer.AddIdRule(2, "\"" + "+" + "\"", StringCaseComparison.Sensitive, SymbolEnum.PLUS, StateEnum.INIT);
            lexer.AddIdRule(3, "\"" + "-" + "\"", StringCaseComparison.Sensitive, SymbolEnum.MINUS, StateEnum.INIT);
            lexer.AddIdAction(4, "\"" + "*" + "\"", StringCaseComparison.Sensitive, match => { match.Token = SymbolEnum.MULT;
                                                                                               match.Value = SymbolEnum.MULT; }, StateEnum.INIT);
            lexer.AddIdRule(5, "\"" + "/" + "\"", StringCaseComparison.Sensitive, SymbolEnum.DIV, StateEnum.INIT);
            lexer.AddIdRule(6, "\"" + "^" + "\"", StringCaseComparison.Sensitive, SymbolEnum.POWER, StateEnum.INIT);
            lexer.AddIdAction(7, "/" + @"[0-9]+" + "/", StringCaseComparison.Sensitive, match => { match.Token = SymbolEnum.NUM;
                                                                                                   match.Value = Convert.ToDouble(match.Text); }, StateEnum.INIT);
            lexer.AddIdAction(8, "\"" + " " + "\"", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.AddIdAction(9, "\"" + "#" + "\"", StringCaseComparison.Sensitive, match => { lexer.PushState(StateEnum.COMMENT); }, StateEnum.INIT);
            lexer.AddIdAction(10, "/" + @"." + "/", StringCaseComparison.Sensitive, match => {}, StateEnum.COMMENT);
            lexer.AddIdRule(11, "/" + @"." + "/", StringCaseComparison.Sensitive, SymbolEnum.Error, StateEnum.INIT);
            lexer.EofAction = (TokenMatch <SymbolEnum> match) => match.Token = SymbolEnum.EOF;
            return(lexer);
        }
コード例 #5
0
        public NaiveLanguageTools.Lexer.Lexer <TokenEnum, StateEnum> CreateLexer()
        {
            var symbols_rep = StringRep.Create(Tuple.Create(TokenEnum.Error, "Error"),
                                               Tuple.Create(TokenEnum.EOF, "EOF"),
                                               Tuple.Create(TokenEnum.STR, "STR"),
                                               Tuple.Create(TokenEnum.LBRACE, "LBRACE"),
                                               Tuple.Create(TokenEnum.LPAREN, "LPAREN"),
                                               Tuple.Create(TokenEnum.RPAREN, "RPAREN"),
                                               Tuple.Create(TokenEnum.RBRACE, "RBRACE"),
                                               Tuple.Create(TokenEnum.EQ, "EQ"),
                                               Tuple.Create(TokenEnum.SEMI, "SEMI"),
                                               Tuple.Create(TokenEnum.COMMA, "COMMA"),
                                               Tuple.Create(TokenEnum.ID, "ID"),
                                               Tuple.Create(TokenEnum.proj, "proj"),
                                               Tuple.Create(TokenEnum.pair, "pair"),
                                               Tuple.Create(TokenEnum.dict, "dict"),
                                               Tuple.Create(TokenEnum.list, "list"),
                                               Tuple.Create(TokenEnum.id_list, "id_list"),
                                               Tuple.Create(TokenEnum.str_list, "str_list"),
                                               Tuple.Create(TokenEnum.dict_list, "dict_list"),
                                               Tuple.Create(TokenEnum.__list___merged_dict_pair____, "__list___merged_dict_pair____"),
                                               Tuple.Create(TokenEnum.__optList___merged_dict_pair____, "__optList___merged_dict_pair____"),
                                               Tuple.Create(TokenEnum.__list___merged_id_list_ID____, "__list___merged_id_list_ID____"),
                                               Tuple.Create(TokenEnum.__optList___merged_id_list_ID____, "__optList___merged_id_list_ID____"),
                                               Tuple.Create(TokenEnum.__list___merged_str_list_STR____, "__list___merged_str_list_STR____"),
                                               Tuple.Create(TokenEnum.__list___merged_dict_list_dict____, "__list___merged_dict_list_dict____"));
            var states_rep = StringRep.Create(Tuple.Create(StateEnum.INIT, "INIT"),
                                              Tuple.Create(StateEnum.STR, "STR"),
                                              Tuple.Create(StateEnum.COMMENT, "COMMENT"));
            var mre = new DfaTable(ConnectionTable.Create(0, new int [] { 6, 18, 18, 18, 18, 18, 18, 18, 18, 5, 2, 5, 5, 5, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 5, 18, 8, 18, 18, 18, 18, 18, 15, 14, 3, 18, 10, 18, 18, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 18, 11, 18, 12, 18, 18, 18, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 18, 7, 18, 18, 9, 18, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 18, 13, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, -1, -1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }),                                                                                                                                                       //0
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(0, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //1
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(14, false), Tuple.Create(20, false), Tuple.Create(26, false), Tuple.Create(28, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       //2
                                   ConnectionTable.Create(47, new int [] { 19 }, Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            //3
                                   ConnectionTable.Create(42, new int [] { 20, -1, -1, -1, -1, 21 }, Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //4
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(18, false), Tuple.Create(19, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       //5
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(17, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       //6
                                   ConnectionTable.Create(0, new int [] { 22, 30, 30, 30, 30, 30, 30, 30, 30, 30, 23, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 27, 30, 30, 30, 24, 30, 30, 30, 30, 30, 30, 30, 25, 30, 30, 30, 30, 30, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, -1, -1, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28 }, Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)), //7
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(8, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //8
                                   ConnectionTable.Create(48, new int [] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, -1, -1, -1, -1, -1, -1, -1, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, -1, -1, -1, -1, 31, -1, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, Tuple.Create(7, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            //9
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(6, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //10
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(5, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //11
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(4, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //12
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(3, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //13
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(2, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //14
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(1, false), Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //15
                                   ConnectionTable.Create(160, new int [] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //16
                                   ConnectionTable.Create(13, new int [] { 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 }),                                                                                                                                                                                                                                                                                                                               //17
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(18, false), Tuple.Create(25, false), Tuple.Create(27, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                //18
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(23, false), Tuple.Create(24, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         //19
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(22, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //20
                                   ConnectionTable.Create(0, new int [] { 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 35, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, -1, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }, Tuple.Create(21, false)),                                                   //21
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(15, false), Tuple.Create(16, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         //22
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(13, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //23
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(12, false), Tuple.Create(16, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         //24
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(11, false), Tuple.Create(16, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         //25
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(10, false), Tuple.Create(16, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         //26
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(9, false), Tuple.Create(16, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //27
                                   ConnectionTable.Create(160, new int [] { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //28
                                   ConnectionTable.Create(13, new int [] { 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }),                                                                                                                                                                                                                                                                                                                               //29
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(16, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //30
                                   ConnectionTable.Create(48, new int [] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, -1, -1, -1, -1, -1, -1, -1, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, -1, -1, -1, -1, 31, -1, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, Tuple.Create(7, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       //31
                                   ConnectionTable.Create(160, new int [] { 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //32
                                   ConnectionTable.Create(0, new int [] { 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 35, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, -1, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }, Tuple.Create(21, false)),                                                   //33
                                   ConnectionTable.Create(13, new int [] { 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }),                                                                                                                                                                                                                                                                                                                               //34
                                   ConnectionTable.Create(-1, new int [] {}, Tuple.Create(21, false)));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 //35
            var lexer = new NaiveLanguageTools.Lexer.Lexer <TokenEnum, StateEnum>(symbols_rep, states_rep, StateEnum.INIT, TokenEnum.EOF, TokenEnum.Error, mre);

            lexer.AddIdRule(0, "\"" + "{" + "\"", StringCaseComparison.Sensitive, TokenEnum.LBRACE, StateEnum.INIT);
            lexer.AddIdRule(1, "\"" + "(" + "\"", StringCaseComparison.Sensitive, TokenEnum.LPAREN, StateEnum.INIT);
            lexer.AddIdRule(2, "\"" + ")" + "\"", StringCaseComparison.Sensitive, TokenEnum.RPAREN, StateEnum.INIT);
            lexer.AddIdRule(3, "\"" + "}" + "\"", StringCaseComparison.Sensitive, TokenEnum.RBRACE, StateEnum.INIT);
            lexer.AddIdRule(4, "\"" + "=" + "\"", StringCaseComparison.Sensitive, TokenEnum.EQ, StateEnum.INIT);
            lexer.AddIdRule(5, "\"" + ";" + "\"", StringCaseComparison.Sensitive, TokenEnum.SEMI, StateEnum.INIT);
            lexer.AddIdRule(6, "\"" + "," + "\"", StringCaseComparison.Sensitive, TokenEnum.COMMA, StateEnum.INIT);
            lexer.AddIdRule(7, "/" + @"[A-Za-z_0-9]+" + "/", StringCaseComparison.Sensitive, TokenEnum.ID, StateEnum.INIT);
            lexer.AddIdAction(8, "\"" + "\"" + "\"", StringCaseComparison.Sensitive, match => { if (!string_error)
                                                                                                {
                                                                                                    validateString(match, false);
                                                                                                }
                                                                                                lexer.PopState(); }, StateEnum.STR);
            lexer.AddIdAction(9, "\"" + "\\b" + "\"", StringCaseComparison.Sensitive, match => { string_buf.Append("\b"); }, StateEnum.STR);
            lexer.AddIdAction(10, "\"" + "\\t" + "\"", StringCaseComparison.Sensitive, match => { string_buf.Append("\t"); }, StateEnum.STR);
            lexer.AddIdAction(11, "\"" + "\\n" + "\"", StringCaseComparison.Sensitive, match => { string_buf.Append("\n"); }, StateEnum.STR);
            lexer.AddIdAction(12, "\"" + "\\f" + "\"", StringCaseComparison.Sensitive, match => { string_buf.Append("\f"); }, StateEnum.STR);
            lexer.AddIdAction(13, "\"" + "\\\n" + "\"", StringCaseComparison.Sensitive, match => { string_buf.Append("\n"); }, StateEnum.STR);
            lexer.AddIdAction(14, "\"" + "\n" + "\"", StringCaseComparison.Sensitive, match => { if (!string_error)
                                                                                                 {
                                                                                                     validateString(match, true);
                                                                                                 }
                                                                                                 lexer.PopState(); }, StateEnum.STR);
            lexer.AddIdAction(15, "\"" + "\\\0" + "\"", StringCaseComparison.Sensitive, match => { if (!string_error)
                                                                                                   {
                                                                                                       string_error = true;
                                                                                                       match.Value  = "String contains escaped null character.";
                                                                                                       match.Token  = TokenEnum.Error;
                                                                                                   }
                              }, StateEnum.STR);
            lexer.AddIdAction(16, "/" + @"\\(.|\r)" + "/", StringCaseComparison.Sensitive, match => { string_buf.Append(match.Text.Substring(1)); }, StateEnum.STR);
            lexer.AddIdAction(17, "\"" + "\0" + "\"", StringCaseComparison.Sensitive, match => { if (!string_error)
                                                                                                 {
                                                                                                     string_error = true;
                                                                                                     match.Value  = "String contains null character.";
                                                                                                     match.Token  = TokenEnum.Error;
                                                                                                 }
                              }, StateEnum.STR);
            lexer.AddIdAction(18, "/" + @".|\r" + "/", StringCaseComparison.Sensitive, match => { string_buf.Append(match.Text); }, StateEnum.STR);
            lexer.AddIdAction(19, "/" + @"[ \f\r\t\u000b]" + "/", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.AddIdAction(20, "\"" + "\n" + "\"", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.AddIdAction(21, "/" + @"//(\r|.)*[\n]?" + "/", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.AddIdAction(22, "\"" + "/*" + "\"", StringCaseComparison.Sensitive, match => { lexer.PushState(StateEnum.COMMENT); }, StateEnum.INIT, StateEnum.COMMENT);
            lexer.AddIdAction(23, "\"" + "*/" + "\"", StringCaseComparison.Sensitive, match => { lexer.PopState(); }, StateEnum.COMMENT);
            lexer.AddIdAction(24, "\"" + "*/" + "\"", StringCaseComparison.Sensitive, match => { match.Value = "Unmatched */";
                                                                                                 match.Token = TokenEnum.Error; }, StateEnum.INIT);
            lexer.AddIdAction(25, "/" + @".|\r" + "/", StringCaseComparison.Sensitive, match => {}, StateEnum.COMMENT);
            lexer.AddIdAction(26, "\"" + "\n" + "\"", StringCaseComparison.Sensitive, match => {}, StateEnum.COMMENT);
            lexer.AddIdRule(27, "/" + @".|\r" + "/", StringCaseComparison.Sensitive, TokenEnum.Error, StateEnum.INIT);
            lexer.AddIdRule(28, "\"" + "\n" + "\"", StringCaseComparison.Sensitive, TokenEnum.Error, StateEnum.INIT);
            lexer.EofAction = match => { if (!lexer.IsValidEofState)
                                         {
                                             match.Value = "Invalid state at EOF";
                                             match.Token = TokenEnum.Error;
                                         }
                                         else
                                         {
                                             match.Token = TokenEnum.EOF;
                                         } };
            return(lexer);
        }
コード例 #6
0
        public NaiveLanguageTools.Lexer.Lexer <TokenEnum, StateEnum> CreateLexer()
        {
            var symbols_rep = StringRep.Create(Tuple.Create(TokenEnum.Error, "Error"),
                                               Tuple.Create(TokenEnum.EOF, "EOF"),
                                               Tuple.Create(TokenEnum.__term0, "__term0"),
                                               Tuple.Create(TokenEnum.__term1, "__term1"),
                                               Tuple.Create(TokenEnum.sin, "sin"),
                                               Tuple.Create(TokenEnum.cos, "cos"),
                                               Tuple.Create(TokenEnum.sqrt, "sqrt"),
                                               Tuple.Create(TokenEnum.pi, "pi"),
                                               Tuple.Create(TokenEnum.e, "e"),
                                               Tuple.Create(TokenEnum.PLUS, "PLUS"),
                                               Tuple.Create(TokenEnum.MINUS, "MINUS"),
                                               Tuple.Create(TokenEnum.MULT, "MULT"),
                                               Tuple.Create(TokenEnum.DIV, "DIV"),
                                               Tuple.Create(TokenEnum.POWER, "POWER"),
                                               Tuple.Create(TokenEnum.NUM, "NUM"),
                                               Tuple.Create(TokenEnum.s, "s"),
                                               Tuple.Create(TokenEnum.exp, "exp"));
            var states_rep = StringRep.Create(Tuple.Create(StateEnum.INIT, "INIT"));
            var mre        = new DfaTable(ConnectionTable.Create(0, new int [] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 1, 6, 7, 8, 4, 9, 4, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12, 4, 4, 4, 4, 13, 4, 14, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4, 4, 16, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }), //0
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(0, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //1
                                          ConnectionTable.Create(160, new int [] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //2
                                          ConnectionTable.Create(128, new int [] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //3
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //4
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(13, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 //5
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(1, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //6
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(9, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //7
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(7, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //8
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(8, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //9
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(10, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 //10
                                          ConnectionTable.Create(46, new int [] { 17, -1, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19 }, Tuple.Create(12, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 //11
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(11, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 //12
                                          ConnectionTable.Create(111, new int [] { 20 }, Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     //13
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(6, false), Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //14
                                          ConnectionTable.Create(105, new int [] { 21 }, Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     //15
                                          ConnectionTable.Create(105, new int [] { 23, -1, -1, -1, -1, -1, -1, -1, 22 }, Tuple.Create(14, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     //16
                                          ConnectionTable.Create(48, new int [] { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           //17
                                          ConnectionTable.Create(46, new int [] { 17, -1, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19 }, Tuple.Create(12, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //18
                                          ConnectionTable.Create(43, new int [] { 25, -1, 25, -1, -1, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       //19
                                          ConnectionTable.Create(115, new int [] { 27 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //20
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(5, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           //21
                                          ConnectionTable.Create(114, new int [] { 28 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //22
                                          ConnectionTable.Create(110, new int [] { 29 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //23
                                          ConnectionTable.Create(48, new int [] { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19 }, Tuple.Create(12, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //24
                                          ConnectionTable.Create(48, new int [] { 26, 26, 26, 26, 26, 26, 26, 26, 26, 26 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           //25
                                          ConnectionTable.Create(48, new int [] { 26, 26, 26, 26, 26, 26, 26, 26, 26, 26 }, Tuple.Create(12, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  //26
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(3, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           //27
                                          ConnectionTable.Create(116, new int [] { 30 }),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              //28
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(2, false)),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           //29
                                          ConnectionTable.Create(-1, new int [] {}, Tuple.Create(4, false)));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          //30
            var lexer = new NaiveLanguageTools.Lexer.Lexer <TokenEnum, StateEnum>(symbols_rep, states_rep, StateEnum.INIT, TokenEnum.EOF, TokenEnum.Error, mre);

            lexer.AddIdRule(0, "\"" + "(" + "\"", StringCaseComparison.Sensitive, TokenEnum.__term0, StateEnum.INIT);
            lexer.AddIdRule(1, "\"" + ")" + "\"", StringCaseComparison.Sensitive, TokenEnum.__term1, StateEnum.INIT);
            lexer.AddIdRule(2, "\"" + "sin" + "\"", StringCaseComparison.Sensitive, TokenEnum.sin, StateEnum.INIT);
            lexer.AddIdRule(3, "\"" + "cos" + "\"", StringCaseComparison.Sensitive, TokenEnum.cos, StateEnum.INIT);
            lexer.AddIdRule(4, "\"" + "sqrt" + "\"", StringCaseComparison.Sensitive, TokenEnum.sqrt, StateEnum.INIT);
            lexer.AddIdRule(5, "\"" + "pi" + "\"", StringCaseComparison.Sensitive, TokenEnum.pi, StateEnum.INIT);
            lexer.AddIdRule(6, "\"" + "e" + "\"", StringCaseComparison.Sensitive, TokenEnum.e, StateEnum.INIT);
            lexer.AddIdRule(7, "\"" + "+" + "\"", StringCaseComparison.Sensitive, TokenEnum.PLUS, StateEnum.INIT);
            lexer.AddIdRule(8, "\"" + "-" + "\"", StringCaseComparison.Sensitive, TokenEnum.MINUS, StateEnum.INIT);
            lexer.AddIdRule(9, "\"" + "*" + "\"", StringCaseComparison.Sensitive, TokenEnum.MULT, StateEnum.INIT);
            lexer.AddIdRule(10, "\"" + "/" + "\"", StringCaseComparison.Sensitive, TokenEnum.DIV, StateEnum.INIT);
            lexer.AddIdRule(11, "\"" + "^" + "\"", StringCaseComparison.Sensitive, TokenEnum.POWER, StateEnum.INIT);
            lexer.AddIdAction(12, "/" + @"[0-9]+(\.[0-9]+)?([Ee][\-+]?[0-9]+)?" + "/", StringCaseComparison.Sensitive, match => { match.Token = TokenEnum.NUM;
                                                                                                                                  match.Value = Convert.ToDouble(match.Text, System.Globalization.CultureInfo.InvariantCulture); }, StateEnum.INIT);
            lexer.AddIdAction(13, "\"" + " " + "\"", StringCaseComparison.Sensitive, match => {}, StateEnum.INIT);
            lexer.AddIdRule(14, "/" + @"." + "/", StringCaseComparison.Sensitive, TokenEnum.Error, StateEnum.INIT);
            lexer.EofAction = (TokenMatch <TokenEnum> match) => match.Token = TokenEnum.EOF;
            return(lexer);
        }