diff options
author | John Millaway <john43@users.sourceforge.net> | 2002-09-07 22:40:04 +0000 |
---|---|---|
committer | John Millaway <john43@users.sourceforge.net> | 2002-09-07 22:40:04 +0000 |
commit | 2b672d65bb1b105bb8ffa143a6d0991b0e6f3dc7 (patch) | |
tree | 4d323b0788a7617fc489aa585e7f8244691fdfb1 | |
parent | 204c1a336e56f9b110abae83efe6f1a843e39351 (diff) |
Changed cryptic skeleton markers to readable form.
-rw-r--r-- | flex.skl | 307 | ||||
-rw-r--r-- | misc.c | 208 |
2 files changed, 270 insertions, 245 deletions
@@ -2,18 +2,20 @@ /* A lexical scanner generated by flex */ %# Lines in this skeleton starting with a '%' character are "control lines" -%# and affect the generation of the scanner. The possible control codes are: +%# and affect the generation of the scanner. The possible control codes are +%# listed and processed in misc.c. %# %# %# - A comment. The current line is ommited from the generated scanner. -%# %+ - The following lines are printed for C++ scanners ONLY. -%# %- - The following lines are NOT printed for C++ scanners. -%# %* - The following lines are printed in BOTH C and C++ scanners. +%# %c++-only - The following lines are printed for C++ scanners ONLY. +%# %c-only - The following lines are NOT printed for C++ scanners. +%# %c-or-c++ - The following lines are printed in BOTH C and C++ scanners. %# %% - A stop-point, where code is inserted by flex. %# Each stop-point is numbered here and also in the code generator. %# (See gen.c, etc. for details.) -%# %c - Begin linkage code that should NOT appear in a ".h" file. -%# %e - End linkage code. %c and %e are used for building a header file. -%# %t - Toggle output of Tables API. +%# %not-for-header - Begin code that should NOT appear in a ".h" file. +%# %ok-for-header - %c and %e are used for building a header file. +%# %tables-serialization-code-begin +%# %tables-serialization-code-end %# %# All control-lines EXCEPT comment lines ("%#") will be inserted into %# the generated scanner as a C-style comment. This is to aid those who @@ -25,23 +27,23 @@ /* First, we deal with platform-specific or compiler-specific issues. */ -%- +%c-only /* begin standard C headers. */ #include <stdio.h> #include <errno.h> #include <stdlib.h> -%t +%tables-serialization-code-begin #include <stdint.h> #include <netinet/in.h> -%t +%tables-serialization-code-end /* end standard C headers. */ -%+ +%c++-only /* begin standard C++ headers. */ #include <iostream> #include <cerrno> #include <cstdlib> /* end standard C++ headers. */ -%* +%c-or-c++ #ifdef __cplusplus @@ -49,9 +51,9 @@ #ifdef YY_TRADITIONAL_FUNC_DEFS #undef YY_TRADITIONAL_FUNC_DEFS #endif -%+ +%c++-only #define FLEX_STD std:: -%* +%c-or-c++ /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST @@ -227,11 +229,11 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; extern size_t yyleng; #endif -%- +%c-only #ifndef YY_REENTRANT extern FILE *yyin, *yyout; #endif -%* +%c-or-c++ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 @@ -300,11 +302,11 @@ typedef unsigned int yy_size_t; #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { -%- +%c-only FILE *yy_input_file; -%+ +%c++-only FLEX_STD istream* yy_input_file; -%* +%c-or-c++ char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -360,13 +362,13 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -%- Standard (non-C++) definition -%c +%c-only Standard (non-C++) definition +%not-for-header #ifndef YY_REENTRANT static YY_BUFFER_STATE yy_current_buffer = 0; #endif -%e -%* +%ok-for-header +%c-or-c++ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -375,10 +377,10 @@ static YY_BUFFER_STATE yy_current_buffer = 0; #define YY_CURRENT_BUFFER yy_current_buffer -%- Standard (non-C++) definition +%c-only Standard (non-C++) definition #ifndef YY_REENTRANT -%c +%not-for-header /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; @@ -396,7 +398,7 @@ static int yy_start = 0; /* start state number */ * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; -%e +%ok-for-header #endif /* end !YY_REENTRANT */ void yyrestart YY_PARAMS(( FILE *input_file YY_PROTO_LAST_ARG )); @@ -415,7 +417,7 @@ YY_BUFFER_STATE yy_scan_buffer YY_PARAMS(( char *base, yy_size_t size YY_PROTO_L YY_BUFFER_STATE yy_scan_string YY_PARAMS(( yyconst char *yy_str YY_PROTO_LAST_ARG )); YY_BUFFER_STATE yy_scan_bytes YY_PARAMS(( yyconst char *bytes, int len YY_PROTO_LAST_ARG )); -%* +%c-or-c++ void *yyalloc YY_PARAMS(( yy_size_t YY_PROTO_LAST_ARG )); @@ -444,14 +446,14 @@ void yyfree YY_PARAMS(( void * YY_PROTO_LAST_ARG )); %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here -%- Standard (non-C++) definition -%c +%c-only Standard (non-C++) definition +%not-for-header static yy_state_type yy_get_previous_state YY_PARAMS(( YY_PROTO_ONLY_ARG )); static yy_state_type yy_try_NUL_trans YY_PARAMS(( yy_state_type current_state YY_PROTO_LAST_ARG)); static int yy_get_next_buffer YY_PARAMS(( YY_PROTO_ONLY_ARG )); static void yy_fatal_error YY_PARAMS(( yyconst char msg[] YY_PROTO_LAST_ARG )); -%e -%* +%ok-for-header +%c-or-c++ /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -464,24 +466,24 @@ static void yy_fatal_error YY_PARAMS(( yyconst char msg[] YY_PROTO_LAST_ARG )); %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ YY_G(yy_c_buf_p) = yy_cp; -%* +%c-or-c++ -%c +%not-for-header %% [4.0] data tables for the DFA and the user's section 1 definitions go here -%e +%ok-for-header /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #ifndef YY_NO_UNISTD_H -%- +%c-only #include <unistd.h> -%+ +%c++-only #ifdef HAVE_CUNISTD #include <cunistd> #endif -%* +%c-or-c++ #endif /* !YY_NO_UNISTD_H */ @@ -489,10 +491,10 @@ static void yy_fatal_error YY_PARAMS(( yyconst char msg[] YY_PROTO_LAST_ARG )); #define YY_EXTRA_TYPE void * #endif -%- Reentrant structure and macros (non-C++). +%c-only Reentrant structure and macros (non-C++). #ifdef YY_REENTRANT -%c +%not-for-header /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { @@ -545,13 +547,13 @@ struct yyguts_t #endif }; -%e +%ok-for-header -%c +%not-for-header static int yy_init_globals YY_PARAMS(( YY_PROTO_ONLY_ARG )); -%e +%ok-for-header -%c These go in the .c file only. +%not-for-header These go in the .c file only. /* This must go here because YYSTYPE and YYLSTYPE are included * from bison output in section 1.*/ #ifdef YY_REENTRANT_BISON_PURE @@ -560,7 +562,7 @@ static int yy_init_globals YY_PARAMS(( YY_PROTO_ONLY_ARG )); # define yylloc YY_G(yylloc_r) # endif #endif /* YY_REENTRANT_BISON_PURE */ -%e +%ok-for-header #endif /* end if YY_REENTRANT */ @@ -646,13 +648,13 @@ extern int yywrap YY_PARAMS(( YY_PROTO_ONLY_ARG )); #endif #endif -%- -%c +%c-only +%not-for-header #ifndef YY_NO_UNPUT static void yyunput YY_PARAMS(( int c, char *buf_ptr YY_PROTO_LAST_ARG)); #endif -%e -%* +%ok-for-header +%c-or-c++ #ifndef yytext_ptr static void yy_flex_strncpy YY_PARAMS(( char *, yyconst char *, int YY_PROTO_LAST_ARG)); @@ -663,24 +665,24 @@ static int yy_flex_strlen YY_PARAMS(( yyconst char * YY_PROTO_LAST_ARG)); #endif #ifndef YY_NO_INPUT -%- Standard (non-C++) definition -%c +%c-only Standard (non-C++) definition +%not-for-header #ifdef __cplusplus static int yyinput YY_PARAMS(( YY_PROTO_ONLY_ARG )); #else static int input YY_PARAMS(( YY_PROTO_ONLY_ARG )); #endif -%e -%* +%ok-for-header +%c-or-c++ #endif #if YY_STACK_USED #ifndef YY_REENTRANT -%c +%not-for-header static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; -%e +%ok-for-header #endif #ifndef YY_NO_PUSH_STATE static void yy_push_state YY_PARAMS(( int new_state YY_PROTO_LAST_ARG)); @@ -706,14 +708,14 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG )); /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO -%- Standard (non-C++) definition +%c-only Standard (non-C++) definition /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -%+ C++ definition +%c++-only C++ definition #define ECHO LexerOutput( yytext, yyleng ) -%* +%c-or-c++ #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -722,10 +724,10 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG )); #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ -%+ C++ definition \ +%c++-only C++ definition \ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); -%* +%c-or-c++ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -743,14 +745,14 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG )); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -%- +%c-only #define YY_FATAL_ERROR(msg) yy_fatal_error( msg YY_CALL_LAST_ARG) -%+ +%c++-only #define YY_FATAL_ERROR(msg) LexerError( msg ) -%* +%c-or-c++ #endif -%t Tables API Structures and Prototypes +%tables-serialization-code-begin structures and prototypes m4_include(`tables_shared.h') /* Load the DFA tables from the given stream. */ @@ -768,15 +770,20 @@ struct yytbl_dmap { }; /** A {0,0,0}-terminated list of structs, forming the map */ -extern struct yytbl_dmap * yydmap; +static struct yytbl_dmap yydmap[] = +{ +%tables-yydmap generated elements + {0,0,0} +}; + -%t End of Tables API Structures and Prototypes +%tables-serialization-code-end structures and prototypes /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL -%- Standard (non-C++) definition +%c-only Standard (non-C++) definition /* If the bison pure parser is used, then bison will provide one or two additional arguments. */ @@ -798,9 +805,9 @@ extern struct yytbl_dmap * yydmap; extern int yylex YY_LEX_PROTO; #define YY_DECL int yylex YY_LEX_DECLARATION -%+ C++ definition +%c++-only C++ definition #define YY_DECL int yyFlexLexer::yylex() -%* +%c-or-c++ #endif /* Code executed at the beginning of each rule, after yytext and yyleng @@ -817,7 +824,7 @@ extern int yylex YY_LEX_PROTO; %% [6.0] YY_RULE_SETUP definition goes here -%c +%not-for-header YY_DECL { register yy_state_type yy_current_state; @@ -850,18 +857,18 @@ YY_DECL YY_G(yy_start) = 1; /* first start state */ if ( ! yyin ) -%- +%c-only yyin = stdin; -%+ +%c++-only yyin = & FLEX_STD cin; -%* +%c-or-c++ if ( ! yyout ) -%- +%c-only yyout = stdout; -%+ +%c++-only yyout = & FLEX_STD cout; -%* +%c-or-c++ if ( ! YY_G(yy_current_buffer) ) YY_G(yy_current_buffer) = @@ -1028,9 +1035,9 @@ do_action: /* This label is used only to access EOF actions. */ } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ -%e -%+ -%c +%ok-for-header +%c++-only +%not-for-header yyFlexLexer::yyFlexLexer( FLEX_STD istream* arg_yyin, FLEX_STD ostream* arg_yyout ) { yyin = arg_yyin; @@ -1113,8 +1120,8 @@ void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout->write( buf, size ); } -%e -%* +%ok-for-header +%c-or-c++ /* yy_get_next_buffer - try to read in a new buffer * @@ -1124,12 +1131,12 @@ void yyFlexLexer::LexerOutput( const char* buf, int size ) * EOB_ACT_END_OF_FILE - end of file */ -%- -%c +%c-only +%not-for-header static int yy_get_next_buffer YYFARGS0(void) -%+ +%c++-only int yyFlexLexer::yy_get_next_buffer() -%* +%c-or-c++ { register char *dest = YY_G(yy_current_buffer)->yy_ch_buf; register char *source = YY_G(yytext_ptr); @@ -1257,16 +1264,16 @@ int yyFlexLexer::yy_get_next_buffer() return ret_val; } -%e +%ok-for-header /* yy_get_previous_state - get the state just before the EOB char was reached */ -%- -%c +%c-only +%not-for-header static yy_state_type yy_get_previous_state YYFARGS0(void) -%+ +%c++-only yy_state_type yyFlexLexer::yy_get_previous_state() -%* +%c-or-c++ { register yy_state_type yy_current_state; register char *yy_cp; @@ -1288,11 +1295,11 @@ yy_state_type yyFlexLexer::yy_get_previous_state() * next_state = yy_try_NUL_trans( current_state ); */ -%- +%c-only static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) -%+ +%c++-only yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -%* +%c-or-c++ { register int yy_is_jam; %% [17.0] code to find the next state, and perhaps do backing up, goes here @@ -1301,12 +1308,12 @@ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) } -%- +%c-only #ifndef YY_NO_UNPUT static void yyunput YYFARGS2( int,c, register char *,yy_bp) -%+ +%c++-only void yyFlexLexer::yyunput( int c, register char* yy_bp) -%* +%c-or-c++ { register char *yy_cp = YY_G(yy_c_buf_p); @@ -1345,21 +1352,21 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp) YY_G(yy_hold_char) = *yy_cp; YY_G(yy_c_buf_p) = yy_cp; } -%- +%c-only #endif /* ifndef YY_NO_UNPUT */ -%* +%c-or-c++ -%- +%c-only #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YYFARGS0(void) #else static int input YYFARGS0(void) #endif -%+ +%c++-only int yyFlexLexer::yyinput() -%* +%c-or-c++ { int c; @@ -1427,15 +1434,15 @@ int yyFlexLexer::yyinput() return c; } -%- +%c-only #endif /* ifndef YY_NO_INPUT */ -%* +%c-or-c++ -%- +%c-only void yyrestart YYFARGS1( FILE *,input_file) -%+ +%c++-only void yyFlexLexer::yyrestart( FLEX_STD istream* input_file ) -%* +%c-or-c++ { if ( ! YY_G(yy_current_buffer) ) YY_G(yy_current_buffer) = @@ -1446,11 +1453,11 @@ void yyFlexLexer::yyrestart( FLEX_STD istream* input_file ) } -%- +%c-only void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) -%+ +%c++-only void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -%* +%c-or-c++ { if ( YY_G(yy_current_buffer) == new_buffer ) return; @@ -1475,11 +1482,11 @@ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) } -%- +%c-only void yy_load_buffer_state YYFARGS0(void) -%+ +%c++-only void yyFlexLexer::yy_load_buffer_state() -%* +%c-or-c++ { YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars; YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_G(yy_current_buffer)->yy_buf_pos; @@ -1488,11 +1495,11 @@ void yyFlexLexer::yy_load_buffer_state() } -%- +%c-only YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) -%+ +%c++-only YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( FLEX_STD istream* file, int size ) -%* +%c-or-c++ { YY_BUFFER_STATE b; @@ -1517,11 +1524,11 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( FLEX_STD istream* file, int size } -%- +%c-only void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) -%+ +%c++-only void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) -%* +%c-or-c++ { if ( ! b ) return; @@ -1536,7 +1543,7 @@ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) } -%- +%c-only #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE #ifndef __cplusplus @@ -1546,12 +1553,12 @@ extern int isatty YY_PARAMS(( int )); #endif /* !YY_ALWAYS_INTERACTIVE */ void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) -%+ +%c++-only #ifndef YY_NEVER_INTERACTIVE extern "C" int isatty YY_PARAMS(( int )); #endif void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, FLEX_STD istream* file ) -%* +%c-or-c++ { int oerrno = errno; @@ -1561,7 +1568,7 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, FLEX_STD istream* file ) b->yy_input_file = file; b->yy_fill_buffer = 1; -%- +%c-only #if YY_ALWAYS_INTERACTIVE b->yy_is_interactive = 1; #else @@ -1571,18 +1578,18 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, FLEX_STD istream* file ) b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif -%+ +%c++-only b->yy_is_interactive = 0; -%* +%c-or-c++ errno = oerrno; } -%- +%c-only void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) -%+ +%c++-only void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) -%* +%c-or-c++ { if ( ! b ) return; @@ -1604,11 +1611,11 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) if ( b == YY_G(yy_current_buffer) ) yy_load_buffer_state( YY_CALL_ONLY_ARG ); } -%* +%c-or-c++ #ifndef YY_NO_SCAN_BUFFER -%- +%c-only YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) { YY_BUFFER_STATE b; @@ -1637,12 +1644,12 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) return b; } -%* +%c-or-c++ #endif #ifndef YY_NO_SCAN_STRING -%- +%c-only YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *,yy_str) { int len; @@ -1651,12 +1658,12 @@ YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *,yy_str) return yy_scan_bytes( yy_str, len YY_CALL_LAST_ARG); } -%* +%c-or-c++ #endif #ifndef YY_NO_SCAN_BYTES -%- +%c-only YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len) { YY_BUFFER_STATE b; @@ -1686,16 +1693,16 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len) return b; } -%* +%c-or-c++ #endif #ifndef YY_NO_PUSH_STATE -%- +%c-only static void yy_push_state YYFARGS1( int ,new_state) -%+ +%c++-only void yyFlexLexer::yy_push_state( int new_state ) -%* +%c-or-c++ { if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) { @@ -1724,11 +1731,11 @@ void yyFlexLexer::yy_push_state( int new_state ) #ifndef YY_NO_POP_STATE -%- +%c-only static void yy_pop_state YYFARGS0(void) -%+ +%c++-only void yyFlexLexer::yy_pop_state() -%* +%c-or-c++ { if ( --YY_G(yy_start_stack_ptr) < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); @@ -1739,11 +1746,11 @@ void yyFlexLexer::yy_pop_state() #ifndef YY_NO_TOP_STATE -%- +%c-only static int yy_top_state YYFARGS0(void) -%+ +%c++-only int yyFlexLexer::yy_top_state() -%* +%c-or-c++ { return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1]; } @@ -1753,21 +1760,21 @@ int yyFlexLexer::yy_top_state() #define YY_EXIT_FAILURE 2 #endif -%- +%c-only static void yy_fatal_error YYFARGS1(yyconst char*, msg) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } -%+ +%c++-only void yyFlexLexer::LexerError( yyconst char msg[] ) { FLEX_STD cerr << msg << '\n'; exit( YY_EXIT_FAILURE ); } -%* +%c-or-c++ /* Redefine yyless() so it works in section 3 code. */ @@ -1978,7 +1985,7 @@ int yylex_init( ptr_yy_globals ) /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy YYFARGS0(void) { -%- SNIP! this currently causes conflicts with the c++ scanner +%c-only SNIP! this currently causes conflicts with the c++ scanner /* Destroy the current (main) buffer. */ yy_delete_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG ); YY_G(yy_current_buffer) = NULL; @@ -2000,7 +2007,7 @@ int yylex_destroy YYFARGS0(void) /* Destroy the main struct (reentrant only). */ yyfree ( yyscanner YY_CALL_LAST_ARG ); #endif -%* +%c-or-c++ return 0; } @@ -2061,7 +2068,7 @@ void yyfree YYFARGS1( void *,ptr) } #endif -%t Tables API Definitions +%tables-serialization-code-begin definitions m4_include(`tables_shared.c') static int yytbl_read8 (void *v, FILE * fp) @@ -2293,7 +2300,7 @@ int yytables_load YYFARGS1 (FILE *, fp) return 0; } -%t End of Tables API Definitions +%tables-serialization-code-end definitions #if YY_MAIN int main YY_PARAMS((void)); @@ -2314,4 +2321,4 @@ int main () return 0; } #endif -%e +%ok-for-header @@ -34,17 +34,26 @@ #include "flexdef.h" #include "tables.h" +#define CMD_TABLES_SER_BEGIN "%tables-serialization-code-begin" +#define CMD_TABLES_SER_END "%tables-serialization-code-end" +#define CMD_TABLES_YYDMAP "%tables-yydmap" +#define CMD_CPP_ONLY "%c++-only" +#define CMD_C_ONLY "%c-only" +#define CMD_C_OR_CPP "%c-or-c++" +#define CMD_NOT_FOR_HEADER "%not-for-header" +#define CMD_OK_FOR_HEADER "%ok-for-header" + /* Append "#define defname value\n" to the running buffer. */ -void action_define (defname, value) +void action_define (defname, value) const char *defname; - int value; + int value; { char buf[MAXLINE]; char *cpy; if ((int) strlen (defname) > MAXLINE / 2) { - format_pinpoint_message ( - _("name \"%s\" ridiculously long"), + format_pinpoint_message (_ + ("name \"%s\" ridiculously long"), defname); return; } @@ -59,7 +68,7 @@ void action_define (defname, value) /* Append "new_text" to the running buffer. */ -void add_action (new_text) +void add_action (new_text) char *new_text; { int len = strlen (new_text); @@ -89,16 +98,16 @@ void add_action (new_text) /* allocate_array - allocate memory for an integer array of the given size */ void *allocate_array (size, element_size) - int size; - size_t element_size; + int size; + size_t element_size; { register void *mem; size_t num_bytes = element_size * size; mem = flex_alloc (num_bytes); if (!mem) - flexfatal ( - _("memory allocation failed in allocate_array()")); + flexfatal (_ + ("memory allocation failed in allocate_array()")); return mem; } @@ -106,7 +115,7 @@ void *allocate_array (size, element_size) /* all_lower - true if a string is all lower-case */ -int all_lower (str) +int all_lower (str) register char *str; { while (*str) { @@ -121,7 +130,7 @@ int all_lower (str) /* all_upper - true if a string is all upper-case */ -int all_upper (str) +int all_upper (str) register char *str; { while (*str) { @@ -149,8 +158,8 @@ int all_upper (str) * n - the number of elements of 'v' to be sorted */ -void bubble (v, n) - int v[], n; +void bubble (v, n) + int v[], n; { register int i, j, k; @@ -169,24 +178,24 @@ void bubble (v, n) * and exits. */ -void check_char (c) - int c; +void check_char (c) + int c; { if (c >= CSIZE) lerrsf (_("bad character '%s' detected in check_char()"), readable_form (c)); if (c >= csize) - lerrsf ( - _("scanner requires -8 flag to use the character %s"), -readable_form (c)); + lerrsf (_ + ("scanner requires -8 flag to use the character %s"), + readable_form (c)); } /* clower - replace upper-case letter to lower-case */ -Char clower (c) +Char clower (c) register int c; { return (Char) ((isascii (c) && isupper (c)) ? tolower (c) : c); @@ -258,9 +267,9 @@ Char *copy_unsigned_string (str) * n - number of elements of v to be sorted */ -void cshell (v, n, special_case_0) - Char v[]; - int n, special_case_0; +void cshell (v, n, special_case_0) + Char v[]; + int n, special_case_0; { int gap, i, j, jg; Char k; @@ -275,7 +284,8 @@ void cshell (v, n, special_case_0) break; else if (v[j] != 0 - && v[j] <= v[jg]) break; + && v[j] <= v[jg]) + break; } else if (v[j] <= v[jg]) @@ -290,7 +300,7 @@ void cshell (v, n, special_case_0) /* dataend - finish up a block of data declarations */ -void dataend () +void dataend () { if (datapos > 0) dataflush (); @@ -305,7 +315,7 @@ void dataend () /* dataflush - flush generated data statements */ -void dataflush () +void dataflush () { outc ('\n'); @@ -324,7 +334,7 @@ void dataflush () /* flexerror - report an error message and terminate */ -void flexerror (msg) +void flexerror (msg) const char *msg; { fprintf (stderr, "%s: %s\n", program_name, msg); @@ -334,7 +344,7 @@ void flexerror (msg) /* flexfatal - report a fatal error message and terminate */ -void flexfatal (msg) +void flexfatal (msg) const char *msg; { fprintf (stderr, _("%s: fatal internal error, %s\n"), @@ -345,8 +355,8 @@ void flexfatal (msg) /* htoi - convert a hexadecimal digit string to an integer value */ -int htoi (str) - Char str[]; +int htoi (str) + Char str[]; { unsigned int result; @@ -358,9 +368,9 @@ int htoi (str) /* lerrif - report an error message formatted with one integer argument */ -void lerrif (msg, arg) +void lerrif (msg, arg) const char *msg; - int arg; + int arg; { char errmsg[MAXLINE]; @@ -371,7 +381,7 @@ void lerrif (msg, arg) /* lerrsf - report an error message formatted with one string argument */ -void lerrsf (msg, arg) +void lerrsf (msg, arg) const char *msg, arg[]; { char errmsg[MAXLINE]; @@ -383,9 +393,9 @@ void lerrsf (msg, arg) /* line_directive_out - spit out a "#line" statement */ -void line_directive_out (output_file, do_infile) +void line_directive_out (output_file, do_infile) FILE *output_file; - int do_infile; + int do_infile; { char directive[MAXLINE], filename[MAXLINE]; char *s1, *s2, *s3; @@ -437,7 +447,7 @@ void line_directive_out (output_file, do_infile) * representing where the user's section 1 definitions end * and the prolog begins */ -void mark_defs1 () +void mark_defs1 () { defs1_offset = 0; action_array[action_index++] = '\0'; @@ -449,7 +459,7 @@ void mark_defs1 () /* mark_prolog - mark the current position in the action array as * representing the end of the action prolog */ -void mark_prolog () +void mark_prolog () { action_array[action_index++] = '\0'; action_offset = action_index; @@ -461,8 +471,8 @@ void mark_prolog () * * Generates a data statement initializing the current 2-D array to "value". */ -void mk2data (value) - int value; +void mk2data (value) + int value; { if (datapos >= NUMDATAITEMS) { outc (','); @@ -487,8 +497,8 @@ void mk2data (value) * Generates a data statement initializing the current array element to * "value". */ -void mkdata (value) - int value; +void mkdata (value) + int value; { if (datapos >= NUMDATAITEMS) { outc (','); @@ -509,7 +519,7 @@ void mkdata (value) /* myctoi - return the integer represented by a string of digits */ -int myctoi (array) +int myctoi (array) const char *array; { int val = 0; @@ -522,8 +532,8 @@ int myctoi (array) /* myesc - return character corresponding to escape sequence */ -Char myesc (array) - Char array[]; +Char myesc (array) + Char array[]; { Char c, esc_char; @@ -610,8 +620,8 @@ Char myesc (array) /* otoi - convert an octal digit string to an integer value */ -int otoi (str) - Char str[]; +int otoi (str) + Char str[]; { unsigned int result; @@ -624,30 +634,30 @@ int otoi (str) * generated scanner, keeping track of the line count. */ -void out (str) +void out (str) const char *str; { fputs (str, stdout); out_line_count (str); } -void out_dec (fmt, n) +void out_dec (fmt, n) const char *fmt; - int n; + int n; { printf (fmt, n); out_line_count (fmt); } -void out_dec2 (fmt, n1, n2) +void out_dec2 (fmt, n1, n2) const char *fmt; - int n1, n2; + int n1, n2; { printf (fmt, n1, n2); out_line_count (fmt); } -void out_hex (fmt, x) +void out_hex (fmt, x) const char *fmt; unsigned int x; { @@ -655,7 +665,7 @@ void out_hex (fmt, x) out_line_count (fmt); } -void out_line_count (str) +void out_line_count (str) const char *str; { register int i; @@ -665,7 +675,7 @@ void out_line_count (str) ++out_linenum; } -void out_str (fmt, str) +void out_str (fmt, str) const char *fmt, str[]; { printf (fmt, str); @@ -673,7 +683,7 @@ void out_str (fmt, str) out_line_count (str); } -void out_str3 (fmt, s1, s2, s3) +void out_str3 (fmt, s1, s2, s3) const char *fmt, s1[], s2[], s3[]; { printf (fmt, s1, s2, s3); @@ -683,17 +693,17 @@ void out_str3 (fmt, s1, s2, s3) out_line_count (s3); } -void out_str_dec (fmt, str, n) +void out_str_dec (fmt, str, n) const char *fmt, str[]; - int n; + int n; { printf (fmt, str, n); out_line_count (fmt); out_line_count (str); } -void outc (c) - int c; +void outc (c) + int c; { putc (c, stdout); @@ -701,7 +711,7 @@ void outc (c) ++out_linenum; } -void outn (str) +void outn (str) const char *str; { puts (str); @@ -762,8 +772,8 @@ char *readable_form (c) void *reallocate_array (array, size, element_size) void *array; - int size; - size_t element_size; + int size; + size_t element_size; { register void *new_array; size_t num_bytes = element_size * size; @@ -782,7 +792,7 @@ void *reallocate_array (array, size, element_size) * Copies skelfile or skel array to stdout until a line beginning with * "%%" or EOF is found. */ -void skelout () +void skelout () { char buf_storage[MAXLINE]; char *buf = buf_storage; @@ -808,40 +818,48 @@ void skelout () out_str ("/* %s */\n", buf); } - switch (buf[1]) { - case '%': + /* We've been accused of using cryptic markers in the skel. + * So we'll use emacs-style-hyphenated-commands. + */ +#define cmd_match(s) (strncmp(buf,(s),strlen(s))==0) + + if (buf[1] == '%') { + /* %% is a break point for skelout() */ return; + } + else if (cmd_match (CMD_TABLES_SER_BEGIN)) { + tablestoggle = true; + } + else if (cmd_match (CMD_TABLES_SER_END)) { + tablestoggle = false; + } + else if (cmd_match (CMD_TABLES_YYDMAP)) { - case '+': + } + else if (cmd_match (CMD_CPP_ONLY)) { + /* only for C++ */ do_copy = C_plus_plus; - break; - - case '-': + } + else if (cmd_match (CMD_C_ONLY)) { + /* %- only for C */ do_copy = !C_plus_plus; - break; - - case '*': + } + else if (cmd_match (CMD_C_OR_CPP)) { + /* %* for C and C++ */ do_copy = 1; - break; - - case 'c': /* begin linkage-only (non-header) code. */ + } + else if (cmd_match (CMD_NOT_FOR_HEADER)) { + /* %c begin linkage-only (non-header) code. */ OUT_BEGIN_CODE (); - break; - - case 'e': /* end linkage-only code. */ + } + else if (cmd_match (CMD_OK_FOR_HEADER)) { + /* %e end linkage-only code. */ OUT_END_CODE (); - break; - - case '#': - /* a comment in the skel. ignore. */ - break; - - case 't': - /* %t - toggle tables api */ - tablestoggle = !tablestoggle; - break; - - default: + } + else if (buf[1] == '#') { + /* %# a comment in the skel. ignore. */ + } + else { flexfatal (_("bad line in skeleton file")); } } @@ -850,7 +868,7 @@ void skelout () if (tablesext || !tablestoggle) outn (buf); } - } + } /* end while */ } @@ -860,8 +878,8 @@ void skelout () * element_n. Formats the output with spaces and carriage returns. */ -void transition_struct_out (element_v, element_n) - int element_v, element_n; +void transition_struct_out (element_v, element_n) + int element_v, element_n; { out_dec2 (" {%4d,%4d },", element_v, element_n); @@ -882,7 +900,7 @@ void transition_struct_out (element_v, element_n) * broken versions of bison. */ void *yy_flex_xmalloc (size) - int size; + int size; { void *result = flex_alloc ((size_t) size); @@ -899,9 +917,9 @@ void *yy_flex_xmalloc (size) * Sets region_ptr[0] through region_ptr[size_in_bytes - 1] to zero. */ -void zero_out (region_ptr, size_in_bytes) +void zero_out (region_ptr, size_in_bytes) char *region_ptr; - size_t size_in_bytes; + size_t size_in_bytes; { register char *rp, *rp_end; |