From: John Millaway Date: Thu, 13 Mar 2003 08:56:07 +0000 (+0000) Subject: Moved YY_USE_LINENO to m4. X-Git-Tag: flex-2-5-34~35^2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02af71f137f5cf71b4e1ec26fdc466dc90566fc3;p=flex Moved YY_USE_LINENO to m4. --- diff --git a/flex.skl b/flex.skl index 626fc34..fd4f971 100644 --- a/flex.skl +++ b/flex.skl @@ -92,20 +92,11 @@ m4preproc_include(`flexint.h') #ifdef __cplusplus -/* C++ compilers do not understand traditional function definitions. */ -#ifdef YY_TRADITIONAL_FUNC_DEFS -#undef YY_TRADITIONAL_FUNC_DEFS -#endif - /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ -/* We are not in a C++ compiler, so by default, - we generate C99 function defs, unless you explicitly ask - for traditional defs by defining YY_TRADITIONAL_FUNC_DEFS */ - #if __STDC__ #define YY_USE_CONST @@ -232,13 +223,23 @@ m4_define([[M4_YY_CALL_ONLY_ARG]]) * char * y; * yyscan_t yyscanner; */ -m4_ifdef( [[YY_TRADITIONAL_FUNC_DEFS]], +m4_ifdef( [[M4_YY_TRADITIONAL_FUNC_DEFS]], [[ %# Generate traditional function defs - #define YYFARGS0(v) (M4_YY_DEF_ONLY_ARG) M4_YY_DECL_LAST_ARG - #define YYFARGS1(t1,n1) (n1 M4_YY_DEF_LAST_ARG) t1 n1; M4_YY_DECL_LAST_ARG - #define YYFARGS2(t1,n1,t2,n2) (n1,n2 M4_YY_DEF_LAST_ARG) t1 n1; t2 n2; M4_YY_DECL_LAST_ARG - #define YYFARGS3(t1,n1,t2,n2,t3,n3) (n1,n2,n3 M4_YY_DEF_LAST_ARG) t1 n1; t2 n2; t3 n3; M4_YY_DECL_LAST_ARG + m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG) + M4_YY_DECL_LAST_ARG]]) + m4_define( [[YYFARGS1]], [[($2 M4_YY_DEF_LAST_ARG) + $1 $2; + M4_YY_DECL_LAST_ARG]]) + m4_define( [[YYFARGS2]], [[($2,$4 M4_YY_DEF_LAST_ARG) + $1 $2; + $3 $4; + M4_YY_DECL_LAST_ARG]]) + m4_define( [[YYFARGS3]], [[($2,$4,$6 M4_YY_DEF_LAST_ARG) + $1 $2; + $3 $4; + $5 $6; + M4_YY_DECL_LAST_ARG]]) ]], [[ %# Generate C99 function defs. @@ -294,7 +295,8 @@ extern FILE *yyin, *yyout; #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 -#ifdef YY_USE_LINENO +m4_ifdef( [[M4_YY_USE_LINENO]], +[[ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. @@ -309,9 +311,10 @@ extern FILE *yyin, *yyout; if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) -#else +]], +[[ #define YY_LESS_LINENO(n) -#endif +]]) /* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator). This @@ -1501,10 +1504,12 @@ m4_ifdef( [[M4_YY_USES_REJECT]], *--yy_cp = (char) c; %% [18.0] update yylineno here -#ifdef YY_USE_LINENO +m4_ifdef( [[M4_YY_USE_LINENO]], +[[ if ( c == '\n' ) --yylineno; -#endif +]]) + YY_G(yytext_ptr) = yy_bp; YY_G(yy_hold_char) = *yy_cp; YY_G(yy_c_buf_p) = yy_cp; @@ -2292,9 +2297,10 @@ static int yy_init_globals YYFARGS0(void) This function is called once per scanner lifetime. */ /* We do not touch yylineno unless the option is enabled. */ -#ifdef YY_USE_LINENO +m4_ifdef( [[M4_YY_USE_LINENO]], +[[ yylineno = 1; -#endif +]]) YY_G(yy_buffer_stack) = 0; YY_G(yy_buffer_stack_top) = 0; YY_G(yy_buffer_stack_max) = 0; diff --git a/gen.c b/gen.c index c742582..7c7dfa0 100644 --- a/gen.c +++ b/gen.c @@ -125,7 +125,7 @@ static void geneoltbl () { int i; - outn ("#ifdef YY_USE_LINENO"); + outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); outn ("/* Table of booleans, true if rule could match eol. */"); out_str_dec (get_int32_decl (), "yy_rule_can_match_eol", num_rules + 1); @@ -139,7 +139,7 @@ static void geneoltbl () } out (" };\n"); } - outn ("#endif"); + outn ("]])"); } @@ -1978,7 +1978,7 @@ void make_tables () gen_find_action (); skelout (); /* %% [11.0] - break point in skel */ - outn ("#ifdef YY_USE_LINENO"); + outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); indent_puts ("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )"); indent_up (); @@ -1996,7 +1996,7 @@ void make_tables () indent_down (); indent_puts ("}"); indent_down (); - outn ("#endif"); + outn ("]])"); skelout (); /* %% [12.0] - break point in skel */ if (ddebug) { diff --git a/main.c b/main.c index bc79267..abeab38 100644 --- a/main.c +++ b/main.c @@ -483,7 +483,7 @@ void check_options () line_directive_out (stdout, 0); if (do_yylineno) - buf_strdefine (&userdef_buf, "YY_USE_LINENO", "1"); + buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL); /* Create the alignment type. */ buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", @@ -735,7 +735,6 @@ void flexend (exit_status) "YY_TRAILING_MASK", "YY_USER_ACTION", "YY_USE_CONST", - "YY_USE_LINENO", "YY_USE_PROTOS", "unput", "yyTABLES_NAME", diff --git a/scan.l b/scan.l index a0b68db..7bcec3b 100644 --- a/scan.l +++ b/scan.l @@ -310,7 +310,7 @@ LEXOPT [aceknopr] unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense); verbose printstats = option_sense; warn nowarn = ! option_sense; - yylineno do_yylineno = option_sense; ACTION_IFDEF("YY_USE_LINENO", option_sense); + yylineno do_yylineno = option_sense; ACTION_M4_IFDEF("M4_YY_USE_LINENO", option_sense); yymore yymore_really_used = option_sense; yywrap do_yywrap = option_sense;