Significantly speed up the config lexer.

This commit is contained in:
Gunnar Beutner 2013-03-27 15:51:33 +01:00
parent c14aaf3d29
commit f1c57ce3a0
2 changed files with 142 additions and 152 deletions

View File

@ -379,30 +379,28 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[193] =
static yyconst flex_int16_t yy_accept[191] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 57, 55,
21, 21, 1, 55, 43, 55, 55, 55, 49, 55,
50, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 55, 18, 19, 12, 3, 2, 56, 15,
15, 21, 0, 0, 0, 43, 53, 51, 49, 52,
16, 20, 54, 0, 46, 47, 48, 0, 44, 43,
15, 0, 0, 0, 43, 53, 51, 49, 52, 16,
20, 54, 0, 46, 47, 48, 0, 44, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 0, 18, 17, 12, 11,
4, 5, 9, 10, 6, 8, 7, 0, 0, 0,
0, 20, 49, 45, 43, 28, 43, 43, 43, 43,
43, 43, 43, 43, 0, 17, 12, 11, 4, 5,
9, 10, 6, 8, 7, 0, 0, 0, 0, 20,
49, 45, 43, 28, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 13, 4, 5, 14, 0, 0, 0, 43,
43, 43, 43, 43, 43, 43, 43, 39, 43, 43,
43, 43, 43, 43, 41, 22, 4, 0, 0, 0,
43, 24, 43, 42, 43, 43, 43, 33, 43, 43,
43, 43, 43, 43, 0, 0, 0, 43, 43, 43,
43, 43, 25, 34, 43, 27, 26, 43, 0, 0,
0, 43, 43, 36, 43, 37, 40, 43, 0, 30,
0, 32, 43, 38, 35, 0, 0, 43, 31, 29,
23, 0
13, 4, 5, 14, 0, 0, 0, 43, 43, 43,
43, 43, 43, 43, 43, 39, 43, 43, 43, 43,
43, 43, 41, 22, 4, 0, 0, 0, 43, 24,
43, 42, 43, 43, 43, 33, 43, 43, 43, 43,
43, 43, 0, 0, 0, 43, 43, 43, 43, 43,
25, 34, 43, 27, 26, 43, 0, 0, 0, 43,
43, 36, 43, 37, 40, 43, 0, 30, 0, 32,
43, 38, 35, 0, 0, 43, 31, 29, 23, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@ -439,163 +437,155 @@ static yyconst flex_int32_t yy_ec[256] =
static yyconst flex_int32_t yy_meta[43] =
{ 0,
1, 1, 2, 3, 1, 4, 1, 5, 1, 1,
5, 5, 5, 1, 5, 1, 5, 3, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1, 1, 2, 3, 1, 4, 1, 4, 1, 1,
4, 4, 4, 1, 4, 1, 4, 3, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
1, 1
} ;
static yyconst flex_int16_t yy_base[202] =
static yyconst flex_int16_t yy_base[199] =
{ 0,
0, 0, 358, 357, 40, 42, 320, 319, 360, 365,
45, 47, 365, 32, 344, 343, 41, 49, 54, 341,
365, 341, 42, 54, 53, 39, 59, 60, 63, 70,
67, 72, 314, 0, 344, 0, 365, 365, 102, 365,
311, 90, 315, 328, 331, 334, 365, 365, 85, 365,
365, 0, 365, 88, 365, 312, 365, 331, 365, 87,
61, 90, 88, 91, 103, 112, 95, 113, 102, 116,
119, 120, 126, 121, 46, 305, 0, 365, 0, 365,
133, 135, 365, 365, 365, 365, 365, 303, 307, 309,
313, 0, 137, 365, 125, 326, 135, 137, 142, 143,
0, 0, 340, 339, 40, 42, 302, 301, 342, 347,
347, 347, 347, 28, 326, 325, 37, 44, 44, 323,
347, 323, 42, 49, 46, 51, 54, 53, 63, 56,
64, 69, 296, 347, 326, 0, 347, 347, 99, 347,
293, 297, 310, 313, 316, 347, 347, 86, 347, 347,
0, 347, 76, 347, 294, 347, 313, 347, 36, 74,
78, 75, 79, 100, 85, 103, 102, 92, 110, 84,
112, 113, 91, 118, 287, 347, 0, 347, 126, 128,
347, 347, 347, 347, 347, 285, 289, 291, 295, 0,
130, 347, 120, 308, 129, 131, 134, 135, 138, 137,
138, 145, 149, 150, 151, 154, 155, 160, 161, 166,
167, 168, 365, 173, 175, 365, 305, 301, 311, 178,
179, 180, 181, 182, 183, 186, 185, 322, 187, 188,
196, 193, 191, 200, 321, 320, 205, 307, 306, 310,
206, 316, 209, 315, 211, 212, 213, 311, 215, 216,
217, 219, 220, 223, 297, 281, 294, 222, 225, 229,
231, 232, 271, 270, 234, 269, 268, 236, 244, 258,
241, 240, 242, 261, 243, 260, 259, 244, 234, 365,
238, 254, 245, 251, 250, 241, 84, 247, 365, 365,
93, 365, 287, 292, 297, 299, 304, 309, 314, 319,
139, 140, 147, 148, 144, 150, 158, 159, 160, 161,
347, 166, 175, 347, 287, 283, 293, 165, 167, 174,
173, 175, 176, 178, 179, 304, 180, 183, 187, 190,
184, 191, 303, 302, 205, 289, 288, 292, 203, 298,
195, 297, 197, 206, 208, 296, 209, 210, 211, 213,
214, 216, 290, 272, 281, 217, 219, 222, 221, 225,
284, 265, 226, 264, 263, 227, 239, 253, 238, 231,
234, 258, 236, 256, 255, 237, 232, 347, 235, 251,
239, 248, 247, 238, 224, 241, 347, 347, 242, 347,
281, 285, 289, 98, 293, 297, 301, 305
324
} ;
static yyconst flex_int16_t yy_def[202] =
static yyconst flex_int16_t yy_def[199] =
{ 0,
192, 1, 193, 193, 194, 194, 195, 195, 192, 192,
192, 192, 192, 192, 196, 192, 192, 192, 192, 197,
192, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 192, 198, 192, 199, 192, 192, 200, 192,
192, 192, 192, 192, 192, 196, 192, 192, 192, 192,
192, 201, 192, 192, 192, 192, 192, 197, 192, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 192, 198, 192, 199, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 201, 192, 192, 196, 196, 196, 196, 196, 196,
190, 1, 191, 191, 192, 192, 193, 193, 190, 190,
190, 190, 190, 190, 194, 190, 190, 190, 190, 195,
190, 194, 194, 194, 194, 194, 194, 194, 194, 194,
194, 194, 190, 190, 190, 196, 190, 190, 197, 190,
190, 190, 190, 190, 194, 190, 190, 190, 190, 190,
198, 190, 190, 190, 190, 190, 195, 190, 194, 194,
194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
194, 194, 194, 194, 190, 190, 196, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 198,
190, 190, 194, 194, 194, 194, 194, 194, 194, 194,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 192, 192, 192, 192, 192, 192, 192, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 192, 192, 192, 192,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 192, 192, 192, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 192, 192,
192, 196, 196, 196, 196, 196, 196, 196, 192, 192,
192, 196, 196, 196, 196, 192, 192, 196, 192, 192,
196, 0, 192, 192, 192, 192, 192, 192, 192, 192,
194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
190, 190, 190, 190, 190, 190, 190, 194, 194, 194,
194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
194, 194, 194, 194, 190, 190, 190, 190, 194, 194,
194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
194, 194, 190, 190, 190, 194, 194, 194, 194, 194,
194, 194, 194, 194, 194, 194, 190, 190, 190, 194,
194, 194, 194, 194, 194, 194, 190, 190, 190, 194,
194, 194, 194, 190, 190, 194, 190, 190, 194, 0,
190, 190, 190, 190, 190, 190, 190, 190
192
} ;
static yyconst flex_int16_t yy_nxt[408] =
static yyconst flex_int16_t yy_nxt[390] =
{ 0,
10, 11, 12, 13, 14, 15, 16, 17, 10, 18,
19, 19, 10, 20, 21, 10, 22, 10, 23, 22,
22, 24, 22, 25, 22, 22, 26, 22, 27, 22,
28, 29, 30, 22, 22, 31, 32, 22, 22, 22,
33, 10, 37, 38, 37, 38, 42, 42, 42, 42,
43, 49, 49, 192, 51, 50, 192, 39, 52, 39,
192, 60, 54, 53, 49, 49, 44, 192, 192, 65,
45, 64, 61, 192, 192, 192, 62, 192, 112, 55,
63, 192, 69, 56, 192, 66, 192, 71, 70, 57,
67, 42, 42, 54, 73, 49, 49, 68, 93, 93,
33, 10, 37, 38, 37, 38, 42, 48, 48, 50,
190, 49, 53, 51, 48, 48, 190, 39, 52, 39,
190, 59, 43, 190, 63, 190, 44, 190, 190, 54,
190, 93, 60, 55, 69, 62, 61, 190, 190, 56,
65, 64, 68, 190, 70, 66, 91, 91, 190, 190,
67, 72, 190, 190, 53, 96, 48, 48, 190, 190,
96, 192, 192, 72, 192, 192, 74, 192, 98, 192,
55, 75, 81, 82, 56, 103, 192, 192, 190, 99,
57, 83, 95, 100, 97, 84, 192, 192, 101, 106,
192, 102, 85, 192, 192, 192, 86, 108, 87, 192,
192, 104, 105, 114, 115, 115, 115, 93, 93, 192,
107, 192, 192, 121, 109, 110, 192, 192, 111, 192,
125, 120, 55, 192, 192, 192, 56, 127, 192, 192,
129, 124, 57, 122, 192, 192, 130, 123, 128, 126,
192, 192, 192, 137, 115, 115, 115, 133, 132, 135,
136, 131, 192, 192, 192, 192, 192, 192, 134, 192,
71, 45, 106, 73, 100, 190, 190, 97, 74, 79,
80, 54, 95, 94, 190, 55, 190, 190, 81, 104,
98, 56, 82, 101, 190, 99, 190, 190, 109, 83,
102, 103, 190, 84, 190, 85, 112, 113, 113, 113,
91, 91, 108, 190, 105, 190, 107, 119, 190, 190,
110, 190, 190, 190, 190, 54, 118, 125, 190, 55,
123, 190, 190, 122, 190, 56, 127, 120, 126, 121,
128, 124, 190, 190, 190, 190, 135, 113, 130, 190,
129, 190, 133, 134, 131, 113, 113, 190, 190, 190,
190, 132, 190, 190, 190, 142, 145, 190, 190, 139,
192, 192, 192, 144, 147, 192, 143, 192, 150, 149,
192, 152, 141, 148, 192, 115, 115, 146, 142, 145,
192, 153, 151, 192, 158, 192, 192, 192, 154, 192,
192, 192, 160, 192, 192, 165, 192, 192, 161, 192,
159, 168, 172, 192, 167, 192, 192, 162, 192, 163,
192, 174, 164, 166, 192, 173, 192, 192, 192, 192,
183, 192, 177, 189, 192, 192, 185, 175, 192, 187,
186, 176, 178, 192, 192, 192, 182, 181, 184, 188,
180, 179, 192, 192, 192, 192, 191, 34, 34, 34,
34, 34, 36, 36, 36, 36, 36, 40, 40, 40,
141, 190, 147, 148, 190, 190, 140, 146, 150, 190,
144, 190, 143, 149, 151, 113, 113, 190, 158, 152,
190, 156, 190, 190, 190, 190, 157, 190, 190, 163,
190, 190, 159, 190, 166, 190, 190, 170, 165, 190,
190, 190, 160, 161, 172, 190, 162, 164, 190, 171,
190, 190, 181, 190, 175, 190, 190, 173, 188, 183,
187, 190, 190, 176, 174, 190, 185, 180, 184, 190,
190, 182, 190, 186, 179, 178, 177, 190, 190, 190,
189, 34, 34, 34, 34, 36, 36, 36, 36, 40,
40, 40, 40, 57, 57, 57, 57, 77, 190, 169,
40, 40, 46, 46, 58, 58, 58, 58, 58, 77,
77, 77, 171, 77, 79, 170, 169, 79, 79, 80,
80, 80, 80, 80, 92, 192, 92, 92, 92, 192,
192, 157, 156, 155, 192, 192, 192, 140, 139, 138,
192, 119, 118, 117, 116, 113, 59, 94, 192, 91,
90, 89, 88, 78, 76, 192, 59, 48, 47, 192,
41, 41, 35, 35, 9, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192
77, 78, 78, 78, 78, 90, 168, 90, 90, 167,
190, 190, 190, 155, 154, 153, 190, 190, 190, 138,
137, 136, 190, 117, 116, 115, 114, 111, 58, 92,
190, 89, 88, 87, 86, 76, 75, 190, 58, 47,
46, 190, 41, 41, 35, 35, 9, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190
} ;
static yyconst flex_int16_t yy_chk[408] =
static yyconst flex_int16_t yy_chk[390] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 5, 5, 6, 6, 11, 11, 12, 12,
14, 17, 17, 26, 18, 17, 23, 5, 18, 6,
75, 23, 19, 18, 19, 19, 14, 25, 24, 26,
14, 25, 23, 27, 28, 61, 23, 29, 75, 19,
24, 31, 29, 19, 30, 27, 32, 31, 30, 19,
27, 42, 42, 49, 32, 49, 49, 28, 54, 54,
1, 1, 5, 5, 6, 6, 14, 17, 17, 18,
59, 17, 19, 18, 19, 19, 23, 5, 18, 6,
25, 23, 14, 24, 25, 26, 14, 28, 27, 19,
30, 59, 23, 19, 30, 24, 23, 29, 31, 19,
27, 26, 29, 32, 31, 27, 53, 53, 60, 62,
28, 32, 61, 63, 48, 62, 48, 48, 70, 65,
61, 60, 63, 31, 62, 64, 32, 191, 63, 67,
49, 32, 39, 39, 49, 67, 69, 65, 187, 64,
49, 39, 60, 65, 62, 39, 66, 68, 65, 69,
70, 66, 39, 71, 72, 74, 39, 71, 39, 95,
73, 68, 68, 81, 81, 82, 82, 93, 93, 97,
70, 98, 101, 97, 72, 73, 99, 100, 74, 102,
101, 95, 93, 103, 104, 105, 93, 103, 106, 107,
105, 100, 93, 98, 108, 109, 106, 99, 104, 102,
110, 111, 112, 114, 114, 115, 115, 109, 108, 111,
112, 107, 120, 121, 122, 123, 124, 125, 110, 127,
31, 194, 70, 32, 65, 73, 68, 63, 32, 39,
39, 48, 61, 60, 64, 48, 67, 66, 39, 68,
64, 48, 39, 66, 69, 64, 71, 72, 73, 39,
67, 67, 74, 39, 93, 39, 79, 79, 80, 80,
91, 91, 72, 95, 69, 96, 71, 95, 97, 98,
74, 100, 99, 101, 102, 91, 93, 101, 105, 91,
99, 103, 104, 98, 106, 91, 103, 96, 102, 97,
104, 100, 107, 108, 109, 110, 112, 112, 106, 118,
105, 119, 109, 110, 107, 113, 113, 121, 120, 122,
123, 108, 124, 125, 127, 121, 124, 128, 131, 118,
126, 129, 130, 123, 126, 133, 122, 132, 130, 129,
131, 132, 120, 127, 134, 137, 137, 125, 121, 124,
141, 133, 131, 143, 141, 145, 146, 147, 134, 149,
150, 151, 145, 152, 153, 151, 158, 154, 146, 159,
143, 154, 158, 160, 153, 161, 162, 147, 165, 149,
168, 160, 150, 152, 172, 159, 173, 175, 178, 183,
173, 188, 165, 186, 185, 184, 178, 161, 182, 181,
179, 162, 168, 177, 176, 174, 172, 171, 175, 183,
170, 169, 167, 166, 164, 163, 188, 193, 193, 193,
193, 193, 194, 194, 194, 194, 194, 195, 195, 195,
120, 129, 127, 128, 130, 132, 119, 125, 130, 141,
123, 143, 122, 129, 131, 135, 135, 139, 143, 132,
144, 139, 145, 147, 148, 149, 141, 150, 151, 149,
152, 156, 144, 157, 152, 159, 158, 156, 151, 160,
163, 166, 145, 147, 158, 170, 148, 150, 171, 157,
173, 176, 171, 181, 163, 186, 189, 159, 185, 176,
184, 183, 182, 166, 160, 180, 179, 170, 177, 175,
174, 173, 172, 181, 169, 168, 167, 165, 164, 162,
186, 191, 191, 191, 191, 192, 192, 192, 192, 193,
193, 193, 193, 195, 195, 195, 195, 196, 161, 155,
195, 195, 196, 196, 197, 197, 197, 197, 197, 198,
198, 198, 157, 198, 199, 156, 155, 199, 199, 200,
200, 200, 200, 200, 201, 148, 201, 201, 201, 144,
142, 140, 139, 138, 136, 135, 128, 119, 118, 117,
96, 91, 90, 89, 88, 76, 58, 56, 46, 45,
44, 43, 41, 35, 33, 22, 20, 16, 15, 9,
8, 7, 4, 3, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192
196, 197, 197, 197, 197, 198, 154, 198, 198, 153,
146, 142, 140, 138, 137, 136, 134, 133, 126, 117,
116, 115, 94, 89, 88, 87, 86, 75, 57, 55,
45, 44, 43, 42, 41, 35, 33, 22, 20, 16,
15, 9, 8, 7, 4, 3, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 190, 190, 190, 190, 190
} ;
/* Table of booleans, true if rule could match eol. */
@ -705,7 +695,7 @@ static void lb_append_char(lex_buf *lb, char new_char)
#line 709 "config_lexer.cc"
#line 699 "config_lexer.cc"
#define INITIAL 0
#define C_COMMENT 1
@ -962,7 +952,7 @@ YY_DECL
lex_buf string_buf;
#line 966 "config_lexer.cc"
#line 956 "config_lexer.cc"
yylval = yylval_param;
@ -1019,13 +1009,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 193 )
if ( yy_current_state >= 191 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 192 );
while ( yy_current_state != 190 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1396,7 +1386,7 @@ YY_RULE_SETUP
#line 225 "config_lexer.ll"
ECHO;
YY_BREAK
#line 1400 "config_lexer.cc"
#line 1390 "config_lexer.cc"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(C_COMMENT):
case YY_STATE_EOF(STRING):
@ -1694,7 +1684,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 193 )
if ( yy_current_state >= 191 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1723,11 +1713,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 193 )
if ( yy_current_state >= 191 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 192);
yy_is_jam = (yy_current_state == 190);
return yy_is_jam ? 0 : yy_current_state;
}

View File

@ -177,12 +177,12 @@ static void lb_append_char(lex_buf *lb, char new_char)
<C_COMMENT>{
"*/" BEGIN(INITIAL);
[^*]+ /* ignore comment */
[^*] /* ignore comment */
"*" /* ignore star */
}
\/\/[^\n]* /* ignore C++-style comments */
[ \t\r\n]+ /* ignore whitespace */
[ \t\r\n] /* ignore whitespace */
<INITIAL>{
type return T_TYPE;