diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2020-09-25 16:34:18 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2020-09-25 18:09:44 -0400 |
commit | c842b49f83a4fd07a261a05195e440765b8df585 (patch) | |
tree | fa0e90d1fcf6a209a20b319f527b6d2892d1bfc3 | |
parent | 8521281aef33b47df7e372d16a495cec7f9a7e62 (diff) | |
download | flex-git-c842b49f83a4fd07a261a05195e440765b8df585.tar.gz |
Finish the retargeting patch series with a couple of small fixups.
Pull the C mode setting for M4_YYL_BASE into m4.
Use if/then/else extension of m4_ifdef to simplify how yy_flex_debug
is set. In the process, fix a bug introduced earlier in this patchest
where yy_flex_debug initialization was inverted.
Remove unused skel breakpoints and renumber those left.
Diffs have only commenmt and whitespace changes *except* for the
corrected initialzation of yy_flex_debug.
#40 in the retargeting patch series
-rw-r--r-- | src/cpp-flex.skl | 27 | ||||
-rw-r--r-- | src/gen.c | 27 |
2 files changed, 15 insertions, 39 deletions
diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index da2f38d..c9f1bfd 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -728,13 +728,11 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef( [[M4_MODE_C_ONLY]], [[ extern int yy_flex_debug; -int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]])m4_ifdef([[M4_MODE_NO_DEBUG]],[[1]]); +int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); ]]) %endif -%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ -%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ -%% [4.0] data tables for the DFA and the user's section 1 definitions go here +%% [2.0] data tables for the DFA are inserted here ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], @@ -847,7 +845,7 @@ char *yytext; ]]) ]]) -%% [4.1] static declarations conditional on mode switches go here +%% [3.0] static declarations conditional on mode switches go here ]]) m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) @@ -1252,7 +1250,6 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ \ }\ ]]) \ %endif \ -%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ \ %if-c++-only C++ definition \ if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ @@ -1390,7 +1387,6 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ -%% [6.0] YY_RULE_SETUP definition goes here #define YY_RULE_SETUP \ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ @@ -1562,7 +1558,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], } { -%% [7.0] user's declarations go here +%% [4.0] user's declarations go here while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1576,7 +1572,6 @@ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ } ]]) ]]) -%% [8.0] yymore()-related code goes here yy_cp = YY_G(yy_c_buf_p); /* Support of yytext. */ @@ -1591,7 +1586,6 @@ M4_GEN_START_STATE yy_match: -%% [9.0] code to set up and find next match goes here /* Generate the code to find the next match. */ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ m4_ifdef([[M4_MODE_GENTABLES]], [[ @@ -1633,7 +1627,7 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ ]]) yy_find_action: -%% [10.0] code to find the action number goes here + /* code to find the action number goes here */ m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ @@ -1704,8 +1698,9 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s YY_DO_BEFORE_ACTION; m4_ifdef( [[M4_YY_USE_LINENO]],[[ -m4_ifdef( [[M4_MODE_YYMORE_USED]],[[ -]]) +m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], + [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], + [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; @@ -1715,12 +1710,8 @@ m4_ifdef( [[M4_MODE_YYMORE_USED]],[[ } ]]) -%% [11.0] code for yylineno update goes here - do_action: /* This label is used only to access EOF actions. */ -%% [12.0] debug code goes here - m4_ifdef([[M4_MODE_DEBUG]], [[ if ( yy_flex_debug ) { if ( yy_act == 0 ) { @@ -1785,7 +1776,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ goto yy_find_action; ]]) ]]) -%% [13.0] actions go here +%% [5.0] user actions get inserted here case YY_END_OF_BUFFER: { @@ -920,7 +920,7 @@ void make_tables (void) if (do_yylineno) visible_define ( "M4_MODE_YYLINENO"); - // Equivelance classes + // Equivalence classes if (useecs) visible_define ( "M4_MODE_USEECS"); else @@ -957,11 +957,9 @@ void make_tables (void) if (ddebug) visible_define ( "M4_MODE_DEBUG"); - else - visible_define ( "M4_MODE_NO_DEBUG"); // Kluge to get around the fact that the %if-not-reentrant and - // %if-c-only gates can;t be combined by nesting one inside the + // %if-c-only gates can't be combined by nesting one inside the // other. if (backend == &cpp_backend && !C_plus_plus) visible_define ( "M4_MODE_C_ONLY"); @@ -969,10 +967,6 @@ void make_tables (void) backend->comment("m4 controls end"); out ("\n"); - // FIXME: This probaby should be done in pure m4 - out_m4_define ("M4_YYL_BASE", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : - "YY_G(yy_more_len)") : "0"); - // There are a couple more modes we can't compute until after // tables have been generated. @@ -989,9 +983,7 @@ void make_tables (void) */ fprintf (stdout, backend->string_define_fmt, "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1)); - skelout (); /* %% [2.0] - break point in skel */ - skelout (); /* %% [3.0] - break point in skel */ - skelout (); /* %% [4.0] - tables get dumped here */ + skelout (); /* %% [2.0] - tables get dumped here */ /* This is where we REALLY begin generating the tables. */ @@ -1141,29 +1133,22 @@ void make_tables (void) dataend (); } - skelout (); /* %% [4.1] - mode-dependent static declarations get dumped here */ + skelout (); /* %% [3.0] - mode-dependent static declarations get dumped here */ out (&action_array[defs1_offset]); line_directive_out (stdout, 0); - skelout (); /* %% [5.0] - break point in skel */ - skelout (); /* %% [6.0] - break point in skel */ - skelout (); /* %% [7.0] - break point in skel */ + skelout (); /* %% [4.0] - various random yylex internals get dumped here */ /* Copy prolog to output file. */ out (&action_array[prolog_offset]); line_directive_out (stdout, 0); - skelout (); /* %% [8.0] - break point in skel */ - skelout (); /* %% [9.0] - break point in skel */ - skelout (); /* %% [10.0] - break point in skel */ - skelout (); /* %% [11.0] - break point in skel */ - skelout (); /* %% [12.0] - break point in skel */ + skelout (); /* %% [5.0] - main loop of matching-emngine code gets dumped here */ /* Copy actions to output file. */ - skelout (); /* %% [13.0] - break point in skel */ out (&action_array[action_offset]); line_directive_out (stdout, 0); |