diff options
Diffstat (limited to 'usr.bin/lex/flex.skl')
-rw-r--r-- | usr.bin/lex/flex.skl | 520 |
1 files changed, 413 insertions, 107 deletions
diff --git a/usr.bin/lex/flex.skl b/usr.bin/lex/flex.skl index 01ff7a1..67ebe57 100644 --- a/usr.bin/lex/flex.skl +++ b/usr.bin/lex/flex.skl @@ -1,10 +1,12 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/flex-2.4.7/RCS/flex.skl,v 1.2 94/08/03 11:13:24 vern Exp $ + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.89 96/05/25 21:02:21 vern Exp $ */ #define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 %- #include <stdio.h> @@ -35,7 +37,7 @@ class istream; #else /* ! __cplusplus */ -#ifdef __STDC__ +#if __STDC__ #define YY_USE_PROTOS #define YY_USE_CONST @@ -43,16 +45,19 @@ class istream; #endif /* __STDC__ */ #endif /* ! __cplusplus */ - #ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include <io.h> +#include <stdlib.h> #define YY_USE_CONST +#define YY_USE_PROTOS #endif - -#ifndef YY_USE_CONST -#ifndef const -#define const -#endif +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst #endif @@ -79,16 +84,16 @@ class istream; #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. */ #define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". Now included - * only for backward compatibility with previous versions of flex. - */ +/* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 @@ -103,14 +108,6 @@ extern int yyleng; extern FILE *yyin, *yyout; %* -#ifdef __cplusplus -extern "C" { -#endif - extern int yywrap YY_PROTO(( void )); -#ifdef __cplusplus - } -#endif - #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -136,6 +133,7 @@ extern "C" { { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ @@ -143,6 +141,12 @@ extern "C" { #define unput(c) yyunput( c, yytext_ptr ) +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + struct yy_buffer_state { @@ -158,13 +162,19 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - int yy_buf_size; + yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after @@ -172,6 +182,12 @@ struct yy_buffer_state */ int yy_is_interactive; + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -223,47 +239,50 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -static void yyunput YY_PROTO(( int c, char *buf_ptr )); void yyrestart YY_PROTO(( FILE *input_file )); + void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); void yy_load_buffer_state YY_PROTO(( void )); YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -static void yy_push_state YY_PROTO(( int new_state )); -static void yy_pop_state YY_PROTO(( void )); -static int yy_top_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); %* -static void *yy_flex_alloc YY_PROTO(( unsigned int )); -static void *yy_flex_realloc YY_PROTO(( void *, unsigned int )); +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer -%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, const char *, int )); -#endif +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } -%- Standard (non-C++) definition -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -%* +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + +%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here %- Standard (non-C++) definition static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( const char msg[] )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); %* /* Done after the current pattern has been matched and before the @@ -283,6 +302,58 @@ static void yy_fatal_error YY_PROTO(( const char msg[] )); * section 1. */ +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +%- +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif +%* + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +%- Standard (non-C++) definition +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +%* +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else @@ -373,6 +444,8 @@ YY_MALLOC_DECL #define YY_BREAK break; #endif +%% YY_RULE_SETUP definition goes here + YY_DECL { register yy_state_type yy_current_state; @@ -383,6 +456,8 @@ YY_DECL if ( yy_init ) { + yy_init = 0; + #ifdef YY_USER_INIT YY_USER_INIT; #endif @@ -404,15 +479,11 @@ YY_DECL yyout = &cout; %* - if ( yy_current_buffer ) - yy_init_buffer( yy_current_buffer, yyin ); - else + if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); - - yy_init = 0; } while ( 1 ) /* loops until end-of-file is reached */ @@ -435,7 +506,7 @@ yy_find_action: YY_DO_BEFORE_ACTION; -%% code for yylineno update goes here, if -l option +%% code for yylineno update goes here do_action: /* This label is used only to access EOF actions. */ @@ -448,10 +519,11 @@ do_action: /* This label is used only to access EOF actions. */ case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { @@ -574,6 +646,53 @@ do_action: /* This label is used only to access EOF actions. */ } /* end of yylex */ %+ +yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout ) + { + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 1; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = 0; + + yy_current_buffer = 0; + +#ifdef YY_USES_REJECT + yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2]; +#else + yy_state_buf = 0; +#endif + } + +yyFlexLexer::~yyFlexLexer() + { + delete yy_state_buf; + yy_delete_buffer( yy_current_buffer ); + } + +void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out ) + { + if ( new_in ) + { + yy_delete_buffer( yy_current_buffer ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; + } + #ifdef YY_INTERACTIVE int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) #else @@ -625,7 +744,7 @@ int yyFlexLexer::yy_get_next_buffer() %* { register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr - 1; /* copy prev. char, too */ + register char *source = yytext_ptr; register int number_to_move, i; int ret_val; @@ -637,7 +756,7 @@ int yyFlexLexer::yy_get_next_buffer() { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { - /* We matched a singled characater, the EOB, so + /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; @@ -655,7 +774,7 @@ int yyFlexLexer::yy_get_next_buffer() /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = yy_c_buf_p - yytext_ptr; + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -681,12 +800,26 @@ int yyFlexLexer::yy_get_next_buffer() /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; - int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf; + int yy_c_buf_p_offset = + (int) (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_buf_size *= 2; - b->yy_ch_buf = (char *) - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size ); + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -709,7 +842,7 @@ int yyFlexLexer::yy_get_next_buffer() if ( yy_n_chars == 0 ) { - if ( number_to_move - YY_MORE_ADJ == 1 ) + if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); @@ -730,13 +863,7 @@ int yyFlexLexer::yy_get_next_buffer() yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - /* yytext begins at the second character in yy_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * yy_get_previous_state() will have with '^' rules active. - */ - - yytext_ptr = &yy_current_buffer->yy_ch_buf[1]; + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; } @@ -789,6 +916,7 @@ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) %- +#ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS static void yyunput( int c, register char *yy_bp ) #else @@ -817,26 +945,25 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp ) while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; - yy_cp += dest - source; - yy_bp += dest - source; + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } - if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) - yy_cp[-2] = '\n'; - *--yy_cp = (char) c; -%% update yylineno here, if doing -l +%% update yylineno here - /* Note: the formal parameter *must* be called "yy_bp" for this - * macro to now work correctly. - */ - YY_DO_BEFORE_ACTION; /* set up yytext again */ + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; } +%- +#endif /* ifndef YY_NO_UNPUT */ +%* %- @@ -865,7 +992,7 @@ int yyFlexLexer::yyinput() else { /* need more input */ - yytext_ptr = yy_c_buf_p; + int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) @@ -874,12 +1001,12 @@ int yyFlexLexer::yyinput() { if ( yywrap() ) { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; + yy_c_buf_p = yytext_ptr + offset; return EOF; } - YY_NEW_FILE; + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else @@ -888,7 +1015,7 @@ int yyFlexLexer::yyinput() } case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + yy_c_buf_p = yytext_ptr + offset; break; case EOB_ACT_LAST_MATCH: @@ -907,6 +1034,8 @@ int yyFlexLexer::yyinput() *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; +%% update BOL and yylineno + return c; } @@ -996,7 +1125,6 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size ) YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1006,10 +1134,11 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size ) * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + b->yy_is_our_buffer = 1; + yy_init_buffer( b, file ); return b; @@ -1027,15 +1156,26 @@ YY_BUFFER_STATE b; void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) %* { + if ( ! b ) + return; + if ( b == yy_current_buffer ) yy_current_buffer = (YY_BUFFER_STATE) 0; - yy_flex_free( (void *) b->yy_ch_buf ); + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + yy_flex_free( (void *) b ); } %- +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else @@ -1043,40 +1183,167 @@ void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif + %+ +extern "C" int isatty YY_PROTO(( int )); void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file ) %* + { + yy_flush_buffer( b ); + b->yy_input_file = file; + b->yy_fill_buffer = 1; - /* We put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ +%- +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif +%+ + b->yy_is_interactive = 0; +%* + } - b->yy_ch_buf[0] = '\n'; - b->yy_n_chars = 1; + +%- +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + +%+ +void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +%* + { + b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[1]; + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } +%* + + +#ifndef YY_NO_SCAN_BUFFER %- - b->yy_is_interactive = file ? isatty( fileno(file) ) : 0; -%+ +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + 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; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + 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_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } %* +#endif - b->yy_fill_buffer = 1; - b->yy_buffer_status = YY_BUFFER_NEW; +#ifndef YY_NO_SCAN_STRING +%- +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *str ) +#else +YY_BUFFER_STATE yy_scan_string( str ) +yyconst char *str; +#endif + { + int len; + for ( len = 0; str[len]; ++len ) + ; + + return yy_scan_bytes( str, len ); } +%* +#endif +#ifndef YY_NO_SCAN_BYTES +%- +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +%* +#endif + + +#ifndef YY_NO_PUSH_STATE %- #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) @@ -1090,7 +1357,7 @@ void yyFlexLexer::yy_push_state( int new_state ) { if ( yy_start_stack_ptr >= yy_start_stack_depth ) { - int new_size; + yy_size_t new_size; yy_start_stack_depth += YY_START_STACK_INCR; new_size = yy_start_stack_depth * sizeof( int ); @@ -1111,8 +1378,10 @@ void yyFlexLexer::yy_push_state( int new_state ) BEGIN(new_state); } +#endif +#ifndef YY_NO_POP_STATE %- static void yy_pop_state() %+ @@ -1124,8 +1393,10 @@ void yyFlexLexer::yy_pop_state() BEGIN(yy_start_stack[yy_start_stack_ptr]); } +#endif +#ifndef YY_NO_TOP_STATE %- static int yy_top_state() %+ @@ -1134,26 +1405,30 @@ int yyFlexLexer::yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } +#endif +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif %- #ifdef YY_USE_PROTOS -static void yy_fatal_error( const char msg[] ) +static void yy_fatal_error( yyconst char msg[] ) #else static void yy_fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); - exit( 1 ); + exit( YY_EXIT_FAILURE ); } %+ -void yyFlexLexer::LexerError( const char msg[] ) +void yyFlexLexer::LexerError( yyconst char msg[] ) { cerr << msg << '\n'; - exit( 1 ); + exit( YY_EXIT_FAILURE ); } %* @@ -1166,7 +1441,7 @@ void yyFlexLexer::LexerError( const char msg[] ) { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ + yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ @@ -1178,11 +1453,11 @@ void yyFlexLexer::LexerError( const char msg[] ) #ifndef yytext_ptr #ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, const char *s2, int n ) +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else static void yy_flex_strncpy( s1, s2, n ) char *s1; -const char *s2; +yyconst char *s2; int n; #endif { @@ -1192,26 +1467,49 @@ int n; } #endif +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + #ifdef YY_USE_PROTOS -static void *yy_flex_alloc( unsigned int size ) +static void *yy_flex_alloc( yy_size_t size ) #else static void *yy_flex_alloc( size ) -unsigned int size; +yy_size_t size; #endif { return (void *) malloc( size ); } #ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, unsigned int size ) +static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else static void *yy_flex_realloc( ptr, size ) void *ptr; -unsigned int size; +yy_size_t size; #endif { - return (void *) realloc( ptr, size ); + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS @@ -1223,3 +1521,11 @@ void *ptr; { free( ptr ); } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif |