summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2020-11-12 18:45:54 -0500
committerEric S. Raymond <esr@thyrsus.com>2020-11-12 18:45:54 -0500
commit1a48798ca94c0afd8ff5b5e2e26948948352a2ad (patch)
treee901a7e28bbc7801d3f7ffca5ae92d4fab90b1c6
parente3e0d791eaca3485dadfcb84530f23c360f61ec9 (diff)
downloadflex-git-1a48798ca94c0afd8ff5b5e2e26948948352a2ad.tar.gz
In C99, more rearrangement to make public API calls visible in actions...
..,without resorting to forward declarations. Last C99 cleanup before the Go port begins.
-rw-r--r--src/c99-flex.skl358
1 files changed, 179 insertions, 179 deletions
diff --git a/src/c99-flex.skl b/src/c99-flex.skl
index 37f0c96..408761a 100644
--- a/src/c99-flex.skl
+++ b/src/c99-flex.skl
@@ -29,7 +29,7 @@ m4_changequote([[, ]])
%# Properties not used in the skeleton - meant to be read by the Flex code
m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C99]])
-m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]])
+m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[c]])
m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]])
m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]])
m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]])
@@ -1604,6 +1604,184 @@ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner)
}
]])
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (yyscan_t yyscanner)
+{
+ char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf;
+ char *source = yyscanner->yytext_ptr;
+ int number_to_move, i;
+ int ret_val;
+
+ if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) {
+ yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner);
+ }
+ if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) {
+ /* Don't try to fill the buffer, so this is an EOF. */
+ if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ } else {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1);
+
+ for ( i = 0; i < number_to_move; ++i ) {
+ *(dest++) = *(source++);
+ }
+ if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) {
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0;
+ } else {
+ int num_to_read =
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */
+m4_ifdef( [[M4_MODE_USES_REJECT]],
+[[
+ yypanic(
+ "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner );
+]],
+[[
+ /* just a shorter name for the current buffer */
+ yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top];
+
+ int yy_c_buf_p_offset =
+ (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer ) {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 ) {
+ b->yy_buf_size += b->yy_buf_size / 8;
+ } else {
+ b->yy_buf_size *= 2;
+ }
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2), yyscanner );
+ } else {
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = NULL;
+ }
+ if ( b->yy_ch_buf == NULL ) {
+ yypanic("fatal error - scanner input buffer overflow", yyscanner);
+ }
+ yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size -
+ number_to_move - 1;
+]])
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE ) {
+ num_to_read = YY_READ_BUF_SIZE;
+ }
+ /* Read in more data. */
+ yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner);
+
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars;
+ }
+
+ if ( yyscanner->yy_n_chars == 0 ) {
+ if ( number_to_move == YY_MORE_ADJ ) {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyscanner->yyin_r, yyscanner);
+ } else {
+ ret_val = EOB_ACT_LAST_MATCH;
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ } else {
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+ }
+ if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1);
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc(
+ (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner );
+ if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) {
+ yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner);
+ }
+ /* "- 2" to take care of EOB's */
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2);
+ }
+
+ yyscanner->yy_n_chars += number_to_move;
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
+[[
+static void yy_push_state(int _new_state, yyscan_t yyscanner)
+{
+ if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) {
+ yy_size_t new_size;
+
+ yyscanner->yy_start_stack_depth += YY_START_STACK_INCR;
+ new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int );
+
+ if ( yyscanner->yy_start_stack == NULL ) {
+ yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner );
+
+ } else {
+ yyscanner->yy_start_stack = (int *) yyrealloc(
+ (void *) yyscanner->yy_start_stack, new_size, yyscanner );
+ }
+ if ( yyscanner->yy_start_stack == NULL ) {
+ yypanic( "out of memory expanding start-condition stack", yyscanner);
+ }
+ }
+ yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner);
+
+ yybegin(_new_state, yyscanner);
+}
+]])
+
+
+m4_ifdef( [[M4_YY_NO_POP_STATE]],,
+[[
+static void yy_pop_state (yyscan_t yyscanner)
+{
+ if ( --yyscanner->yy_start_stack_ptr < 0 ) {
+ yypanic( "start-condition stack underflow", yyscanner );
+ }
+ yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner);
+}
+]])
+
+
+m4_ifdef( [[M4_YY_NO_TOP_STATE]],,
+[[
+static int yy_top_state (yyscan_t yyscanner)
+{
+ return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner);
+}
+]])
+
%# Code snippets used in various cases of code generation in the main scanner.
m4_define([[M4_GEN_BACKING_UP]], [[
@@ -2190,184 +2368,6 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[
} /* end of user's declarations */
} /* end of yylex */
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (yyscan_t yyscanner)
-{
- char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf;
- char *source = yyscanner->yytext_ptr;
- int number_to_move, i;
- int ret_val;
-
- if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) {
- yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner);
- }
- if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) {
- /* Don't try to fill the buffer, so this is an EOF. */
- if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- } else {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1);
-
- for ( i = 0; i < number_to_move; ++i ) {
- *(dest++) = *(source++);
- }
- if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) {
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0;
- } else {
- int num_to_read =
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */
-m4_ifdef( [[M4_MODE_USES_REJECT]],
-[[
- yypanic(
- "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner );
-]],
-[[
- /* just a shorter name for the current buffer */
- yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top];
-
- int yy_c_buf_p_offset =
- (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer ) {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 ) {
- b->yy_buf_size += b->yy_buf_size / 8;
- } else {
- b->yy_buf_size *= 2;
- }
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc( (void *) b->yy_ch_buf,
- (yy_size_t) (b->yy_buf_size + 2), yyscanner );
- } else {
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = NULL;
- }
- if ( b->yy_ch_buf == NULL ) {
- yypanic("fatal error - scanner input buffer overflow", yyscanner);
- }
- yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size -
- number_to_move - 1;
-]])
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE ) {
- num_to_read = YY_READ_BUF_SIZE;
- }
- /* Read in more data. */
- yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner);
-
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars;
- }
-
- if ( yyscanner->yy_n_chars == 0 ) {
- if ( number_to_move == YY_MORE_ADJ ) {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyscanner->yyin_r, yyscanner);
- } else {
- ret_val = EOB_ACT_LAST_MATCH;
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- } else {
- ret_val = EOB_ACT_CONTINUE_SCAN;
- }
- if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1);
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc(
- (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner );
- if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) {
- yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner);
- }
- /* "- 2" to take care of EOB's */
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2);
- }
-
- yyscanner->yy_n_chars += number_to_move;
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0];
-
- return ret_val;
-}
-
-m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
-[[
-static void yy_push_state(int _new_state, yyscan_t yyscanner)
-{
- if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) {
- yy_size_t new_size;
-
- yyscanner->yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int );
-
- if ( yyscanner->yy_start_stack == NULL ) {
- yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner );
-
- } else {
- yyscanner->yy_start_stack = (int *) yyrealloc(
- (void *) yyscanner->yy_start_stack, new_size, yyscanner );
- }
- if ( yyscanner->yy_start_stack == NULL ) {
- yypanic( "out of memory expanding start-condition stack", yyscanner);
- }
- }
- yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner);
-
- yybegin(_new_state, yyscanner);
-}
-]])
-
-
-m4_ifdef( [[M4_YY_NO_POP_STATE]],,
-[[
-static void yy_pop_state (yyscan_t yyscanner)
-{
- if ( --yyscanner->yy_start_stack_ptr < 0 ) {
- yypanic( "start-condition stack underflow", yyscanner );
- }
- yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner);
-}
-]])
-
-
-m4_ifdef( [[M4_YY_NO_TOP_STATE]],,
-[[
-static int yy_top_state (yyscan_t yyscanner)
-{
- return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner);
-}
-]])
-
m4_undefine([[yyless]])
/* Redefine yyless() so it works in section 3 code. */