summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flex.skl930
-rw-r--r--flexdef.h3
-rw-r--r--gen.c126
-rw-r--r--main.c112
-rw-r--r--nfa.c4
-rw-r--r--scan.l27
6 files changed, 923 insertions, 279 deletions
diff --git a/flex.skl b/flex.skl
index 218f8fa..bf6c513 100644
--- a/flex.skl
+++ b/flex.skl
@@ -73,24 +73,66 @@
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+#ifdef YY_REENTRANT
+
+/* For use wherever a Global is accessed or assigned. */
+#define YY_G(var) (((struct yy_globals_t*)yy_globals)->var)
+
+/* For use in function prototypes to append the additional argument. */
+#ifdef YY_USE_PROTOS
+#define YY_LAST_ARG , void * yy_globals
+#define YY_ONLY_ARG void * yy_globals
+#else
+#define YY_LAST_ARG , yy_globals
+#define YY_ONLY_ARG yy_globals
+#define YY_DECL_LAST_ARG void * yy_globals;
+#endif
+
+/* For use in function calls to pass the additional argument. */
+#define YY_CALL_LAST_ARG , yy_globals
+#define YY_CALL_ONLY_ARG yy_globals
+
+/* For convenience. */
+#define yyin_r YY_G(yyin)
+#define yyout_r YY_G(yyout)
+#define yyextra_r YY_G(yyextra)
+#define yyleng_r YY_G(yyleng)
+#define yytext_r YY_G(yytext)
+#define yylineno_r YY_G(yylineno)
+
+int yylex_init YY_PROTO((void** scanner));
+int yylex_destroy YY_PROTO((void* scanner));
+
+#else /* not YY_REENTRANT */
+
+ /* Define these macros to be no-ops. */
+#define YY_G(var) (var)
+#define YY_LAST_ARG
+#define YY_ONLY_ARG void
+#define YY_CALL_LAST_ARG
+#define YY_CALL_ONLY_ARG
+#define YY_DECL_LAST_ARG
+#endif
+
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
-#define BEGIN yy_start = 1 + 2 *
+#define BEGIN YY_G(yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
-#define YY_START ((yy_start - 1) / 2)
+#define YY_START ((YY_G(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". */
-#define YY_NEW_FILE yyrestart( yyin )
+#define YY_NEW_FILE yyrestart( YY_G(yyin) YY_CALL_LAST_ARG )
#define YY_END_OF_BUFFER_CHAR 0
@@ -99,9 +141,14 @@
typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#ifndef YY_REENTRANT
extern int yyleng;
+#endif
+
%-
+#ifndef YY_REENTRANT
extern FILE *yyin, *yyout;
+#endif
%*
#define EOB_ACT_CONTINUE_SCAN 0
@@ -128,14 +175,14 @@ extern FILE *yyin, *yyout;
do \
{ \
/* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
+ *yy_cp = YY_G(yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+ YY_G(yy_c_buf_p) = yy_cp = yy_bp + n - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-#define unput(c) yyunput( c, yytext_ptr )
+#define unput(c) yyunput( c, yytext_ptr YY_CALL_LAST_ARG )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
@@ -206,7 +253,9 @@ struct yy_buffer_state
};
%- Standard (non-C++) definition
+#ifndef YY_REENTRANT
static YY_BUFFER_STATE yy_current_buffer = 0;
+#endif
%*
/* We provide macros for accessing buffer states in case in the
@@ -217,6 +266,8 @@ static YY_BUFFER_STATE yy_current_buffer = 0;
%- Standard (non-C++) definition
+
+#ifndef YY_REENTRANT
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
@@ -235,19 +286,21 @@ static int yy_start = 0; /* start state number */
*/
static int yy_did_buffer_switch_on_eof;
-void yyrestart YY_PROTO(( FILE *input_file ));
+#endif /* end !YY_REENTRANT */
-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 )
+void yyrestart YY_PROTO(( FILE *input_file YY_LAST_ARG ));
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer YY_LAST_ARG ));
+void yy_load_buffer_state YY_PROTO(( YY_ONLY_ARG ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size YY_LAST_ARG ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG)
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size YY_LAST_ARG ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str YY_LAST_ARG ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len YY_LAST_ARG ));
%*
static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
@@ -258,26 +311,28 @@ static void yy_flex_free YY_PROTO(( void * ));
#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; \
+ if ( ! YY_G(yy_current_buffer) ) \
+ YY_G(yy_current_buffer) = \
+ yy_create_buffer( YY_G(yyin), YY_BUF_SIZE YY_CALL_LAST_ARG); \
+ YY_G(yy_current_buffer)->yy_is_interactive = is_interactive; \
}
#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; \
+ if ( ! YY_G(yy_current_buffer) ) \
+ YY_G(yy_current_buffer) = \
+ yy_create_buffer( YY_G(yyin), YY_BUF_SIZE YY_CALL_LAST_ARG); \
+ YY_G(yy_current_buffer)->yy_at_bol = at_bol; \
}
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+#define YY_AT_BOL() (YY_G(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 yy_state_type yy_get_previous_state YY_PROTO(( YY_ONLY_ARG ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state YY_LAST_ARG));
+static int yy_get_next_buffer YY_PROTO(( YY_ONLY_ARG ));
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
%*
@@ -287,28 +342,152 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
#define YY_DO_BEFORE_ACTION \
yytext_ptr = yy_bp; \
%% code to fiddle yytext and yyleng for yymore() goes here
- yy_hold_char = *yy_cp; \
+ YY_G(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
%% code to copy yytext_ptr to yytext[] goes here, if %array
- yy_c_buf_p = yy_cp;
+ YY_G(yy_c_buf_p) = yy_cp;
+
+%*
%% data tables for the DFA and the user's section 1 definitions go here
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+%- Reentrant structure and macros (non-C++).
+#ifdef YY_REENTRANT
+
+struct yy_globals_t
+ {
+
+ /* User-defined. Not touched by flex. */
+ YY_EXTRA_TYPE yyextra;
+
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
+ FILE *yyin, *yyout;
+ YY_BUFFER_STATE yy_current_buffer;
+ char yy_hold_char;
+ int yy_n_chars;
+ int yyleng;
+ char *yy_c_buf_p;
+ int yy_init;
+ int yy_start;
+ int yy_did_buffer_switch_on_eof;
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int *yy_start_stack;
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ int yylineno;
+
+#ifdef YY_TEXT_IS_ARRAY
+ char yytext[YYLMAX];
+ char *yytext_ptr;
+ int yy_more_offset;
+ int yy_prev_more_offset;
+#else
+ char *yytext;
+ int yy_more_flag;
+ int yy_more_len;
+#endif
+
+#ifdef YY_REENTRANT_BISON_PURE
+ YYSTYPE * yylval;
+#ifdef YYLTYPE
+ YYLTYPE * yylloc;
+#endif
+#endif
+
+ };
+
+static int yy_init_globals YY_PROTO(( void * ));
+
+/* This must go here because YYSTYPE and YYLSTYPE are included
+ * from bison output in section 1.*/
+#ifdef YY_REENTRANT_BISON_PURE
+# define yylval_r YY_G(yylval)
+# ifdef YYLTYPE
+# define yylloc_r YY_G(yylloc)
+# endif
+#endif
+
+#endif /* end if YY_REENTRANT */
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+#ifndef YY_NO_GET_EXTRA
+YY_EXTRA_TYPE yyget_extra YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_EXTRA
+void yyset_extra YY_PROTO(( YY_EXTRA_TYPE user_defined YY_LAST_ARG ));
+#endif
+
+#ifndef YY_NO_GET_IN
+FILE *yyget_in YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_IN
+void yyset_in YY_PROTO(( FILE * in_str YY_LAST_ARG ));
+#endif
+
+#ifndef YY_NO_GET_OUT
+FILE *yyget_out YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_OUT
+void yyset_out YY_PROTO(( FILE * out_str YY_LAST_ARG ));
+#endif
+
+#ifndef YY_NO_GET_LENG
+int yyget_leng YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_GET_TEXT
+char *yyget_text YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_GET_LINENO
+int yyget_lineno YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_LINENO
+void yyset_lineno YY_PROTO(( int line_number YY_LAST_ARG ));
+#endif
+
+#ifdef YY_REENTRANT_BISON_PURE
+#ifndef YY_NO_GET_LVAL
+YYSTYPE * yyget_lval YY_PROTO(( YY_ONLY_ARG ));
+#endif
+void yyset_lval YY_PROTO(( YYSTYPE * yylvalp YY_LAST_ARG ));
+#ifdef YYLTYPE
+#ifndef YY_NO_GET_LLOC
+ YYLTYPE *yyget_lloc YY_PROTO(( YY_ONLY_ARG ));
+#endif
+#ifndef YY_NO_SET_LLOC
+ void yyset_lloc YY_PROTO(( YYLTYPE * yyllocp YY_LAST_ARG ));
+#endif
+#endif /* YYLTYPE */
+#endif /* YY_REENTRANT_BISON_PURE */
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
+extern "C" int yywrap YY_PROTO(( YY_ONLY_ARG ));
#else
-extern int yywrap YY_PROTO(( void ));
+extern int yywrap YY_PROTO(( YY_ONLY_ARG ));
#endif
#endif
%-
#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+static void yyunput YY_PROTO(( int c, char *buf_ptr YY_LAST_ARG));
#endif
%*
@@ -323,25 +502,27 @@ static int yy_flex_strlen YY_PROTO(( yyconst char * ));
#ifndef YY_NO_INPUT
%- Standard (non-C++) definition
#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
+static int yyinput YY_PROTO(( YY_ONLY_ARG ));
#else
-static int input YY_PROTO(( void ));
+static int input YY_PROTO(( YY_ONLY_ARG ));
#endif
%*
#endif
#if YY_STACK_USED
+#ifndef YY_REENTRANT
static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
+#endif
#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
+static void yy_push_state YY_PROTO(( int new_state YY_LAST_ARG));
#endif
#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
+static void yy_pop_state YY_PROTO(( YY_ONLY_ARG ));
#endif
#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
+static int yy_top_state YY_PROTO(( YY_ONLY_ARG ));
#endif
#else
@@ -377,7 +558,7 @@ YY_MALLOC_DECL
/* 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 )
+#define ECHO (void) fwrite( YY_G(yytext), YY_G(yyleng), 1, YY_G(yyout) )
%+ C++ definition
#define ECHO LexerOutput( yytext, yyleng )
%*
@@ -422,7 +603,35 @@ YY_MALLOC_DECL
*/
#ifndef YY_DECL
%- Standard (non-C++) definition
-#define YY_DECL int yylex YY_PROTO(( void ))
+
+/* If the bison pure parser is used, then bison will provide
+ one or two additional arguments. */
+
+#ifdef YY_REENTRANT_BISON_PURE
+# ifdef YYLTYPE
+# ifdef YY_USE_PROTOS
+# define YY_LEX_ARGS (YYSTYPE * yylvalp, YYLTYPE * yyllocp YY_LAST_ARG)
+# else
+# define YY_LEX_ARGS (yylvalp, yyllocp YY_LAST_ARG) \
+ YYSTYPE * yylvalp; YYLTYPE * yyllocp; YY_DECL_LAST_ARG
+# endif
+# else
+# ifdef YY_USE_PROTOS
+# define YY_LEX_ARGS (YYSTYPE * yylvalp YY_LAST_ARG)
+# else
+# define YY_LEX_ARGS (yylvalp YY_LAST_ARG) \
+ YYSTYPE * yylvalp; YY_DECL_LAST_ARG
+# endif
+# endif
+#else
+# ifdef YY_USE_PROTOS
+# define YY_LEX_ARGS (YY_ONLY_ARG)
+# else
+# define YY_LEX_ARGS (YY_ONLY_ARG) YY_DECL_LAST_ARG
+# endif
+#endif
+
+#define YY_DECL int yylex YY_LEX_ARGS
%+ C++ definition
#define YY_DECL int yyFlexLexer::yylex()
%*
@@ -450,45 +659,52 @@ YY_DECL
%% user's declarations go here
- if ( yy_init )
+#ifdef YY_REENTRANT_BISON_PURE
+ YY_G(yylval) = yylvalp;
+#ifdef YYLTYPE
+ YY_G(yylloc) = yyllocp;
+#endif
+#endif
+
+ if ( YY_G(yy_init) )
{
- yy_init = 0;
+ YY_G(yy_init) = 0;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
- if ( ! yy_start )
- yy_start = 1; /* first start state */
+ if ( ! YY_G(yy_start) )
+ YY_G(yy_start) = 1; /* first start state */
- if ( ! yyin )
+ if ( ! YY_G(yyin) )
%-
- yyin = stdin;
+ YY_G(yyin) = stdin;
%+
yyin = &cin;
%*
- if ( ! yyout )
+ if ( ! YY_G(yyout) )
%-
- yyout = stdout;
+ YY_G(yyout) = stdout;
%+
yyout = &cout;
%*
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
+ if ( ! YY_G(yy_current_buffer) )
+ YY_G(yy_current_buffer) =
+ yy_create_buffer( YY_G(yyin), YY_BUF_SIZE YY_CALL_LAST_ARG);
- yy_load_buffer_state();
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
while ( 1 ) /* loops until end-of-file is reached */
{
%% yymore()-related code goes here
- yy_cp = yy_c_buf_p;
+ yy_cp = YY_G(yy_c_buf_p);
/* Support of yytext. */
- *yy_cp = yy_hold_char;
+ *yy_cp = YY_G(yy_hold_char);
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
@@ -518,10 +734,10 @@ do_action: /* This label is used only to access EOF actions. */
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_cp = YY_G(yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+ if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
@@ -532,9 +748,9 @@ do_action: /* This label is used only to access EOF actions. */
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+ YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
+ YY_G(yy_current_buffer)->yy_input_file = YY_G(yyin);
+ YY_G(yy_current_buffer)->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
@@ -544,13 +760,13 @@ do_action: /* This label is used only to access EOF actions. */
* end-of-buffer state). Contrast this with the test
* in input().
*/
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ if ( YY_G(yy_c_buf_p) <= &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+ YY_G(yy_c_buf_p) = yytext_ptr + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
@@ -561,14 +777,14 @@ do_action: /* This label is used only to access EOF actions. */
* will run more slowly).
*/
- yy_next_state = yy_try_NUL_trans( yy_current_state );
+ yy_next_state = yy_try_NUL_trans( yy_current_state YY_CALL_LAST_ARG);
yy_bp = yytext_ptr + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
+ yy_cp = ++YY_G(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
}
@@ -580,13 +796,13 @@ do_action: /* This label is used only to access EOF actions. */
}
}
- else switch ( yy_get_next_buffer() )
+ else switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
{
case EOB_ACT_END_OF_FILE:
{
- yy_did_buffer_switch_on_eof = 0;
+ YY_G(yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap() )
+ if ( yywrap( YY_CALL_ONLY_ARG ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -597,7 +813,7 @@ do_action: /* This label is used only to access EOF actions. */
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+ YY_G(yy_c_buf_p) = yytext_ptr + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
@@ -605,29 +821,29 @@ do_action: /* This label is used only to access EOF actions. */
else
{
- if ( ! yy_did_buffer_switch_on_eof )
+ if ( ! YY_G(yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
+ YY_G(yy_c_buf_p) =
yytext_ptr + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
- yy_cp = yy_c_buf_p;
+ yy_cp = YY_G(yy_c_buf_p);
yy_bp = yytext_ptr + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
+ YY_G(yy_c_buf_p) =
+ &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)];
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
- yy_cp = yy_c_buf_p;
+ yy_cp = YY_G(yy_c_buf_p);
yy_bp = yytext_ptr + YY_MORE_ADJ;
goto yy_find_action;
}
@@ -675,15 +891,15 @@ yyFlexLexer::~yyFlexLexer()
{
delete [] yy_state_buf;
yy_flex_free( yy_start_stack );
- yy_delete_buffer( yy_current_buffer );
+ yy_delete_buffer( yy_current_buffer YY_CALL_LAST_ARG);
}
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 ) );
+ yy_delete_buffer( yy_current_buffer YY_CALL_LAST_ARG);
+ yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE YY_CALL_LAST_ARG) YY_CALL_LAST_ARG);
}
if ( new_out )
@@ -735,23 +951,28 @@ void yyFlexLexer::LexerOutput( const char* buf, int size )
*/
%-
-static int yy_get_next_buffer()
+#ifdef YY_USE_PROTOS
+static int yy_get_next_buffer(YY_ONLY_ARG)
+#else
+static int yy_get_next_buffer(YY_ONLY_ARG)
+YY_DECL_LAST_ARG
+#endif
%+
int yyFlexLexer::yy_get_next_buffer()
%*
{
- register char *dest = yy_current_buffer->yy_ch_buf;
+ register char *dest = YY_G(yy_current_buffer)->yy_ch_buf;
register char *source = yytext_ptr;
register int number_to_move, i;
int ret_val;
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+ if ( YY_G(yy_c_buf_p) > &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
- if ( yy_current_buffer->yy_fill_buffer == 0 )
+ if ( YY_G(yy_current_buffer)->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+ if ( YY_G(yy_c_buf_p) - yytext_ptr - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
@@ -771,21 +992,21 @@ int yyFlexLexer::yy_get_next_buffer()
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+ number_to_move = (int) (YY_G(yy_c_buf_p) - yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+ YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars) = 0;
else
{
int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
+ YY_G(yy_current_buffer)->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
@@ -795,10 +1016,10 @@ int yyFlexLexer::yy_get_next_buffer()
#else
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
+ YY_BUFFER_STATE b = YY_G(yy_current_buffer);
int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
+ (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
@@ -822,9 +1043,9 @@ int yyFlexLexer::yy_get_next_buffer()
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+ YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
- num_to_read = yy_current_buffer->yy_buf_size -
+ num_to_read = YY_G(yy_current_buffer)->yy_buf_size -
number_to_move - 1;
#endif
}
@@ -833,24 +1054,24 @@ int yyFlexLexer::yy_get_next_buffer()
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
+ YY_INPUT( (&YY_G(yy_current_buffer)->yy_ch_buf[number_to_move]),
+ YY_G(yy_n_chars), num_to_read );
- yy_current_buffer->yy_n_chars = yy_n_chars;
+ YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
}
- if ( yy_n_chars == 0 )
+ if ( YY_G(yy_n_chars) == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
+ yyrestart( YY_G(yyin) YY_CALL_LAST_ARG);
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
+ YY_G(yy_current_buffer)->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
@@ -858,11 +1079,11 @@ int yyFlexLexer::yy_get_next_buffer()
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- yy_n_chars += number_to_move;
- 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;
+ YY_G(yy_n_chars) += number_to_move;
+ YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+ yytext_ptr = &YY_G(yy_current_buffer)->yy_ch_buf[0];
return ret_val;
}
@@ -871,7 +1092,12 @@ int yyFlexLexer::yy_get_next_buffer()
/* yy_get_previous_state - get the state just before the EOB char was reached */
%-
-static yy_state_type yy_get_previous_state()
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
+#else
+static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
+YY_DECL_LAST_ARG
+#endif
%+
yy_state_type yyFlexLexer::yy_get_previous_state()
%*
@@ -881,7 +1107,7 @@ yy_state_type yyFlexLexer::yy_get_previous_state()
%% code to get the start state into yy_current_state goes here
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+ for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp )
{
%% code to find the next state goes here
}
@@ -898,10 +1124,11 @@ yy_state_type yyFlexLexer::yy_get_previous_state()
%-
#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state YY_LAST_ARG )
#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
+static yy_state_type yy_try_NUL_trans( yy_current_state YY_LAST_ARG )
yy_state_type yy_current_state;
+YY_DECL_LAST_ARG
#endif
%+
yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
@@ -917,39 +1144,40 @@ 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 )
+static void yyunput( int c, register char *yy_bp YY_LAST_ARG )
#else
-static void yyunput( c, yy_bp )
+static void yyunput( c, yy_bp YY_LAST_ARG)
int c;
register char *yy_bp;
+YY_DECL_LAST_ARG
#endif
%+
-void yyFlexLexer::yyunput( int c, register char* yy_bp )
+void yyFlexLexer::yyunput( int c, register char* yy_bp YY_LAST_ARG)
%*
{
- register char *yy_cp = yy_c_buf_p;
+ register char *yy_cp = YY_G(yy_c_buf_p);
/* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
+ *yy_cp = YY_G(yy_hold_char);
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
+ register int number_to_move = YY_G(yy_n_chars) + 2;
+ register char *dest = &YY_G(yy_current_buffer)->yy_ch_buf[
+ YY_G(yy_current_buffer)->yy_buf_size + 2];
register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
+ &YY_G(yy_current_buffer)->yy_ch_buf[number_to_move];
- while ( source > yy_current_buffer->yy_ch_buf )
+ while ( source > YY_G(yy_current_buffer)->yy_ch_buf )
*--dest = *--source;
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
+ YY_G(yy_current_buffer)->yy_n_chars =
+ YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_buf_size;
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
@@ -958,8 +1186,8 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp )
%% update yylineno here
yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
+ YY_G(yy_hold_char) = *yy_cp;
+ YY_G(yy_c_buf_p) = yy_cp;
}
%-
#endif /* ifndef YY_NO_UNPUT */
@@ -969,9 +1197,14 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp )
%-
#ifndef YY_NO_INPUT
#ifdef __cplusplus
-static int yyinput()
+static int yyinput(YY_ONLY_ARG)
+#else
+#ifdef YY_USE_PROTOS
+static int input(YY_ONLY_ARG)
#else
-static int input()
+static int input(YY_ONLY_ARG)
+ YY_DECL_LAST_ARG
+#endif
#endif
%+
int yyFlexLexer::yyinput()
@@ -979,24 +1212,24 @@ int yyFlexLexer::yyinput()
{
int c;
- *yy_c_buf_p = yy_hold_char;
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ if ( YY_G(yy_c_buf_p) < &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
/* This was really a NUL. */
- *yy_c_buf_p = '\0';
+ *YY_G(yy_c_buf_p) = '\0';
else
{ /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
+ int offset = YY_G(yy_c_buf_p) - yytext_ptr;
+ ++YY_G(yy_c_buf_p);
- switch ( yy_get_next_buffer() )
+ switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
@@ -1010,34 +1243,34 @@ int yyFlexLexer::yyinput()
*/
/* Reset buffer status. */
- yyrestart( yyin );
+ yyrestart( YY_G(yyin) YY_CALL_LAST_ARG);
/* fall through */
case EOB_ACT_END_OF_FILE:
{
- if ( yywrap() )
+ if ( yywrap( YY_CALL_ONLY_ARG ) )
return EOF;
- if ( ! yy_did_buffer_switch_on_eof )
+ if ( ! YY_G(yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
- return yyinput();
+ return yyinput(YY_CALL_ONLY_ARG);
#else
- return input();
+ return input(YY_CALL_ONLY_ARG);
#endif
}
case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
+ YY_G(yy_c_buf_p) = yytext_ptr + offset;
break;
}
}
}
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
+ c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */
+ *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */
+ YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p);
%% update BOL and yylineno
@@ -1049,81 +1282,86 @@ int yyFlexLexer::yyinput()
%-
#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
+void yyrestart( FILE *input_file YY_LAST_ARG)
#else
-void yyrestart( input_file )
+void yyrestart( input_file YY_LAST_ARG)
FILE *input_file;
+YY_DECL_LAST_ARG
#endif
%+
void yyFlexLexer::yyrestart( istream* input_file )
%*
{
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+ if ( ! YY_G(yy_current_buffer) )
+ YY_G(yy_current_buffer) =
+ yy_create_buffer( YY_G(yyin), YY_BUF_SIZE YY_CALL_LAST_ARG);
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
+ yy_init_buffer( YY_G(yy_current_buffer), input_file YY_CALL_LAST_ARG);
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
%-
#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer YY_LAST_ARG )
#else
-void yy_switch_to_buffer( new_buffer )
+void yy_switch_to_buffer( new_buffer YY_LAST_ARG )
YY_BUFFER_STATE new_buffer;
+YY_DECL_LAST_ARG
#endif
%+
void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
%*
{
- if ( yy_current_buffer == new_buffer )
+ if ( YY_G(yy_current_buffer) == new_buffer )
return;
- if ( yy_current_buffer )
+ if ( YY_G(yy_current_buffer) )
{
/* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
+ YY_G(yy_current_buffer)->yy_buf_pos = YY_G(yy_c_buf_p);
+ YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
}
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
+ YY_G(yy_current_buffer) = new_buffer;
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
- yy_did_buffer_switch_on_eof = 1;
+ YY_G(yy_did_buffer_switch_on_eof) = 1;
}
%-
#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
+void yy_load_buffer_state( YY_ONLY_ARG )
#else
-void yy_load_buffer_state()
+void yy_load_buffer_state(YY_ONLY_ARG )
+YY_DECL_LAST_ARG
#endif
%+
void yyFlexLexer::yy_load_buffer_state()
%*
{
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
+ YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
+ yytext_ptr = YY_G(yy_c_buf_p) = YY_G(yy_current_buffer)->yy_buf_pos;
+ YY_G(yyin) = YY_G(yy_current_buffer)->yy_input_file;
+ YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
}
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size YY_LAST_ARG)
#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
+YY_BUFFER_STATE yy_create_buffer( file, size YY_LAST_ARG)
FILE *file;
int size;
+YY_DECL_LAST_ARG
#endif
%+
YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
@@ -1146,7 +1384,7 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
b->yy_is_our_buffer = 1;
- yy_init_buffer( b, file );
+ yy_init_buffer( b, file YY_CALL_LAST_ARG);
return b;
}
@@ -1154,10 +1392,11 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
%-
#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
+void yy_delete_buffer( YY_BUFFER_STATE b YY_LAST_ARG)
#else
-void yy_delete_buffer( b )
+void yy_delete_buffer( b YY_LAST_ARG)
YY_BUFFER_STATE b;
+YY_DECL_LAST_ARG
#endif
%+
void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
@@ -1166,8 +1405,8 @@ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
if ( ! b )
return;
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
+ if ( b == YY_G(yy_current_buffer) )
+ YY_G(yy_current_buffer) = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
yy_flex_free( (void *) b->yy_ch_buf );
@@ -1184,11 +1423,12 @@ extern int isatty YY_PROTO(( int ));
#endif
#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG)
#else
-void yy_init_buffer( b, file )
+void yy_init_buffer( b, file YY_LAST_ARG)
YY_BUFFER_STATE b;
FILE *file;
+YY_DECL_LAST_ARG
#endif
%+
@@ -1197,7 +1437,7 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
%*
{
- yy_flush_buffer( b );
+ yy_flush_buffer( b YY_CALL_LAST_ARG);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
@@ -1220,10 +1460,11 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
%-
#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
+void yy_flush_buffer( YY_BUFFER_STATE b YY_LAST_ARG )
#else
-void yy_flush_buffer( b )
+void yy_flush_buffer( b YY_LAST_ARG )
YY_BUFFER_STATE b;
+YY_DECL_LAST_ARG
#endif
%+
@@ -1247,8 +1488,8 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
+ if ( b == YY_G(yy_current_buffer) )
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
%*
@@ -1256,11 +1497,12 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
#ifndef YY_NO_SCAN_BUFFER
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size YY_LAST_ARG )
#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
+YY_BUFFER_STATE yy_scan_buffer( base, size YY_LAST_ARG )
char *base;
yy_size_t size;
+YY_DECL_LAST_ARG
#endif
{
YY_BUFFER_STATE b;
@@ -1285,7 +1527,7 @@ yy_size_t size;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer( b );
+ yy_switch_to_buffer( b YY_CALL_LAST_ARG );
return b;
}
@@ -1296,17 +1538,18 @@ yy_size_t size;
#ifndef YY_NO_SCAN_STRING
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str YY_LAST_ARG )
#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
+YY_BUFFER_STATE yy_scan_string( yy_str YY_LAST_ARG)
yyconst char *yy_str;
+YY_DECL_LAST_ARG
#endif
{
int len;
for ( len = 0; yy_str[len]; ++len )
;
- return yy_scan_bytes( yy_str, len );
+ return yy_scan_bytes( yy_str, len YY_CALL_LAST_ARG);
}
%*
#endif
@@ -1315,10 +1558,11 @@ yyconst char *yy_str;
#ifndef YY_NO_SCAN_BYTES
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len YY_LAST_ARG)
#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+YY_BUFFER_STATE yy_scan_bytes( bytes, len YY_LAST_ARG)
yyconst char *bytes;
+YY_DECL_LAST_ARG
int len;
#endif
{
@@ -1338,7 +1582,7 @@ int len;
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer( buf, n );
+ b = yy_scan_buffer( buf, n YY_CALL_LAST_ARG);
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1356,35 +1600,36 @@ int len;
#ifndef YY_NO_PUSH_STATE
%-
#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
+static void yy_push_state( int new_state YY_LAST_ARG)
#else
-static void yy_push_state( new_state )
+static void yy_push_state( new_state YY_LAST_ARG)
int new_state;
+YY_DECL_LAST_ARG
#endif
%+
void yyFlexLexer::yy_push_state( int new_state )
%*
{
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
+ if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) )
{
yy_size_t new_size;
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
+ YY_G(yy_start_stack_depth) += YY_START_STACK_INCR;
+ new_size = YY_G(yy_start_stack_depth) * sizeof( int );
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
+ if ( ! YY_G(yy_start_stack) )
+ YY_G(yy_start_stack) = (int *) yy_flex_alloc( new_size );
else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
+ YY_G(yy_start_stack) = (int *) yy_flex_realloc(
+ (void *) YY_G(yy_start_stack), new_size );
- if ( ! yy_start_stack )
+ if ( ! YY_G(yy_start_stack) )
YY_FATAL_ERROR(
"out of memory expanding start-condition stack" );
}
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
+ YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
BEGIN(new_state);
}
@@ -1393,27 +1638,37 @@ void yyFlexLexer::yy_push_state( int new_state )
#ifndef YY_NO_POP_STATE
%-
-static void yy_pop_state()
+#ifdef YY_USE_PROTOS
+static void yy_pop_state( YY_ONLY_ARG )
+#else
+static void yy_pop_state( YY_ONLY_ARG )
+YY_DECL_LAST_ARG
+#endif
%+
void yyFlexLexer::yy_pop_state()
%*
{
- if ( --yy_start_stack_ptr < 0 )
+ if ( --YY_G(yy_start_stack_ptr) < 0 )
YY_FATAL_ERROR( "start-condition stack underflow" );
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
+ BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]);
}
#endif
#ifndef YY_NO_TOP_STATE
%-
-static int yy_top_state()
+#ifdef YY_USE_PROTOS
+static int yy_top_state( YY_ONLY_ARG )
+#else
+static int yy_top_state( YY_ONLY_ARG )
+YY_DECL_LAST_ARG
+#endif
%+
int yyFlexLexer::yy_top_state()
%*
{
- return yy_start_stack[yy_start_stack_ptr - 1];
+ return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1];
}
#endif
@@ -1422,12 +1677,7 @@ int yyFlexLexer::yy_top_state()
#endif
%-
-#ifdef YY_USE_PROTOS
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( YY_EXIT_FAILURE );
@@ -1450,15 +1700,265 @@ void yyFlexLexer::LexerError( yyconst char msg[] )
do \
{ \
/* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
+ YY_G(yytext)[YY_G(yyleng)] = YY_G(yy_hold_char); \
+ YY_G(yy_c_buf_p) = YY_G(yytext) + n; \
+ YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \
+ *YY_G(yy_c_buf_p) = '\0'; \
+ YY_G(yyleng) = n; \
} \
while ( 0 )
+
+#ifdef YY_REENTRANT
+
+/* Accessor methods (get/set functions) to struct members. */
+
+#ifndef YY_NO_GET_EXTRA
+#ifdef YY_USE_PROTOS
+YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
+#else
+YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yyextra);
+}
+#endif /* !YY_NO_GET_EXTRA */
+
+#ifndef YY_NO_GET_LINENO
+# ifdef YY_USE_PROTOS
+int yyget_lineno( YY_ONLY_ARG )
+# else
+int yyget_lineno( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+# endif
+{
+ return YY_G(yylineno);
+}
+#endif /* !YY_NO_GET_LINENO */
+
+#ifndef YY_NO_GET_IN
+#ifdef YY_USE_PROTOS
+FILE *yyget_in( YY_ONLY_ARG )
+#else
+FILE *yyget_in( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yyin);
+}
+#endif /* !YY_NO_GET_IN */
+
+#ifndef YY_NO_GET_OUT
+#ifdef YY_USE_PROTOS
+FILE *yyget_out( YY_ONLY_ARG )
+#else
+FILE *yyget_out( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yyout);
+}
+#endif /* !YY_NO_GET_OUT */
+
+#ifndef YY_NO_GET_LENG
+#ifdef YY_USE_PROTOS
+int yyget_leng( YY_ONLY_ARG )
+#else
+int yyget_leng( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yyleng);
+}
+#endif /* !YY_NO_GET_LENG */
+
+#ifndef YY_NO_GET_TEXT
+#ifdef YY_USE_PROTOS
+char *yyget_text( YY_ONLY_ARG )
+#else
+char *yyget_text( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yytext);
+}
+#endif /* !YY_NO_GET_TEXT */
+
+#ifndef YY_NO_SET_EXTRA
+#ifdef YY_USE_PROTOS
+void yyset_extra( YY_EXTRA_TYPE user_defined YY_LAST_ARG )
+#else
+void yyset_extra( user_defined YY_LAST_ARG )
+ YY_EXTRA_TYPE user_defined;
+ YY_DECL_LAST_ARG
+#endif
+{
+ YY_G(yyextra) = user_defined ;
+}
+#endif /* !YY_NO_SET_EXTRA */
+
+#ifndef YY_NO_SET_LINENO
+# ifdef YY_USE_PROTOS
+void yyset_lineno( int line_number YY_LAST_ARG )
+# else
+void yyset_lineno( line_number YY_LAST_ARG )
+ int line_number;
+ YY_DECL_LAST_ARG
+# endif
+{
+ YY_G(yylineno) = line_number;
+}
+#endif /* !YY_NO_SET_LINENO */
+
+
+#ifndef YY_NO_SET_IN
+#ifdef YY_USE_PROTOS
+void yyset_in( FILE * in_str YY_LAST_ARG )
+#else
+void yyset_in( in_str YY_LAST_ARG )
+ FILE * in_str;
+ YY_DECL_LAST_ARG
+#endif
+{
+ YY_G(yyin) = in_str ;
+}
+#endif /* !YY_NO_SET_IN */
+
+#ifndef YY_NO_SET_OUT
+#ifdef YY_USE_PROTOS
+void yyset_out( FILE * out_str YY_LAST_ARG )
+#else
+void yyset_out( out_str YY_LAST_ARG )
+ FILE * out_str;
+ YY_DECL_LAST_ARG
+#endif
+{
+ YY_G(yyout) = out_str ;
+}
+#endif /* !YY_NO_SET_OUT */
+
+/* Accessor methods for yylval and yylloc */
+
+#ifdef YY_REENTRANT_BISON_PURE
+#ifndef YY_NO_GET_LVAL
+#ifdef YY_USE_PROTOS
+YYSTYPE * yyget_lval( YY_ONLY_ARG )
+#else
+YYSTYPE * yyget_lval( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yylval);
+}
+#endif /* !YY_NO_GET_LVAL */
+
+#ifndef YY_NO_SET_LVAL
+#ifdef YY_USE_PROTOS
+void yyset_lval( YYSTYPE * yylvalp YY_LAST_ARG )
+#else
+void yyset_lval( yylvalp YY_LAST_ARG )
+ YYSTYPE * yylvalp;
+ YY_DECL_LAST_ARG
+#endif
+{
+ YY_G(yylval) = yylvalp;
+}
+#endif /* !YY_NO_SET_LVAL */
+
+#ifdef YYLTYPE
+#ifndef YY_NO_GET_LLOC
+#ifdef YY_USE_PROTOS
+YYLTYPE *yyget_lloc( YY_ONLY_ARG )
+#else
+YYLTYPE *yyget_lloc( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return YY_G(yylloc);
+}
+#endif /* !YY_NO_GET_LLOC */
+
+#ifndef YY_NO_SET_LLOC
+#ifdef YY_USE_PROTOS
+void yyset_lloc( YYLTYPE * yyllocp YY_LAST_ARG )
+#else
+void yyset_lloc( yyllocp YY_LAST_ARG )
+ YYLTYPE * yyllocp;
+ YY_DECL_LAST_ARG
+#endif
+{
+ YY_G(yylloc) = yyllocp;
+}
+#endif /* !YY_NO_SET_LLOC */
+
+#endif /* YYLTYPE */
+#endif /* YY_REENTRANT_BISON_PURE */
+
+
+#ifdef YY_USE_PROTOS
+static int yy_init_globals( void* yy_globals)
+#else
+static int yy_init_globals( yy_globals )
+ void* yy_globals;
+#endif
+ {
+ /* Initialization is the same as for the non-reentrant scanner.
+ This function is called once per scanner lifetime. */
+
+ /* We do not touch yylineno unless the option is enabled. */
+#ifdef YY_USE_LINENO
+ YY_G(yylineno) = 1;
+#endif
+ YY_G(yy_current_buffer) = 0;
+ YY_G(yy_c_buf_p) = (char *) 0;
+ YY_G(yy_init) = 1;
+ YY_G(yy_start) = 0;
+ YY_G(yy_start_stack_ptr) = 0;
+ YY_G(yy_start_stack_depth) = 0;
+ YY_G(yy_start_stack) = (int *) 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ YY_G(yyin) = stdin;
+ YY_G(yyout) = stdout;
+#else
+ YY_G(yyin) = (FILE *) 0;
+ YY_G(yyout) = (FILE *) 0;
+#endif
+ return 0;
+ }
+
+/* User-visible API */
+#ifdef YY_USE_PROTOS
+int yylex_init( void** ptr_yy_globals)
+#else
+int yylex_init( ptr_yy_globals )
+ void** ptr_yy_globals;
+#endif
+ {
+ *ptr_yy_globals = (void *) yy_flex_alloc ( sizeof( struct yy_globals_t ) );
+ yy_init_globals ( *ptr_yy_globals );
+ return 0;
+ }
+
+#ifdef YY_USE_PROTOS
+int yylex_destroy( void* ptr_yy_globals )
+#else
+int yylex_destroy( ptr_yy_globals )
+ void* ptr_yy_globals;
+#endif
+ {
+ if( ptr_yy_globals )
+ {
+ yy_flex_free ( ptr_yy_globals );
+ }
+ return 0;
+ }
+
+#endif /* End YY_REENTRANT */
+
/* Internal utility routines. */
#ifndef yytext_ptr
@@ -1535,7 +2035,17 @@ void *ptr;
#if YY_MAIN
int main()
{
+
+#ifdef YY_REENTRANT
+ void *lexer;
+ yylex_init(&lexer);
+ yylex( lexer );
+ yylex_destroy( lexer);
+
+#else
yylex();
+#endif
+
return 0;
}
#endif
diff --git a/flexdef.h b/flexdef.h
index 81fd5e2..6642222 100644
--- a/flexdef.h
+++ b/flexdef.h
@@ -337,6 +337,8 @@
* listing backing-up states
* C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
* otherwise, a standard C scanner
+ * reentrant - if true (-R), generate a reentrant C scanner.
+ * reentrant_bison_pure - if true (-Rb), bison pure calling convention.
* long_align - if true (-Ca flag), favor long-word alignment.
* use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
* otherwise, use fread().
@@ -362,6 +364,7 @@ extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
extern int interactive, caseins, lex_compat, do_yylineno;
extern int useecs, fulltbl, usemecs, fullspd;
extern int gen_line_dirs, performance_report, backing_up_report;
+extern int reentrant, reentrant_bison_pure;
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
extern int csize;
extern int yymore_used, reject, real_reject, continued_action, in_rule;
diff --git a/gen.c b/gen.c
index 4195494..22632ee 100644
--- a/gen.c
+++ b/gen.c
@@ -89,8 +89,8 @@ void gen_backing_up()
indent_up();
indent_puts( "{" );
- indent_puts( "yy_last_accepting_state = yy_current_state;" );
- indent_puts( "yy_last_accepting_cpos = yy_cp;" );
+ indent_puts( "YY_G(yy_last_accepting_state) = yy_current_state;" );
+ indent_puts( "YY_G(yy_last_accepting_cpos) = yy_cp;" );
indent_puts( "}" );
indent_down();
}
@@ -107,17 +107,17 @@ void gen_bu_action()
indent_puts( "case 0: /* must back up */" );
indent_puts( "/* undo the effects of YY_DO_BEFORE_ACTION */" );
- indent_puts( "*yy_cp = yy_hold_char;" );
+ indent_puts( "*yy_cp = YY_G(yy_hold_char);" );
if ( fullspd || fulltbl )
- indent_puts( "yy_cp = yy_last_accepting_cpos + 1;" );
+ 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_last_accepting_cpos;" );
+ indent_puts( "yy_cp = YY_G(yy_last_accepting_cpos);" );
- indent_puts( "yy_current_state = yy_last_accepting_state;" );
+ indent_puts( "yy_current_state = YY_G(yy_last_accepting_state);" );
indent_puts( "goto yy_find_action;" );
outc( '\n' );
@@ -391,9 +391,9 @@ void gen_find_action()
indent_puts( "if ( yy_act == 0 )" );
indent_up();
indent_puts( "{ /* have to back up */" );
- indent_puts( "yy_cp = yy_last_accepting_cpos;" );
+ indent_puts( "yy_cp = YY_G(yy_last_accepting_cpos);" );
indent_puts(
- "yy_current_state = yy_last_accepting_state;" );
+ "yy_current_state = YY_G(yy_last_accepting_state);" );
indent_puts( "yy_act = yy_accept[yy_current_state];" );
indent_puts( "}" );
indent_down();
@@ -583,9 +583,9 @@ void gen_next_match()
/* Do the guaranteed-needed backing up to figure out
* the match.
*/
- indent_puts( "yy_cp = yy_last_accepting_cpos;" );
+ indent_puts( "yy_cp = YY_G(yy_last_accepting_cpos);" );
indent_puts(
- "yy_current_state = yy_last_accepting_state;" );
+ "yy_current_state = YY_G(yy_last_accepting_state);" );
}
}
}
@@ -670,7 +670,7 @@ void gen_NUL_trans()
/* We're going to need yy_cp lying around for the call
* below to gen_backing_up().
*/
- indent_puts( "register char *yy_cp = yy_c_buf_p;" );
+ indent_puts( "register char *yy_cp = YY_G(yy_c_buf_p);" );
outc( '\n' );
@@ -753,16 +753,16 @@ void gen_start_state()
if ( bol_needed )
{
indent_puts(
- "yy_current_state = yy_start_state_list[yy_start + YY_AT_BOL()];" );
+ "yy_current_state = yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];" );
}
else
indent_puts(
- "yy_current_state = yy_start_state_list[yy_start];" );
+ "yy_current_state = yy_start_state_list[YY_G(yy_start)];" );
}
else
{
- indent_puts( "yy_current_state = yy_start;" );
+ indent_puts( "yy_current_state = YY_G(yy_start);" );
if ( bol_needed )
indent_puts( "yy_current_state += YY_AT_BOL();" );
@@ -1068,12 +1068,12 @@ void make_tables()
if ( yymore_used && ! yytext_is_array )
{
- indent_puts( "yytext_ptr -= yy_more_len; \\" );
- indent_puts( "yyleng = (int) (yy_cp - yytext_ptr); \\" );
+ indent_puts( "YY_G(yytext_ptr) -= YY_G(yy_more_len); \\" );
+ indent_puts( "YY_G(yyleng) = (int) (yy_cp - YY_G(yytext_ptr)); \\" );
}
else
- indent_puts( "yyleng = (int) (yy_cp - yy_bp); \\" );
+ indent_puts( "YY_G(yyleng) = (int) (yy_cp - yy_bp); \\" );
/* Now also deal with copying yytext_ptr to yytext if needed. */
skelout();
@@ -1081,9 +1081,9 @@ void make_tables()
{
if ( yymore_used )
indent_puts(
- "if ( yyleng + yy_more_offset >= YYLMAX ) \\" );
+ "if ( YY_G(yyleng) + YY_G(yy_more_offset) >= YYLMAX ) \\" );
else
- indent_puts( "if ( yyleng >= YYLMAX ) \\" );
+ indent_puts( "if ( YY_G(yyleng) >= YYLMAX ) \\" );
indent_up();
indent_puts(
@@ -1093,16 +1093,16 @@ void make_tables()
if ( yymore_used )
{
indent_puts(
-"yy_flex_strncpy( &yytext[yy_more_offset], yytext_ptr, yyleng + 1 ); \\" );
- indent_puts( "yyleng += yy_more_offset; \\" );
+"yy_flex_strncpy( &YY_G(yytext)[YY_G(yy_more_offset)], YY_G(yytext_ptr), YY_G(yyleng) + 1 ); \\" );
+ indent_puts( "YY_G(yyleng) += YY_G(yy_more_offset); \\" );
indent_puts(
- "yy_prev_more_offset = yy_more_offset; \\" );
- indent_puts( "yy_more_offset = 0; \\" );
+ "YY_G(yy_prev_more_offset) = YY_G(yy_more_offset); \\" );
+ indent_puts( "YY_G(yy_more_offset) = 0; \\" );
}
else
{
indent_puts(
- "yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \\" );
+ "yy_flex_strncpy( YY_G(yytext), YY_G(yytext_ptr), YY_G(yyleng) + 1 ); \\" );
}
}
@@ -1160,7 +1160,7 @@ void make_tables()
*/
if ( num_backing_up > 0 && ! reject )
{
- if ( ! C_plus_plus )
+ if ( ! C_plus_plus && !reentrant)
{
indent_puts(
"static yy_state_type yy_last_accepting_state;" );
@@ -1229,7 +1229,7 @@ void make_tables()
outn( "#define REJECT \\" );
outn( "{ \\" ); /* } for vi */
outn(
- "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \\" );
+ "*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \\" );
outn(
"yy_cp = yy_full_match; /* restore poss. backed-over text */ \\" );
@@ -1264,35 +1264,39 @@ void make_tables()
{
if ( yytext_is_array )
{
+ outn( "#ifndef YY_REENTRANT");
indent_puts( "static int yy_more_offset = 0;" );
indent_puts(
"static int yy_prev_more_offset = 0;" );
- }
- else
+ outn( "#endif" );
+ }
+ else if( !reentrant )
{
+ outn( "#ifndef YY_REENTRANT");
indent_puts( "static int yy_more_flag = 0;" );
indent_puts( "static int yy_more_len = 0;" );
+ outn( "#endif" );
}
}
if ( yytext_is_array )
{
indent_puts(
- "#define yymore() (yy_more_offset = yy_flex_strlen( yytext ))" );
+ "#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( YY_G(yytext) ))" );
indent_puts( "#define YY_NEED_STRLEN" );
indent_puts( "#define YY_MORE_ADJ 0" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET \\" );
indent_up();
indent_puts( "{ \\" );
- indent_puts( "yy_more_offset = yy_prev_more_offset; \\" );
- indent_puts( "yyleng -= yy_more_offset; \\" );
+ indent_puts( "YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\" );
+ indent_puts( "YY_G(yyleng) -= YY_G(yy_more_offset); \\" );
indent_puts( "}" );
indent_down();
}
else
{
- indent_puts( "#define yymore() (yy_more_flag = 1)" );
- indent_puts( "#define YY_MORE_ADJ yy_more_len" );
+ indent_puts( "#define yymore() (YY_G(yy_more_flag) = 1)" );
+ indent_puts( "#define YY_MORE_ADJ YY_G(yy_more_len)" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET" );
}
}
@@ -1311,12 +1315,18 @@ void make_tables()
outn( "#ifndef YYLMAX" );
outn( "#define YYLMAX 8192" );
outn( "#endif\n" );
+ outn( "#ifndef YY_REENTRANT" );
outn( "char yytext[YYLMAX];" );
outn( "char *yytext_ptr;" );
+ outn( "#endif" );
}
- else
+ else
+ {
+ outn( "#ifndef YY_REENTRANT" );
outn( "char *yytext;" );
+ outn( "#endif" );
+ }
}
out( &action_array[defs1_offset] );
@@ -1330,7 +1340,7 @@ void make_tables()
if ( use_read )
{
outn(
-"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\" );
+"\tif ( (result = read( fileno(YY_G(yyin)), (char *) buf, max_size )) < 0 ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
@@ -1338,22 +1348,22 @@ void make_tables()
else
{
outn(
- "\tif ( yy_current_buffer->yy_is_interactive ) \\" );
+ "\tif ( YY_G(yy_current_buffer)->yy_is_interactive ) \\" );
outn( "\t\t{ \\" );
outn( "\t\tint c = '*', n; \\" );
outn( "\t\tfor ( n = 0; n < max_size && \\" );
- outn( "\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\" );
+ outn( "\t\t\t (c = getc( YY_G(yyin) )) != EOF && c != '\\n'; ++n ) \\" );
outn( "\t\t\tbuf[n] = (char) c; \\" );
outn( "\t\tif ( c == '\\n' ) \\" );
outn( "\t\t\tbuf[n++] = (char) c; \\" );
- outn( "\t\tif ( c == EOF && ferror( yyin ) ) \\" );
+ outn( "\t\tif ( c == EOF && ferror( YY_G(yyin) ) ) \\" );
outn(
"\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
outn( "\t\tresult = n; \\" );
outn( "\t\t} \\" );
outn(
- "\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\" );
- outn( "\t\t && ferror( yyin ) ) \\" );
+ "\telse if ( ((result = fread( buf, 1, max_size, YY_G(yyin) )) == 0) \\" );
+ outn( "\t\t && ferror( YY_G(yyin) ) ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
@@ -1365,10 +1375,10 @@ void make_tables()
indent_up();
if ( bol_needed )
{
- indent_puts( "if ( yyleng > 0 ) \\" );
+ indent_puts( "if ( YY_G(yyleng) > 0 ) \\" );
indent_up();
- indent_puts( "yy_current_buffer->yy_at_bol = \\" );
- indent_puts( "\t\t(yytext[yyleng - 1] == '\\n'); \\" );
+ indent_puts( "YY_G(yy_current_buffer)->yy_at_bol = \\" );
+ indent_puts( "\t\t(YY_G(yytext)[YY_G(yyleng) - 1] == '\\n'); \\" );
indent_down();
}
indent_puts( "YY_USER_ACTION" );
@@ -1387,12 +1397,12 @@ void make_tables()
if ( yymore_used && ! yytext_is_array )
{
- indent_puts( "yy_more_len = 0;" );
- indent_puts( "if ( yy_more_flag )" );
+ indent_puts( "YY_G(yy_more_len) = 0;" );
+ indent_puts( "if ( YY_G(yy_more_flag) )" );
indent_up();
indent_puts( "{" );
- indent_puts( "yy_more_len = yy_c_buf_p - yytext_ptr;" );
- indent_puts( "yy_more_flag = 0;" );
+ indent_puts( "YY_G(yy_more_len) = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);" );
+ indent_puts( "YY_G(yy_more_flag) = 0;" );
indent_puts( "}" );
indent_down();
}
@@ -1461,7 +1471,7 @@ void make_tables()
"fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
indent_puts(
- " yy_rule_linenum[yy_act], yytext );" );
+ " yy_rule_linenum[yy_act], YY_G(yytext) );" );
}
indent_down();
@@ -1479,7 +1489,7 @@ void make_tables()
{
indent_puts(
"fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," );
- indent_puts( " yytext );" );
+ indent_puts( " YY_G(yytext) );" );
}
indent_down();
@@ -1549,7 +1559,7 @@ void make_tables()
set_indent( 4 );
if ( fullspd || fulltbl )
- indent_puts( "yy_cp = yy_c_buf_p;" );
+ indent_puts( "yy_cp = YY_G(yy_c_buf_p);" );
else
{ /* compressed table */
@@ -1558,9 +1568,9 @@ void make_tables()
/* Do the guaranteed-needed backing up to figure
* out the match.
*/
- indent_puts( "yy_cp = yy_last_accepting_cpos;" );
+ indent_puts( "yy_cp = YY_G(yy_last_accepting_cpos);" );
indent_puts(
- "yy_current_state = yy_last_accepting_state;" );
+ "yy_current_state = YY_G(yy_last_accepting_state);" );
}
else
@@ -1568,7 +1578,7 @@ void make_tables()
* yy_current_state was set up by
* yy_get_previous_state().
*/
- indent_puts( "yy_cp = yy_c_buf_p;" );
+ indent_puts( "yy_cp = YY_G(yy_c_buf_p);" );
}
@@ -1591,7 +1601,7 @@ void make_tables()
{ /* update yylineno inside of unput() */
indent_puts( "if ( c == '\\n' )" );
indent_up();
- indent_puts( "--yylineno;" );
+ indent_puts( "--YY_G(yylineno);" );
indent_down();
}
@@ -1599,12 +1609,12 @@ void make_tables()
/* Update BOL and yylineno inside of input(). */
if ( bol_needed )
{
- indent_puts( "yy_current_buffer->yy_at_bol = (c == '\\n');" );
+ indent_puts( "YY_G(yy_current_buffer)->yy_at_bol = (c == '\\n');" );
if ( do_yylineno )
{
- indent_puts( "if ( yy_current_buffer->yy_at_bol )" );
+ indent_puts( "if ( YY_G(yy_current_buffer)->yy_at_bol )" );
indent_up();
- indent_puts( "++yylineno;" );
+ indent_puts( "++YY_G(yylineno);" );
indent_down();
}
}
@@ -1613,7 +1623,7 @@ void make_tables()
{
indent_puts( "if ( c == '\\n' )" );
indent_up();
- indent_puts( "++yylineno;" );
+ indent_puts( "++YY_G(yylineno);" );
indent_down();
}
diff --git a/main.c b/main.c
index ff4e3e2..b468e76 100644
--- a/main.c
+++ b/main.c
@@ -54,6 +54,7 @@ int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
int interactive, caseins, lex_compat, do_yylineno, useecs, fulltbl, usemecs;
int fullspd, gen_line_dirs, performance_report, backing_up_report;
int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap, csize;
+int reentrant, reentrant_bison_pure;
int yymore_used, reject, real_reject, continued_action, in_rule;
int yymore_really_used, reject_really_used;
int datapos, dataline, linenum, out_linenum;
@@ -181,6 +182,9 @@ void check_options()
if ( fulltbl || fullspd )
flexerror( _( "Can't use -f or -F with -l option" ) );
+ if( reentrant || reentrant_bison_pure )
+ flexerror( _( "Can't use -R or -Rb with -l option" ) );
+
/* Don't rely on detecting use of yymore() and REJECT,
* just assume they'll be used.
*/
@@ -241,6 +245,10 @@ void check_options()
yytext_is_array = false;
}
+ if ( C_plus_plus && (reentrant || reentrant_bison_pure) )
+ flexerror( _( "Options -+ and -R are mutually exclusive." ) );
+
+
if ( useecs )
{ /* Set up doubly-linked equivalence classes. */
@@ -298,6 +306,16 @@ void check_options()
if ( skelname && (skelfile = fopen( skelname, "r" )) == NULL )
lerrsf( _( "can't open skeleton file %s" ), skelname );
+ if ( reentrant )
+ {
+ outn("#define YY_REENTRANT 1");
+ if( yytext_is_array )
+ outn("#define YY_TEXT_IS_ARRAY");
+ }
+
+ if ( reentrant_bison_pure )
+ outn("#define YY_REENTRANT_BISON_PURE 1");
+
if ( strcmp( prefix, "yy" ) )
{
#define GEN_PREFIX(name) out_str3( "#define yy%s %s%s\n", name, prefix, name )
@@ -321,9 +339,33 @@ void check_options()
GEN_PREFIX( "out" );
GEN_PREFIX( "restart" );
GEN_PREFIX( "text" );
+ GEN_PREFIX( "lex_init" );
+ GEN_PREFIX( "lex_destroy" );
+ GEN_PREFIX( "get_extra" );
+ GEN_PREFIX( "set_extra" );
+ GEN_PREFIX( "get_in" );
+ GEN_PREFIX( "set_in" );
+ GEN_PREFIX( "get_out" );
+ GEN_PREFIX( "set_out" );
+ GEN_PREFIX( "get_leng" );
+ GEN_PREFIX( "get_text" );
+ GEN_PREFIX( "get_lineno" );
+ GEN_PREFIX( "set_lineno" );
+
+ outn( "#ifdef YY_REENTRANT_BISON_PURE" );
+ GEN_PREFIX( "get_lval" );
+ GEN_PREFIX( "set_lval" );
+ outn( "#ifdef YYLTYPE" );
+ GEN_PREFIX( "get_lloc" );
+ GEN_PREFIX( "set_lloc" );
+ outn( "#endif" );
+ outn( "#endif" );
if ( do_yylineno )
GEN_PREFIX( "lineno" );
+
+ if ( do_yylineno && reentrant)
+ outn ( "#define YY_USE_LINENO 1");
}
if ( do_yywrap )
@@ -420,8 +462,15 @@ int exit_status;
putc( 'p', stderr );
if ( performance_report > 1 )
putc( 'p', stderr );
- if ( spprdflt )
+ if ( spprdflt )
putc( 's', stderr );
+ if ( reentrant )
+ {
+ putc( 'R', stderr );
+
+ if( reentrant_bison_pure )
+ putc( 'b', stderr );
+ }
if ( use_stdout )
putc( 't', stderr );
if ( printstats )
@@ -591,6 +640,7 @@ char **argv;
yymore_really_used = reject_really_used = unspecified;
interactive = csize = unspecified;
do_yywrap = gen_line_dirs = usemecs = useecs = true;
+ reentrant = reentrant_bison_pure = false;
performance_report = 0;
did_outfilename = 0;
prefix = "yy";
@@ -765,6 +815,29 @@ char **argv;
++performance_report;
break;
+ case 'R':
+ if ( i != 1 )
+ flexerror(
+ _( "-P flag must be given separately" ) );
+ reentrant = true;
+
+ /* Optional arguments follow -R */
+
+ for ( ++i; arg[i] != '\0'; ++i )
+ switch ( arg[i] )
+ {
+ case 'b':
+ reentrant_bison_pure = true;
+ break;
+
+ default:
+ lerrif(
+ _( "unknown -R option '%c'" ),
+ (int) arg[i] );
+ break;
+ }
+ goto get_next_arg;
+
case 'S':
if ( i != 1 )
flexerror(
@@ -945,7 +1018,10 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
if ( ! do_yywrap )
{
- outn( "\n#define yywrap() 1" );
+ if( reentrant )
+ outn( "\n#define yywrap(YY_ONLY_ARG) 1" );
+ else
+ outn( "\n#define yywrap(n) 1" );
outn( "#define YY_SKIP_YYWRAP" );
}
@@ -966,9 +1042,19 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
}
else
- {
+ {
+ /* In reentrant scanner, stdinit is handled in flex.skl. */
if ( do_stdinit )
{
+ outn( "#ifdef YY_REENTRANT" );
+ outn( "#ifdef VMS" );
+ outn( "#ifdef __VMS_POSIX" );
+ outn( "#define YY_STDINIT" );
+ outn( "#endif" );
+ outn( "#else" );
+ outn( "#define YY_STDINIT" );
+ outn( "#endif" );
+ outn( "#else /* end YY_REENTRANT */" );
outn( "#ifdef VMS" );
outn( "#ifndef __VMS_POSIX" );
outn( yy_nostdinit );
@@ -978,10 +1064,15 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
outn( "#else" );
outn( yy_stdinit );
outn( "#endif" );
+ outn( "#endif" );
}
- else
+ else
+ {
+ outn( "#ifndef YY_REENTRANT" );
outn( yy_nostdinit );
+ outn( "#endif" );
+ }
}
if ( fullspd )
@@ -995,7 +1086,7 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
if ( lex_compat )
outn( "#define YY_FLEX_LEX_COMPAT" );
- if ( do_yylineno && ! C_plus_plus )
+ if ( do_yylineno && ! C_plus_plus && ! reentrant )
{
outn( "extern int yylineno;" );
outn( "int yylineno = 1;" );
@@ -1021,13 +1112,17 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
else
{
- if ( yytext_is_array )
+ if ( yytext_is_array && !reentrant)
outn( "extern char yytext[];\n" );
else
{
+ outn( "#ifdef YY_REENTRANT" );
+ outn( "#define yytext_ptr YY_G(yytext)" );
+ outn( "#else" );
outn( "extern char *yytext;" );
outn( "#define yytext_ptr yytext" );
+ outn( "#endif" );
}
if ( yyclass )
@@ -1111,7 +1206,7 @@ void usage()
FILE *f = stdout;
fprintf( f,
-_( "%s [-bcdfhilnpstvwBFILTV78+? -C[aefFmr] -ooutput -Pprefix -Sskeleton]\n" ),
+_( "%s [-bcdfhilnpstvwBFILTV78+? -R[b] -C[aefFmr] -ooutput -Pprefix -Sskeleton]\n" ),
program_name );
fprintf( f, _( "\t[--help --version] [file ...]\n" ) );
@@ -1148,6 +1243,9 @@ _( "%s [-bcdfhilnpstvwBFILTV78+? -C[aefFmr] -ooutput -Pprefix -Sskeleton]\n" ),
fprintf( f,
_( "\t-I generate interactive scanner (opposite of -B)\n" ) );
fprintf( f, _( "\t-L suppress #line directives in scanner\n" ) );
+ fprintf( f, _( "\t-R generate a reentrant C scanner\n" ) );
+ fprintf( f,
+_( "\t\t-Rb reentrant scanner is to be called by a bison pure parser.\n" ) );
fprintf( f, _( "\t-T %s should run in trace mode\n" ), program_name );
fprintf( f, _( "\t-V report %s version\n" ), program_name );
fprintf( f, _( "\t-7 generate 7-bit scanner\n" ) );
diff --git a/nfa.c b/nfa.c
index 216cc30..ec0ffeb 100644
--- a/nfa.c
+++ b/nfa.c
@@ -235,11 +235,11 @@ int mach, variable_trail_rule, headcnt, trailcnt;
/* Do trailing context magic to not match the trailing
* characters.
*/
- char *scanner_cp = "yy_c_buf_p = yy_cp";
+ char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp";
char *scanner_bp = "yy_bp";
add_action(
- "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */\n" );
+ "*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n" );
if ( headcnt > 0 )
{
diff --git a/scan.l b/scan.l
index 44e705a..a30031d 100644
--- a/scan.l
+++ b/scan.l
@@ -242,7 +242,9 @@ LEXOPT [aceknopr]
lex-compat lex_compat = option_sense;
main {
action_define( "YY_MAIN", option_sense );
- do_yywrap = ! option_sense;
+ /* Override yywrap */
+ if( option_sense == true )
+ do_yywrap = false;
}
meta-ecs usemecs = option_sense;
never-interactive {
@@ -251,6 +253,12 @@ LEXOPT [aceknopr]
perf-report performance_report += option_sense ? 1 : -1;
pointer yytext_is_array = ! option_sense;
read use_read = option_sense;
+ reentrant reentrant = option_sense;
+ reentrant-bison {
+ /* reentrant-bison implies reentrant. */
+ if ((reentrant_bison_pure = option_sense) != 0)
+ reentrant = 1;
+ }
reject reject_really_used = option_sense;
stack action_define( "YY_STACK_USED", option_sense );
stdinit do_stdinit = option_sense;
@@ -260,7 +268,7 @@ LEXOPT [aceknopr]
warn nowarn = ! option_sense;
yylineno do_yylineno = option_sense;
yymore yymore_really_used = option_sense;
- yywrap do_yywrap = option_sense;
+ yywrap do_yywrap = option_sense;
yy_push_state ACTION_IFDEF("YY_NO_PUSH_STATE", ! option_sense);
yy_pop_state ACTION_IFDEF("YY_NO_POP_STATE", ! option_sense);
@@ -270,6 +278,21 @@ LEXOPT [aceknopr]
yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
+ yyget_extra ACTION_IFDEF("YY_NO_GET_EXTRA", ! option_sense);
+ yyset_extra ACTION_IFDEF("YY_NO_SET_EXTRA", ! option_sense);
+ yyget_leng ACTION_IFDEF("YY_NO_GET_LENG", ! option_sense);
+ yyget_text ACTION_IFDEF("YY_NO_GET_TEXT", ! option_sense);
+ yyget_lineno ACTION_IFDEF("YY_NO_GET_LINENO", ! option_sense);
+ yyset_lineno ACTION_IFDEF("YY_NO_SET_LINENO", ! option_sense);
+ yyget_in ACTION_IFDEF("YY_NO_GET_IN", ! option_sense);
+ yyset_in ACTION_IFDEF("YY_NO_SET_IN", ! option_sense);
+ yyget_out ACTION_IFDEF("YY_NO_GET_OUT", ! option_sense);
+ yyset_out ACTION_IFDEF("YY_NO_SET_OUT", ! option_sense);
+ yyget_lval ACTION_IFDEF("YY_NO_GET_LVAL", ! option_sense);
+ yyset_lval ACTION_IFDEF("YY_NO_SET_LVAL", ! option_sense);
+ yyget_lloc ACTION_IFDEF("YY_NO_GET_LLOC", ! option_sense);
+ yyset_lloc ACTION_IFDEF("YY_NO_SET_LLOC", ! option_sense);
+
outfile return OPT_OUTFILE;
prefix return OPT_PREFIX;
yyclass return OPT_YYCLASS;