diff options
Diffstat (limited to '')
-rw-r--r-- | lib/scanner.c (renamed from scanner.c) | 690 |
1 files changed, 343 insertions, 347 deletions
diff --git a/scanner.c b/lib/scanner.c index f903514..c2eb7d1 100644 --- a/scanner.c +++ b/lib/scanner.c @@ -54,7 +54,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,7 +159,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -360,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 26 -#define YY_END_OF_BUFFER 27 +#define YY_NUM_RULES 41 +#define YY_END_OF_BUFFER 42 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -369,39 +378,38 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[117] = +static yyconst flex_int16_t yy_accept[103] = { 0, - 0, 0, 0, 0, 27, 25, 5, 5, 25, 25, - 21, 22, 12, 25, 7, 13, 25, 14, 14, 6, - 23, 12, 12, 19, 20, 8, 9, 3, 4, 3, - 5, 0, 18, 0, 0, 24, 12, 13, 14, 13, - 0, 1, 0, 13, 0, 15, 0, 12, 12, 2, - 0, 0, 0, 0, 0, 13, 13, 0, 0, 13, - 15, 16, 12, 12, 0, 18, 0, 0, 0, 0, - 0, 13, 17, 12, 10, 0, 0, 17, 11, 0, - 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, - - 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, - 0, 18, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 42, 40, + 21, 20, 20, 5, 40, 36, 37, 28, 40, 23, + 29, 40, 30, 30, 22, 38, 28, 28, 34, 35, + 24, 25, 21, 40, 3, 4, 3, 6, 14, 41, + 16, 19, 41, 21, 0, 39, 28, 29, 30, 29, + 0, 1, 0, 29, 0, 31, 0, 28, 28, 21, + 0, 0, 2, 6, 12, 0, 11, 10, 7, 8, + 9, 16, 18, 17, 0, 29, 29, 0, 0, 29, + 31, 32, 28, 28, 0, 0, 0, 29, 33, 28, + 26, 0, 13, 33, 27, 0, 0, 0, 0, 0, + + 15, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 5, 1, 1, 1, 1, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 16, 17, 1, - 18, 1, 1, 1, 19, 20, 20, 20, 21, 22, - 23, 23, 23, 23, 23, 24, 23, 23, 23, 23, - 23, 25, 26, 27, 28, 23, 23, 29, 23, 23, - 30, 31, 32, 1, 33, 1, 19, 20, 20, 20, - - 21, 22, 23, 23, 23, 23, 23, 34, 23, 23, - 23, 23, 23, 25, 26, 27, 28, 23, 23, 29, - 23, 23, 35, 1, 36, 1, 1, 1, 1, 1, + 1, 2, 1, 6, 7, 1, 1, 1, 1, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 18, 19, 1, + 20, 1, 1, 21, 22, 23, 23, 23, 24, 25, + 26, 26, 26, 26, 26, 27, 26, 26, 26, 26, + 26, 28, 29, 30, 31, 26, 26, 32, 26, 26, + 33, 34, 35, 1, 36, 1, 22, 23, 37, 38, + + 39, 40, 26, 26, 41, 26, 26, 42, 26, 43, + 26, 26, 26, 44, 29, 45, 46, 26, 26, 32, + 26, 26, 47, 1, 48, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -418,181 +426,119 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[37] = +static yyconst flex_int32_t yy_meta[49] = { 0, - 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, - 2, 1, 1, 3, 3, 1, 1, 1, 3, 3, - 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, - 1, 1, 2, 2, 1, 1 + 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, + 1, 1, 3, 1, 1, 4, 4, 1, 1, 1, + 1, 4, 4, 4, 4, 3, 3, 3, 3, 3, + 3, 3, 1, 2, 1, 3, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 3, 1, 1 } ; -static yyconst flex_int16_t yy_base[128] = +static yyconst flex_int16_t yy_base[113] = { 0, - 0, 0, 34, 35, 199, 503, 37, 42, 37, 195, - 503, 503, 0, 34, 503, 36, 39, 57, 41, 503, - 503, 163, 150, 503, 503, 503, 503, 503, 503, 152, - 56, 56, 71, 160, 151, 503, 0, 49, 68, 76, - 84, 503, 150, 86, 94, 128, 0, 43, 118, 503, - 108, 57, 125, 106, 101, 103, 108, 116, 118, 120, - 503, 102, 98, 99, 75, 134, 101, 99, 138, 88, - 130, 134, 70, 64, 0, 58, 142, 503, 0, 154, - 166, 156, 158, 164, 172, 202, 177, 170, 180, 181, - 178, 214, 244, 256, 286, 189, 220, 316, 328, 192, - - 206, 218, 231, 340, 262, 222, 264, 229, 352, 382, - 412, 442, 270, 294, 358, 503, 473, 476, 479, 481, - 51, 484, 487, 490, 493, 496, 499 + 0, 47, 47, 48, 46, 47, 48, 49, 203, 204, + 200, 204, 204, 204, 198, 204, 204, 0, 45, 204, + 47, 50, 60, 74, 204, 204, 178, 28, 204, 204, + 204, 204, 64, 158, 204, 204, 183, 0, 204, 63, + 0, 204, 83, 195, 193, 204, 0, 88, 102, 98, + 62, 204, 190, 104, 119, 162, 0, 67, 65, 121, + 127, 124, 204, 0, 204, 0, 204, 204, 204, 204, + 204, 0, 204, 204, 108, 117, 122, 134, 132, 136, + 204, 139, 136, 116, 126, 0, 140, 142, 135, 130, + 0, 102, 204, 204, 0, 85, 72, 63, 98, 158, + + 204, 204, 169, 173, 177, 181, 183, 187, 191, 89, + 66, 63 } ; -static yyconst flex_int16_t yy_def[128] = +static yyconst flex_int16_t yy_def[113] = { 0, - 116, 1, 117, 117, 116, 116, 116, 116, 118, 119, - 116, 116, 120, 116, 116, 116, 116, 116, 116, 116, - 116, 120, 120, 116, 116, 116, 116, 116, 116, 116, - 116, 118, 116, 118, 119, 116, 120, 116, 116, 116, - 116, 116, 119, 116, 116, 116, 121, 120, 120, 116, - 116, 122, 123, 116, 116, 116, 116, 116, 116, 116, - 116, 121, 120, 120, 122, 116, 122, 123, 116, 124, - 116, 116, 116, 120, 120, 124, 124, 116, 120, 124, - 124, 125, 126, 124, 125, 124, 125, 125, 126, 126, - 124, 125, 126, 125, 125, 127, 125, 126, 124, 127, - - 126, 126, 127, 126, 127, 127, 125, 126, 127, 127, - 125, 127, 127, 127, 127, 0, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116 + 102, 1, 103, 103, 104, 104, 105, 105, 102, 102, + 102, 102, 102, 102, 106, 102, 102, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 107, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 108, 102, 102, + 109, 102, 102, 102, 106, 102, 107, 102, 102, 102, + 102, 102, 106, 102, 102, 102, 110, 107, 107, 102, + 102, 102, 102, 108, 102, 111, 102, 102, 102, 102, + 102, 109, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 110, 107, 107, 102, 112, 102, 102, 102, 107, + 107, 102, 102, 102, 107, 102, 102, 102, 102, 102, + + 102, 0, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 } ; -static yyconst flex_int16_t yy_nxt[540] = +static yyconst flex_int16_t yy_nxt[253] = { 0, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 16, 17, 18, 19, 20, 21, 20, 13, 13, - 13, 22, 13, 13, 13, 13, 23, 13, 13, 24, - 6, 25, 6, 13, 26, 27, 29, 29, 31, 31, - 33, 30, 30, 31, 31, 38, 42, 39, 39, 40, - 40, 43, 44, 62, 39, 39, 41, 31, 31, 33, - 66, 45, 40, 40, 46, 77, 63, 34, 44, 41, - 39, 39, 51, 51, 52, 53, 63, 45, 66, 44, - 46, 39, 39, 54, 79, 47, 34, 67, 45, 40, - 40, 46, 55, 78, 55, 77, 41, 56, 56, 57, - - 57, 69, 59, 116, 59, 67, 58, 60, 60, 51, - 51, 52, 53, 70, 56, 56, 56, 56, 53, 75, - 54, 57, 57, 74, 71, 73, 71, 69, 58, 72, - 72, 60, 60, 60, 60, 51, 51, 52, 53, 51, - 51, 52, 53, 72, 72, 64, 54, 72, 72, 77, - 54, 61, 36, 36, 80, 81, 81, 82, 83, 86, - 80, 77, 116, 87, 50, 90, 84, 81, 81, 82, - 83, 91, 76, 77, 49, 86, 83, 87, 84, 87, - 86, 48, 80, 80, 87, 77, 88, 90, 90, 92, - 80, 92, 104, 93, 92, 104, 105, 36, 116, 105, - - 116, 116, 88, 81, 81, 82, 83, 88, 80, 77, - 116, 116, 116, 90, 84, 94, 94, 95, 96, 106, - 80, 87, 106, 86, 80, 108, 97, 107, 116, 105, - 101, 80, 96, 92, 104, 116, 90, 116, 105, 116, - 116, 93, 116, 116, 88, 98, 99, 100, 101, 116, - 88, 90, 116, 116, 116, 116, 102, 94, 94, 95, - 96, 106, 116, 87, 92, 104, 116, 86, 97, 105, - 116, 87, 92, 104, 109, 116, 92, 105, 116, 116, - 116, 116, 116, 116, 116, 116, 88, 94, 94, 95, - 96, 116, 106, 87, 88, 116, 92, 104, 97, 116, - - 106, 115, 116, 116, 116, 116, 113, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 88, 98, 99, 100, - 101, 116, 116, 90, 106, 116, 116, 116, 102, 81, - 81, 82, 83, 116, 116, 77, 116, 116, 116, 116, - 84, 98, 99, 100, 101, 116, 116, 90, 116, 116, - 116, 116, 102, 110, 111, 112, 113, 116, 116, 105, - 92, 104, 116, 116, 114, 105, 116, 116, 116, 116, - 109, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 106, 110, 111, 112, 113, 116, 106, 105, - 116, 116, 116, 116, 114, 116, 116, 116, 116, 116, - - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 106, 94, 94, 95, 96, 116, 116, 87, - 116, 116, 116, 116, 97, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 88, 110, 111, 112, 113, 116, 116, 105, - 116, 116, 116, 116, 114, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 106, 28, 28, 28, 32, 32, 32, 35, - 35, 35, 37, 37, 65, 65, 65, 68, 68, 68, - 76, 76, 76, 85, 85, 85, 89, 89, 89, 103, - - 103, 103, 5, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116 + 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, + 19, 20, 19, 21, 22, 23, 24, 25, 26, 25, + 10, 18, 18, 18, 27, 18, 18, 18, 18, 28, + 18, 18, 29, 10, 30, 10, 18, 18, 18, 27, + 18, 18, 18, 18, 28, 18, 31, 32, 33, 36, + 36, 39, 39, 42, 42, 59, 37, 37, 48, 52, + 49, 49, 50, 50, 53, 60, 93, 34, 65, 86, + 51, 59, 75, 54, 75, 49, 49, 76, 76, 40, + 40, 43, 43, 55, 61, 51, 56, 54, 73, 49, + 49, 57, 82, 83, 66, 84, 67, 55, 55, 100, + + 56, 99, 68, 50, 50, 69, 70, 71, 83, 98, + 84, 51, 55, 50, 50, 54, 74, 49, 49, 77, + 77, 51, 60, 76, 76, 55, 51, 78, 56, 79, + 97, 79, 76, 76, 80, 80, 51, 77, 77, 91, + 55, 61, 78, 96, 87, 78, 87, 80, 80, 88, + 88, 80, 80, 95, 91, 88, 88, 88, 88, 100, + 78, 94, 92, 101, 90, 89, 85, 62, 95, 35, + 35, 35, 35, 38, 38, 38, 38, 41, 41, 41, + 41, 45, 45, 45, 45, 47, 47, 64, 81, 64, + 64, 72, 46, 72, 72, 46, 44, 63, 62, 58, + + 46, 44, 102, 9, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 } ; -static yyconst flex_int16_t yy_chk[540] = +static yyconst flex_int16_t yy_chk[253] = { 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, 3, 4, 7, 7, - 9, 3, 4, 8, 8, 14, 17, 14, 14, 16, - 16, 17, 19, 121, 19, 19, 16, 31, 31, 32, - 52, 19, 38, 38, 19, 76, 48, 9, 18, 38, - 18, 18, 33, 33, 33, 33, 48, 18, 65, 39, - 18, 39, 39, 33, 74, 18, 32, 52, 39, 40, - 40, 39, 41, 73, 41, 70, 40, 41, 41, 44, - - 44, 68, 45, 67, 45, 65, 44, 45, 45, 51, - 51, 51, 51, 54, 55, 55, 56, 56, 54, 64, - 51, 57, 57, 63, 58, 62, 58, 53, 57, 58, - 58, 59, 59, 60, 60, 66, 66, 66, 66, 69, - 69, 69, 69, 71, 71, 49, 66, 72, 72, 77, - 69, 46, 43, 35, 77, 80, 80, 80, 80, 82, - 83, 80, 34, 82, 30, 83, 80, 81, 81, 81, - 81, 84, 88, 81, 23, 85, 84, 88, 81, 85, - 87, 22, 89, 90, 87, 91, 82, 89, 90, 87, - 91, 96, 96, 90, 100, 100, 96, 10, 5, 100, - - 0, 0, 85, 86, 86, 86, 86, 87, 101, 86, - 0, 0, 0, 101, 86, 92, 92, 92, 92, 96, - 102, 92, 100, 97, 106, 102, 92, 97, 0, 106, - 102, 108, 97, 103, 103, 0, 108, 0, 103, 0, - 0, 108, 0, 0, 92, 93, 93, 93, 93, 0, - 97, 93, 0, 0, 0, 0, 93, 94, 94, 94, - 94, 103, 0, 94, 105, 105, 0, 107, 94, 105, - 0, 107, 113, 113, 105, 0, 107, 113, 0, 0, - 0, 0, 0, 0, 0, 0, 94, 95, 95, 95, - 95, 0, 105, 95, 107, 0, 114, 114, 95, 0, - - 113, 114, 0, 0, 0, 0, 114, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 95, 98, 98, 98, - 98, 0, 0, 98, 114, 0, 0, 0, 98, 99, - 99, 99, 99, 0, 0, 99, 0, 0, 0, 0, - 99, 104, 104, 104, 104, 0, 0, 104, 0, 0, - 0, 0, 104, 109, 109, 109, 109, 0, 0, 109, - 115, 115, 0, 0, 109, 115, 0, 0, 0, 0, - 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 109, 110, 110, 110, 110, 0, 115, 110, - 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 110, 111, 111, 111, 111, 0, 0, 111, - 0, 0, 0, 0, 111, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 111, 112, 112, 112, 112, 0, 0, 112, - 0, 0, 0, 0, 112, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 112, 117, 117, 117, 118, 118, 118, 119, - 119, 119, 120, 120, 122, 122, 122, 123, 123, 123, - 124, 124, 124, 125, 125, 125, 126, 126, 126, 127, - - 127, 127, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 5, 6, 7, 8, 28, 3, 4, 19, 22, + 19, 19, 21, 21, 22, 33, 112, 2, 40, 111, + 21, 28, 51, 23, 51, 23, 23, 51, 51, 5, + 6, 7, 8, 23, 33, 21, 23, 24, 43, 24, + 24, 23, 110, 58, 40, 59, 40, 24, 23, 99, + + 24, 98, 40, 48, 48, 40, 40, 40, 58, 97, + 59, 48, 24, 50, 50, 49, 43, 49, 49, 54, + 54, 50, 60, 75, 75, 49, 48, 54, 49, 55, + 96, 55, 76, 76, 55, 55, 50, 77, 77, 84, + 49, 60, 54, 92, 78, 77, 78, 79, 79, 78, + 78, 80, 80, 90, 84, 87, 87, 88, 88, 100, + 77, 89, 85, 100, 83, 82, 62, 61, 90, 103, + 103, 103, 103, 104, 104, 104, 104, 105, 105, 105, + 105, 106, 106, 106, 106, 107, 107, 108, 56, 108, + 108, 109, 53, 109, 109, 45, 44, 37, 34, 27, + + 15, 11, 9, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[27] = +static yyconst flex_int32_t yy_rule_can_match_eol[42] = { 0, -0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, }; +0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -605,7 +551,7 @@ static yyconst flex_int32_t yy_rule_can_match_eol[27] = /* -*- mode: C -*- */ /* -------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. @@ -624,10 +570,8 @@ static yyconst flex_int32_t yy_rule_can_match_eol[27] = <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- */ -#line 25 "scanner.l" -#define YY_EXTRA_TYPE void* #define YY_NO_UNISTD_H 1 -#line 38 "scanner.l" +#line 35 "scanner.l" #ifdef _MSC_VER #pragma warning (disable: 4996) @@ -638,98 +582,18 @@ static yyconst flex_int32_t yy_rule_can_match_eol[27] = #include <string.h> #include "grammar.h" #include "wincompat.h" +#include "parsectx.h" +#include "scanctx.h" -/* this is somewhat kludgy, but I wanted to avoid building strings - dynamically during scanning */ - -static char *make_string(char *s) -{ - char *r = ++s; - char *p, *q = r; - size_t len = strlen(r); - int esc = 0; - - *(r + --len) = 0; - - for(p = r; *p; p++) - { - if(*p == '\\') - { - if(! esc) - { - esc = 1; - continue; - } - } - - if(esc) - { - if(*p == 'n') - *(q++) = '\n'; - else if(*p == 'r') - *(q++) = '\r'; - else if(*p == 'f') - *(q++) = '\f'; - else if(*p == 't') - *(q++) = '\t'; - else - *(q++) = *p; - - esc = 0; - } - - else if(*p == '\"') /* if we reached the end of a string segment, ... */ - { - /* This construction allows for C-style string concatenation. - We don't bother to check for end-of-string here, as we depend - on the {string} definition to ensure a new opening quote exists. - We do, however, check for and discard all forms of comments - [that is, (#...$|//...$|[/][*]...[*][/])] between string segments. */ - - while (*++p != '\"') /* ... look for the start of the next segment */ - { - if(*p == '#') /* check for #...$ comment */ - { - while(*++p != '\n') - { - /* skip the rest of the line */ - } - } - else if (*p == '/') - { - if(*++p == '/') /* check for //...$ comment */ - { - while (*++p != '\n') - { - /* skip the rest of the line */ - } - } - else /* must be '*', lead-in to an old C-style comment */ - { - while (*++p != '*' || *(p+1) != '/') - { - /* skip all comment content */ - } - ++p; /* step to the trailing slash, to skip it as well */ - } - } - } - } - else - *(q++) = *p; - } - - *q = 0; - - return(r); -} +#define YY_NO_INPUT // Suppress generation of useless input() function static unsigned long long fromhex(const char *s) { #ifdef __MINGW32__ - // MinGW's strtoull() seems to be broken; it only returns the lower - // 32 bits... + /* MinGW's strtoull() seems to be broken; it only returns the lower + * 32 bits... + */ const char *p = s; unsigned long long val = 0; @@ -750,18 +614,20 @@ static unsigned long long fromhex(const char *s) return(val); -#else // ! __MINGW32__ +#else /* ! __MINGW32__ */ return(strtoull(s, NULL, 16)); -#endif // __MINGW32__ +#endif /* __MINGW32__ */ } -#line 762 "scanner.c" +#line 626 "scanner.c" #define INITIAL 0 #define COMMENT 1 +#define STRING 2 +#define INCLUDE 3 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -771,9 +637,7 @@ static unsigned long long fromhex(const char *s) #include <unistd.h> #endif -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif +#define YY_EXTRA_TYPE struct scan_context * /* Holds the entire state of the reentrant scanner. */ struct yyguts_t @@ -886,7 +750,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -894,7 +763,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -905,7 +774,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -979,6 +848,9 @@ extern int libconfig_yylex \ #endif #define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /** The main scanner function which does all the work. @@ -990,10 +862,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 194 "scanner.l" +#line 100 "scanner.l" -#line 997 "scanner.c" +#line 869 "scanner.c" yylval = yylval_param; @@ -1036,6 +908,7 @@ YY_DECL yy_bp = yy_cp; yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); yy_match: do { @@ -1048,13 +921,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 >= 117 ) + if ( yy_current_state >= 103 ) 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_base[yy_current_state] != 503 ); + while ( yy_base[yy_current_state] != 204 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1092,144 +965,265 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 196 "scanner.l" +#line 102 "scanner.l" { BEGIN COMMENT; } YY_BREAK case 2: YY_RULE_SETUP -#line 197 "scanner.l" +#line 103 "scanner.l" { BEGIN INITIAL; } YY_BREAK case 3: YY_RULE_SETUP -#line 198 "scanner.l" +#line 104 "scanner.l" { /* ignore */ } YY_BREAK case 4: /* rule 4 can match eol */ YY_RULE_SETUP -#line 199 "scanner.l" -{ } +#line 105 "scanner.l" +{ /* ignore */ } YY_BREAK case 5: -/* rule 5 can match eol */ YY_RULE_SETUP -#line 201 "scanner.l" -{ /* skip */ } +#line 107 "scanner.l" +{ BEGIN STRING; } YY_BREAK case 6: +/* rule 6 can match eol */ YY_RULE_SETUP -#line 203 "scanner.l" -{ return(TOK_EQUALS); } +#line 108 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } YY_BREAK case 7: YY_RULE_SETUP -#line 204 "scanner.l" -{ return(TOK_COMMA); } +#line 109 "scanner.l" +{ scanctx_append_string(yyextra, "\n"); } YY_BREAK case 8: YY_RULE_SETUP -#line 205 "scanner.l" -{ return(TOK_GROUP_START); } +#line 110 "scanner.l" +{ scanctx_append_string(yyextra, "\r"); } YY_BREAK case 9: YY_RULE_SETUP -#line 206 "scanner.l" -{ return(TOK_GROUP_END); } +#line 111 "scanner.l" +{ scanctx_append_string(yyextra, "\t"); } YY_BREAK case 10: YY_RULE_SETUP -#line 207 "scanner.l" -{ yylval->ival = 1; return(TOK_BOOLEAN); } +#line 112 "scanner.l" +{ scanctx_append_string(yyextra, "\f"); } YY_BREAK case 11: YY_RULE_SETUP -#line 208 "scanner.l" -{ yylval->ival = 0; return(TOK_BOOLEAN); } +#line 113 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } YY_BREAK case 12: YY_RULE_SETUP -#line 209 "scanner.l" -{ yylval->sval = strdup(yytext); return(TOK_NAME); } +#line 114 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } YY_BREAK case 13: YY_RULE_SETUP -#line 210 "scanner.l" -{ yylval->fval = atof(yytext); return(TOK_FLOAT); } +#line 115 "scanner.l" +{ + char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF), + 0 }; + scanctx_append_string(yyextra, c); + } YY_BREAK case 14: YY_RULE_SETUP -#line 211 "scanner.l" -{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } +#line 120 "scanner.l" +{ + yylval->sval = scanctx_take_string(yyextra); + BEGIN INITIAL; + return(TOK_STRING); + } YY_BREAK case 15: YY_RULE_SETUP -#line 212 "scanner.l" -{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } +#line 126 "scanner.l" +{ BEGIN INCLUDE; } YY_BREAK case 16: +/* rule 16 can match eol */ YY_RULE_SETUP -#line 213 "scanner.l" -{ yylval->ival = strtoul(yytext, NULL, 16); return(TOK_HEX); } +#line 127 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } YY_BREAK case 17: YY_RULE_SETUP -#line 214 "scanner.l" -{ yylval->llval = fromhex(yytext); return(TOK_HEX64); } +#line 128 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } YY_BREAK case 18: -/* rule 18 can match eol */ YY_RULE_SETUP -#line 215 "scanner.l" -{ yylval->sval = strdup(make_string(yytext)); return(TOK_STRING); } +#line 129 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } YY_BREAK case 19: YY_RULE_SETUP -#line 216 "scanner.l" -{ return(TOK_ARRAY_START); } +#line 130 "scanner.l" +{ + const char *error; + FILE *fp = scanctx_push_include(yyextra, + (void *)YY_CURRENT_BUFFER, + &error); + if(fp) + { + yyin = fp; + libconfig_yy_switch_to_buffer(libconfig_yy_create_buffer(yyin,YY_BUF_SIZE,yyscanner),yyscanner); + } + else + { + yyextra->config->error_text = error; + yyextra->config->error_file = scanctx_current_filename( + yyextra); + yyextra->config->error_line = libconfig_yyget_lineno( + yyscanner); + return TOK_ERROR; + } + BEGIN INITIAL; + } YY_BREAK case 20: +/* rule 20 can match eol */ YY_RULE_SETUP -#line 217 "scanner.l" -{ return(TOK_ARRAY_END); } +#line 154 "scanner.l" +{ /* ignore */ } YY_BREAK case 21: YY_RULE_SETUP -#line 218 "scanner.l" -{ return(TOK_LIST_START); } +#line 155 "scanner.l" +{ /* ignore */ } YY_BREAK case 22: YY_RULE_SETUP -#line 219 "scanner.l" -{ return(TOK_LIST_END); } +#line 157 "scanner.l" +{ return(TOK_EQUALS); } YY_BREAK case 23: YY_RULE_SETUP -#line 220 "scanner.l" -{ return(TOK_END); } +#line 158 "scanner.l" +{ return(TOK_COMMA); } YY_BREAK case 24: +YY_RULE_SETUP +#line 159 "scanner.l" +{ return(TOK_GROUP_START); } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 160 "scanner.l" +{ return(TOK_GROUP_END); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 161 "scanner.l" +{ yylval->ival = 1; return(TOK_BOOLEAN); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 162 "scanner.l" +{ yylval->ival = 0; return(TOK_BOOLEAN); } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 163 "scanner.l" +{ yylval->sval = yytext; return(TOK_NAME); } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 164 "scanner.l" +{ yylval->fval = atof(yytext); return(TOK_FLOAT); } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 165 "scanner.l" +{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 166 "scanner.l" +{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 167 "scanner.l" +{ + yylval->ival = strtoul(yytext, NULL, 16); + return(TOK_HEX); + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 171 "scanner.l" +{ yylval->llval = fromhex(yytext); return(TOK_HEX64); } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 172 "scanner.l" +{ return(TOK_ARRAY_START); } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 173 "scanner.l" +{ return(TOK_ARRAY_END); } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 174 "scanner.l" +{ return(TOK_LIST_START); } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 175 "scanner.l" +{ return(TOK_LIST_END); } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 176 "scanner.l" +{ return(TOK_SEMICOLON); } + YY_BREAK +case 39: *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 221 "scanner.l" +#line 177 "scanner.l" { /* ignore */ } YY_BREAK -case 25: +case 40: YY_RULE_SETUP -#line 222 "scanner.l" +#line 178 "scanner.l" { return(TOK_GARBAGE); } YY_BREAK -case 26: +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT): +case YY_STATE_EOF(STRING): +case YY_STATE_EOF(INCLUDE): +#line 180 "scanner.l" +{ + YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include( + yyextra); + if(buf) + { + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner); + libconfig_yy_switch_to_buffer(buf,yyscanner); + } + else + yyterminate(); + } + YY_BREAK +case 41: YY_RULE_SETUP -#line 223 "scanner.l" +#line 191 "scanner.l" ECHO; YY_BREAK -#line 1230 "scanner.c" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(COMMENT): - yyterminate(); +#line 1227 "scanner.c" case YY_END_OF_BUFFER: { @@ -1509,6 +1503,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { @@ -1521,7 +1516,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 >= 117 ) + if ( yy_current_state >= 103 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1550,11 +1545,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 >= 117 ) + if ( yy_current_state >= 103 ) 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 == 116); + yy_is_jam = (yy_current_state == 102); return yy_is_jam ? 0 : yy_current_state; } @@ -1630,7 +1625,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; - if ( c == '\n' ) + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) do{ yylineno++; yycolumn=0; @@ -1968,8 +1964,8 @@ YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char * yystr , yyscan_t yyscan /** Setup the input buffer state to scan the given bytes. The next call to libconfig_yylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -2363,4 +2359,4 @@ void libconfig_yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 223 "scanner.l" +#line 191 "scanner.l" |