diff options
Diffstat (limited to 'src/flex.skl')
-rw-r--r-- | src/flex.skl | 153 |
1 files changed, 69 insertions, 84 deletions
diff --git a/src/flex.skl b/src/flex.skl index 1ecea58..d85e729 100644 --- a/src/flex.skl +++ b/src/flex.skl @@ -13,10 +13,10 @@ %# through m4. Macros beginning with `m4_' will be processed. %# The quoting is "[[" and "]]" so we don't interfere with %# user code. -%# +%# %# All generate macros for the m4 stage contain the text "m4" or "M4" %# in them. This is to distinguish them from CPP macros. -%# The exception to this rule is YY_G, which is an m4 macro, +%# The exception to this rule is YY_G, which is an m4 macro, %# but it needs to be remain short because it is used everywhere. %# /* A lexical scanner generated by flex */ @@ -29,7 +29,7 @@ m4_changecom m4_changequote m4_changequote([[, ]]) -%# +%# %# Lines in this skeleton starting with a "%" character are "control lines" %# and affect the generation of the scanner. The possible control codes are %# listed and processed in misc.c. @@ -215,7 +215,7 @@ m4preproc_include(`flexint.h') %if-c++-only /* begin standard C++ headers. */ -#include <iostream> +#include <iostream> #include <errno.h> #include <cstdlib> #include <cstdio> @@ -223,38 +223,26 @@ m4preproc_include(`flexint.h') /* end standard C++ headers. */ %endif -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif %# For compilers that can not handle prototypes. %# e.g., %# The function prototype %# int foo(int x, char* y); -%# +%# %# ...should be written as %# int foo M4_YY_PARAMS(int x, char* y); -%# +%# %# ...which could possibly generate %# int foo (); -%# +%# m4_ifdef( [[M4_YY_NO_ANSI_FUNC_PROTOS]], [[ m4_define( [[M4_YY_PARAMS]], [[()]]) @@ -329,7 +317,7 @@ m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) #define yy_flex_debug YY_G(yy_flex_debug_r) m4_define( [[M4_YY_INCR_LINENO]], -[[ +[[ do{ yylineno++; yycolumn=0; }while(0) @@ -342,7 +330,7 @@ m4_define( [[M4_YY_INCR_LINENO]], %if-not-reentrant m4_define( [[M4_YY_INCR_LINENO]], -[[ +[[ yylineno++; ]]) @@ -477,7 +465,7 @@ typedef size_t yy_size_t; #endif %if-not-reentrant -extern yy_size_t yyleng; +extern int yyleng; %endif %if-c-only @@ -499,7 +487,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* 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. + * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. @@ -556,7 +544,7 @@ struct yy_buffer_state %endif %if-c++-only - std::streambuf* yy_input_file; + std::streambuf* yy_input_file; %endif @@ -566,7 +554,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -594,7 +582,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. @@ -628,7 +616,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ %endif %ok-for-header %endif @@ -661,10 +649,10 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -697,7 +685,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], YY_BUFFER_STATE yy_scan_buffer M4_YY_PARAMS( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); YY_BUFFER_STATE yy_scan_string M4_YY_PARAMS( yyconst char *yy_str M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_bytes M4_YY_PARAMS( yyconst char *bytes, yy_size_t len M4_YY_PROTO_LAST_ARG ); +YY_BUFFER_STATE yy_scan_bytes M4_YY_PARAMS( yyconst char *bytes, int len M4_YY_PROTO_LAST_ARG ); %endif @@ -755,10 +743,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], static yy_state_type yy_get_previous_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); static yy_state_type yy_try_NUL_trans M4_YY_PARAMS( yy_state_type current_state M4_YY_PROTO_LAST_ARG); static int yy_get_next_buffer M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -#if defined(__GNUC__) && __GNUC__ >= 3 -__attribute__((__noreturn__)) -#endif -static void yy_fatal_error M4_YY_PARAMS( yyconst char msg[] M4_YY_PROTO_LAST_ARG ); +static void yynoreturn yy_fatal_error M4_YY_PARAMS( yyconst char* msg M4_YY_PROTO_LAST_ARG ); ]]) %endif @@ -832,7 +817,7 @@ struct yyguts_t YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; int yy_n_chars; - yy_size_t yyleng_r; + int yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -969,7 +954,7 @@ void yyset_out M4_YY_PARAMS( FILE * _out_str M4_YY_PROTO_LAST_ARG ); m4_ifdef( [[M4_YY_NO_GET_LENG]],, [[ -yy_size_t yyget_leng M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); + int yyget_leng M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); ]]) m4_ifdef( [[M4_YY_NO_GET_TEXT]],, @@ -1125,7 +1110,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) %endif %if-c++-only C++ definition #define ECHO LexerOutput( yytext, yyleng ) @@ -1191,7 +1176,7 @@ int yytables_destroy M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG); /** Describes a mapping from a serialized table id to its deserialized state in * this scanner. This is the bridge between our "generic" deserialization code - * and the specifics of this scanner. + * and the specifics of this scanner. */ struct yytbl_dmap { enum yytbl_id dm_id;/**< table identifier */ @@ -1533,7 +1518,7 @@ do_action: /* This label is used only to access EOF actions. */ * This constructor simply maintains backward compatibility. * DEPRECATED */ -yyFlexLexer::yyFlexLexer( FLEX_STD istream* arg_yyin, FLEX_STD ostream* arg_yyout ): +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) { @@ -1569,7 +1554,7 @@ void yyFlexLexer::ctor_common() yy_start_stack_ptr = yy_start_stack_depth = 0; yy_start_stack = NULL; - yy_buffer_stack = 0; + yy_buffer_stack = NULL; yy_buffer_stack_top = 0; yy_buffer_stack_max = 0; @@ -1718,7 +1703,7 @@ int yyFlexLexer::yy_get_next_buffer() else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1737,7 +1722,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]], if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1751,7 +1736,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]], } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1891,7 +1876,7 @@ m4_ifdef( [[M4_YY_NO_UNPUT]],, yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + YY_G(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -1946,7 +1931,7 @@ m4_ifdef( [[M4_YY_USE_LINENO]], else { /* need more input */ - yy_size_t offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr); + int offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr); ++YY_G(yy_c_buf_p); switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) @@ -1970,7 +1955,7 @@ m4_ifdef( [[M4_YY_USE_LINENO]], case EOB_ACT_END_OF_FILE: { if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - return EOF; + return 0; if ( ! YY_G(yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -2341,7 +2326,7 @@ static void yyensure_buffer_stack YYFARGS0(void) void yyFlexLexer::yyensure_buffer_stack(void) %endif { - yy_size_t num_to_alloc; + int num_to_alloc; M4_YY_DECL_GUTS_VAR(); if (!YY_G(yy_buffer_stack)) { @@ -2356,10 +2341,10 @@ void yyFlexLexer::yyensure_buffer_stack(void) M4_YY_CALL_LAST_ARG); if ( ! YY_G(yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - + + memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + YY_G(yy_buffer_stack_max) = num_to_alloc; YY_G(yy_buffer_stack_top) = 0; return; @@ -2395,7 +2380,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, * @param base the character buffer * @param size the size in bytes of the character buffer * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) { @@ -2406,7 +2391,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); if ( ! b ) @@ -2415,7 +2400,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; @@ -2445,7 +2430,7 @@ YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *, yystr) { m4_dnl M4_YY_DECL_GUTS_VAR(); - return yy_scan_bytes( yystr, strlen(yystr) M4_YY_CALL_LAST_ARG); + return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); } %endif ]]) @@ -2461,7 +2446,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, * M4_YY_DOC_PARAM * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, yy_size_t ,_yybytes_len) +YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, int ,_yybytes_len) { YY_BUFFER_STATE b; char *buf; @@ -2470,7 +2455,7 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, yy_size_t ,_yyb m4_dnl M4_YY_DECL_GUTS_VAR(); /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; + n = (yy_size_t) _yybytes_len + 2; buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); @@ -2510,7 +2495,7 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, yy_size_t new_size; YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; - new_size = YY_G(yy_start_stack_depth) * sizeof( int ); + new_size = (yy_size_t) YY_G(yy_start_stack_depth) * sizeof( int ); if ( ! YY_G(yy_start_stack) ) YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); @@ -2567,7 +2552,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, #endif %if-c-only -static void yy_fatal_error YYFARGS1(yyconst char*, msg) +static void yynoreturn yy_fatal_error YYFARGS1(yyconst char*, msg) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); @@ -2576,7 +2561,7 @@ static void yy_fatal_error YYFARGS1(yyconst char*, msg) } %endif %if-c++-only -void yyFlexLexer::LexerError( yyconst char msg[] ) +void yyFlexLexer::LexerError( yyconst char* msg ) { M4_YY_DECL_GUTS_VAR(); std::cerr << msg << std::endl; @@ -2628,7 +2613,7 @@ m4_ifdef( [[M4_YY_NO_GET_LINENO]],, int yyget_lineno YYFARGS0(void) { M4_YY_DECL_GUTS_VAR(); - + m4_ifdef( [[M4_YY_REENTRANT]], [[ if (! YY_CURRENT_BUFFER) @@ -2648,7 +2633,7 @@ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, int yyget_column YYFARGS0(void) { M4_YY_DECL_GUTS_VAR(); - + m4_ifdef( [[M4_YY_REENTRANT]], [[ if (! YY_CURRENT_BUFFER) @@ -2688,7 +2673,7 @@ m4_ifdef( [[M4_YY_NO_GET_LENG]],, /** Get the length of the current token. * M4_YY_DOC_PARAM */ -yy_size_t yyget_leng YYFARGS0(void) +int yyget_leng YYFARGS0(void) { M4_YY_DECL_GUTS_VAR(); return yyleng; @@ -2915,20 +2900,20 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - + yyset_extra (yy_user_defined, *ptr_yy_globals); - + return yy_init_globals ( *ptr_yy_globals ); } @@ -2951,10 +2936,10 @@ m4_ifdef( [[M4_YY_USE_LINENO]], yylineno = 1; ]]) ]]) - YY_G(yy_buffer_stack) = 0; + YY_G(yy_buffer_stack) = NULL; YY_G(yy_buffer_stack_top) = 0; YY_G(yy_buffer_stack_max) = 0; - YY_G(yy_c_buf_p) = (char *) 0; + YY_G(yy_c_buf_p) = NULL; YY_G(yy_init) = 0; YY_G(yy_start) = 0; @@ -2985,8 +2970,8 @@ m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], yyin = stdin; yyout = stdout; #else - yyin = (FILE *) 0; - yyout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by @@ -3083,7 +3068,7 @@ void *yyalloc YYFARGS1( yy_size_t ,size) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); - return (void *) malloc( size ); + return malloc(size); } ]]) @@ -3101,7 +3086,7 @@ void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } ]]) @@ -3216,7 +3201,7 @@ static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, return NULL; } -/** Read a table while mapping its contents to the local array. +/** Read a table while mapping its contents to the local array. * @param dmap used to performing mapping * @return 0 on success */ @@ -3261,7 +3246,7 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read if(M4_YY_TABLES_VERIFY) /* We point to the array itself */ - p = dmap->dm_arr; + p = dmap->dm_arr; else /* We point to the address of a pointer. */ *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); @@ -3308,7 +3293,7 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read rv = yytbl_read8 (&t8, rd); t32 = t8; break; - default: + default: YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ return -1; } @@ -3365,7 +3350,7 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ return -1; } - + if( M4_YY_TABLES_VERIFY) v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); else @@ -3376,7 +3361,7 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); }else ((struct yy_trans_info **) p)[0] = v; - + /* increment p */ p = (struct yy_trans_info **) p + 1; } @@ -3492,7 +3477,7 @@ int yytables_fload YYFARGS1(FILE *, fp) /** Destroy the loaded tables, freeing memory, etc.. */ int yytables_destroy YYFARGS0(void) -{ +{ struct yytbl_dmap *dmap=0; if(!M4_YY_TABLES_VERIFY){ |