From e8c311e86f4d8c082e96e02b6a33525034eee6d4 Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Thu, 10 Sep 2026 12:58:22 +0200 Subject: [PATCH] Fix scanner rule for floats The previous definition also matches integers without an exponent or decimal point, shadowing the INT rule coming after it. This fix changes the rule to only match numbers as floats which contain either an exponent (via e/E), a decimal point or both. --- projectm-eval/Scanner.c | 117 ++++++++++++++++++++-------------------- projectm-eval/Scanner.l | 3 +- 2 files changed, 62 insertions(+), 58 deletions(-) diff --git a/projectm-eval/Scanner.c b/projectm-eval/Scanner.c index 09124ff..c4eb46d 100644 --- a/projectm-eval/Scanner.c +++ b/projectm-eval/Scanner.c @@ -765,16 +765,17 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[80] = +static const flex_int16_t yy_accept[83] = { 0, 0, 0, 0, 0, 0, 0, 53, 51, 50, 50, 40, 51, 36, 38, 42, 43, 34, 32, 48, 33, - 51, 35, 13, 47, 49, 30, 41, 31, 46, 15, + 51, 35, 14, 47, 49, 30, 41, 31, 46, 15, 15, 44, 45, 37, 39, 52, 3, 52, 6, 5, 27, 0, 10, 0, 0, 18, 29, 20, 22, 16, - 17, 13, 1, 4, 21, 13, 13, 0, 25, 24, + 17, 13, 1, 4, 21, 13, 14, 0, 25, 24, 26, 15, 15, 23, 19, 28, 2, 0, 0, 9, - 7, 13, 0, 13, 15, 8, 11, 12, 0 + 7, 0, 13, 0, 13, 15, 8, 11, 0, 13, + 12, 0 } ; static const YY_CHAR yy_ec[256] = @@ -818,74 +819,76 @@ static const YY_CHAR yy_meta[43] = 3, 1 } ; -static const flex_int16_t yy_base[84] = +static const flex_int16_t yy_base[87] = { 0, - 0, 0, 40, 41, 122, 121, 123, 126, 126, 126, - 101, 37, 100, 39, 126, 126, 98, 89, 126, 87, - 90, 37, 39, 126, 126, 84, 83, 81, 126, 0, - 17, 126, 126, 78, 28, 126, 126, 80, 126, 126, - 126, 0, 126, 38, 55, 126, 126, 126, 126, 126, - 126, 38, 126, 126, 126, 64, 67, 71, 126, 126, - 126, 0, 25, 126, 126, 126, 126, 85, 58, 126, - 70, 73, 54, 50, 71, 126, 126, 0, 126, 111, - 114, 56, 117 + 0, 0, 40, 41, 127, 126, 128, 131, 131, 131, + 105, 37, 96, 39, 131, 131, 95, 94, 131, 93, + 96, 37, 39, 131, 131, 90, 89, 88, 131, 0, + 17, 131, 131, 87, 28, 131, 131, 89, 131, 131, + 131, 0, 131, 38, 55, 131, 131, 131, 131, 131, + 131, 38, 131, 131, 131, 64, 67, 71, 131, 131, + 131, 0, 25, 131, 131, 131, 131, 96, 58, 131, + 70, 84, 82, 76, 73, 72, 131, 131, 54, 50, + 0, 131, 118, 121, 56, 124 } ; -static const flex_int16_t yy_def[84] = +static const flex_int16_t yy_def[87] = { 0, - 79, 1, 80, 80, 81, 81, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 82, - 82, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 83, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 82, 82, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 82, 79, 79, 82, 0, 79, - 79, 79, 79 + 82, 1, 83, 83, 84, 84, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 85, + 85, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 86, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 85, 85, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 85, 82, 82, 82, 82, + 85, 0, 82, 82, 82, 82 } ; -static const flex_int16_t yy_nxt[169] = +static const flex_int16_t yy_nxt[174] = { 0, 8, 9, 10, 11, 12, 13, 14, 8, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30, 31, 30, 30, 30, 30, 30, 30, 32, 33, 34, 30, 31, 30, 30, 30, - 30, 35, 37, 37, 42, 47, 63, 53, 65, 75, + 30, 35, 37, 37, 42, 47, 63, 53, 65, 76, 38, 38, 54, 56, 52, 57, 63, 55, 62, 48, - 75, 43, 58, 58, 69, 70, 74, 44, 45, 66, - 74, 71, 43, 58, 58, 69, 70, 44, 71, 71, - 72, 56, 73, 57, 73, 77, 71, 74, 58, 72, - 71, 58, 76, 71, 71, 67, 77, 58, 64, 58, - - 78, 61, 58, 60, 59, 71, 52, 51, 58, 50, - 78, 36, 36, 36, 39, 39, 39, 68, 49, 68, - 46, 41, 79, 40, 40, 7, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79 + 76, 43, 72, 58, 69, 70, 80, 44, 45, 66, + 80, 71, 43, 72, 58, 69, 70, 44, 71, 71, + 73, 56, 74, 57, 74, 78, 71, 75, 72, 75, + 71, 58, 75, 71, 71, 79, 78, 79, 73, 72, + + 80, 81, 58, 77, 67, 71, 72, 64, 61, 60, + 59, 81, 52, 51, 50, 49, 46, 72, 36, 36, + 36, 39, 39, 39, 68, 41, 68, 82, 40, 40, + 7, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82 } ; -static const flex_int16_t yy_chk[169] = +static const flex_int16_t yy_chk[174] = { 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, 3, 4, 12, 14, 31, 22, 35, 63, - 3, 4, 22, 23, 52, 23, 31, 22, 82, 14, - 63, 12, 52, 23, 44, 44, 74, 12, 12, 35, - 73, 45, 12, 52, 23, 44, 44, 12, 45, 45, - 56, 57, 58, 57, 58, 69, 71, 58, 56, 72, - 45, 57, 68, 71, 71, 38, 69, 72, 34, 56, - - 75, 28, 57, 27, 26, 71, 21, 20, 72, 18, - 75, 80, 80, 80, 81, 81, 81, 83, 17, 83, - 13, 11, 7, 6, 5, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79 + 3, 4, 22, 23, 52, 23, 31, 22, 85, 14, + 63, 12, 52, 23, 44, 44, 80, 12, 12, 35, + 79, 45, 12, 52, 23, 44, 44, 12, 45, 45, + 56, 57, 58, 57, 58, 69, 71, 58, 56, 75, + 45, 57, 74, 71, 71, 72, 69, 72, 73, 56, + + 72, 76, 57, 68, 38, 71, 73, 34, 28, 27, + 26, 76, 21, 20, 18, 17, 13, 73, 83, 83, + 83, 84, 84, 84, 86, 11, 86, 7, 6, 5, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82 } ; @@ -1341,13 +1344,13 @@ YY_DECL 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 >= 80 ) + if ( yy_current_state >= 83 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 79 ); + while ( yy_current_state != 82 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1923,7 +1926,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 >= 80 ) + if ( yy_current_state >= 83 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1953,11 +1956,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 >= 80 ) + if ( yy_current_state >= 83 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 79); + yy_is_jam = (yy_current_state == 82); (void)yyg; return yy_is_jam ? 0 : yy_current_state; diff --git a/projectm-eval/Scanner.l b/projectm-eval/Scanner.l index 8d2579a..02d428d 100644 --- a/projectm-eval/Scanner.l +++ b/projectm-eval/Scanner.l @@ -41,7 +41,8 @@ DIGIT [0-9] HEX [0-9a-fA-F] SIGN [+-] EXPO [eE]{SIGN}?{DIGIT}+ -FLOAT ({DIGIT}+|{DIGIT}+\.{DIGIT}*|{DIGIT}*\.{DIGIT}+){EXPO}? +FLT_BASE {DIGIT}+\.{DIGIT}*|{DIGIT}*\.{DIGIT}+ +FLOAT ({DIGIT}+{EXPO})|({FLT_BASE}{EXPO}?) INT {DIGIT}+ NAME [_a-zA-Z][_a-zA-Z0-9]*