diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2020-11-06 13:19:17 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2020-11-08 17:38:42 -0500 |
commit | 191d7068c3045e3a966800428d64881590cf61a5 (patch) | |
tree | d1618838bed46d3b7554ab953aa576f59da6cd94 | |
parent | 8aabc897cd0729b9961b8b919a6ed7331cc32aca (diff) | |
download | flex-git-191d7068c3045e3a966800428d64881590cf61a5.tar.gz |
Fully m4ize yymore()
-rw-r--r-- | doc/flex.texi | 11 | ||||
-rw-r--r-- | src/c99-flex.skl | 27 | ||||
-rw-r--r-- | src/scan.l | 21 |
3 files changed, 29 insertions, 30 deletions
diff --git a/doc/flex.texi b/doc/flex.texi index c9d1dd3..7a52029 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -2721,11 +2721,12 @@ Python, etc. @item @code{%option rewrite} Back ends other than the default C generator can't assume they have the C preprocessor available. Therefore, Flex recognizes the -following function calls - yyecho(), yyinput(), yystart(), yybegin(), -yyunput(), yypanic() and rewreites them adding a yyscanner final -aergument as though they were C macros. This optiion is set to false -whrn you select or default to the C back end, and to true otherwise. -You can turn it off (or on) expliciltly after your emit option. +following function calls - yyecho(), yyless(), yymore(), yyinput(), +yystart(), yybegin(), yyunput(), yypanic() - and rewreites them adding a +yyscanner final argument as though they were C macros. This optiion +is set to false whrn you select or default to the C back end, and to +true otherwise. You can turn it off (or on) explicitly after your +emit option. @anchor{option-case-insensitive} @opindex -i diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 6bc60f5..017d2cb 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1124,31 +1124,30 @@ static void yybumpline( yyscan_t yyscanner) { yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } +/* END access macros for use in actions */ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET \ -{ \ -yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; \ -yyscanner->yyleng_r -= yyscanner->yy_more_offset; \ +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ +yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; +yyscanner->yyleng_r -= yyscanner->yy_more_offset; } ]]) +]]) m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyscanner->yy_more_flag = true) -#define YY_MORE_ADJ yyscanner->yy_more_len -#define YY_RESTORE_YY_MORE_OFFSET +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} +m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) ]]) m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) -/* END access macros for use in actions */ - void yysetbol(bool at_bol, yyscan_t yyscanner) { if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (yyscanner); @@ -88,10 +88,6 @@ extern const char *escaped_qstart, *escaped_qend; if ( all_lower( str ) ) \ reject = true; -#define CHECK_YYMORE(str) \ - if ( all_lower( str ) ) \ - yymore_used = true; - #define YY_USER_INIT \ if ( getenv("POSIXLY_CORRECT") ) \ ctrl.posix_compat = true; @@ -927,16 +923,19 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ <CODEBLOCK,ACTION>{ "reject" { - ACTION_ECHO; - CHECK_REJECT(yytext); + ACTION_ECHO; + CHECK_REJECT(yytext); } "yyreject()" { - add_action("]""]M4_HOOK_REJECT[""["); - CHECK_YYREJECT(yytext); + add_action("]""]M4_HOOK_REJECT[""["); + CHECK_YYREJECT(yytext); } - "yymore" { - ACTION_ECHO; - CHECK_YYMORE(yytext); + "yymore()" { + yymore_used = true; + if (ctrl.rewrite) + context_call(yytext); + else + ACTION_ECHO; } } |