diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2020-09-22 06:08:10 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2020-09-22 06:08:10 -0400 |
commit | e6fa974cd7523f2e093ed70dca591dc89d19c061 (patch) | |
tree | c60d2203bef6e5fc30ca41e8b9c58319d7596c59 | |
parent | 30788806b98ae23151c921ad34c3a6f7ab1d0d76 (diff) | |
download | flex-git-e6fa974cd7523f2e093ed70dca591dc89d19c061.tar.gz |
gen_bu_action() becomes m4 code.
Also, two GEN_START_STATE calls get inlined in the skeleton file.
Changes in generated C from the tests are all comments and whitespace.
#21 in the retargeting patch series
-rw-r--r-- | src/cpp-flex.skl | 19 | ||||
-rw-r--r-- | src/flexdef.h | 3 | ||||
-rw-r--r-- | src/gen.c | 36 |
3 files changed, 20 insertions, 38 deletions
diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 25ee2df..25b7612 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1368,6 +1368,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], */ yy_bp = yy_cp; +M4_GEN_START_STATE %% [9.0] code to set up and find next match goes here /* Generate the code to find the next match. */ @@ -1534,6 +1535,23 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ switch ( yy_act ) { /* beginning of action switch */ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = YY_G(yy_hold_char); + + /* /\* Backing-up info for compressed tables is taken \after/ */ + /* * yy_cp has been incremented for the next state. */ + /* *\/ */ + yy_cp = YY_G(yy_last_accepting_cpos); + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) + m4_ifdef([[M4_MODE_FULLTBL]], [[yy_cp++;]]) + + yy_current_state = YY_G(yy_last_accepting_state); + goto yy_find_action; +]]) +]]) %% [13.0] actions go here case YY_END_OF_BUFFER: @@ -1973,6 +1991,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], char *yy_cp; M4_YY_DECL_GUTS_VAR(); +M4_GEN_START_STATE %% [15.0] code to get the start state into yy_current_state goes here for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) diff --git a/src/flexdef.h b/src/flexdef.h index b1de1b6..7ee87eb 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -775,9 +775,6 @@ extern void mkechar(int, int[], int[]); extern void do_indent(void); /* indent to the current level */ -/* Generate the code to perform the backing up. */ -extern void gen_bu_action(void); - /* Generate full speed compressed transition table. */ extern void genctbl(void); @@ -112,34 +112,6 @@ static void geneoltbl (void) } -/* Generate the code to perform the backing up. */ - -void gen_bu_action (void) -{ - if (reject || num_backing_up == 0) - return; - - set_indent (3); - - indent_puts ("case 0: /* must back up */"); - indent_puts ("/* undo the effects of YY_DO_BEFORE_ACTION */"); - indent_puts ("*yy_cp = YY_G(yy_hold_char);"); - - if (fullspd || fulltbl) - indent_puts ("yy_cp = YY_G(yy_last_accepting_cpos) + 1;"); - else - /* Backing-up info for compressed tables is taken \after/ - * yy_cp has been incremented for the next state. - */ - indent_puts ("yy_cp = YY_G(yy_last_accepting_cpos);"); - - indent_puts ("yy_current_state = YY_G(yy_last_accepting_state);"); - indent_puts ("goto yy_find_action;"); - outc ('\n'); - - set_indent (0); -} - /** mkctbl - make full speed compressed transition table * This is an array of structs; each struct a pair of integers. * You should call mkssltbl() immediately after this. @@ -1570,8 +1542,6 @@ void make_tables (void) skelout (); /* %% [9.0] - break point in skel */ - outn ("M4_GEN_START_STATE"); - /* Note, don't use any indentation. */ outn ("yy_match:"); @@ -1603,13 +1573,12 @@ void make_tables (void) /* Copy actions to output file. */ skelout (); /* %% [13.0] - break point in skel */ - ++indent_level; - gen_bu_action (); out (&action_array[action_offset]); line_directive_out (stdout, 0); /* generate cases for any missing EOF rules */ + set_indent(0); for (i = 1; i <= lastsc; ++i) if (!sceof[i]) { do_indent (); @@ -1623,7 +1592,6 @@ void make_tables (void) --indent_level; } - /* Generate code for handling NUL's, if needed. */ /* First, deal with backing up and setting up yy_cp if the scanner @@ -1659,8 +1627,6 @@ void make_tables (void) set_indent (1); skelout (); /* %% [15.0] - break point in skel */ - outn ("M4_GEN_START_STATE"); - set_indent (2); skelout (); /* %% [16.0] - break point in skel */ gen_next_state (true); |