#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)
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin YY_G(yyin_r)
+#define yyout YY_G(yyout_r)
+#define yyextra YY_G(yyextra_r)
+#define yyleng YY_G(yyleng_r)
+#define yytext YY_G(yytext_r)
+#define yylineno YY_G(yylineno_r)
int yylex_init YY_PROTO((void** scanner));
int yylex_destroy YY_PROTO((void* scanner));
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( YY_G(yyin) YY_CALL_LAST_ARG )
+#define YY_NEW_FILE yyrestart( yyin YY_CALL_LAST_ARG )
#define YY_END_OF_BUFFER_CHAR 0
{ \
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_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
YY_G(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_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
YY_G(yy_current_buffer)->yy_at_bol = at_bol; \
}
{
/* User-defined. Not touched by flex. */
- YY_EXTRA_TYPE yyextra;
+ YY_EXTRA_TYPE yyextra_r;
/* The rest are the same as the globals declared in the non-reentrant scanner. */
- FILE *yyin, *yyout;
+ FILE *yyin_r, *yyout_r;
YY_BUFFER_STATE yy_current_buffer;
char yy_hold_char;
int yy_n_chars;
- int yyleng;
+ int yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
yy_state_type yy_last_accepting_state;
char* yy_last_accepting_cpos;
- int yylineno;
+ int yylineno_r;
#ifdef YY_TEXT_IS_ARRAY
- char yytext[YYLMAX];
+ char yytext_r[YYLMAX];
char *yytext_ptr;
int yy_more_offset;
int yy_prev_more_offset;
#else
- char *yytext;
+ char *yytext_r;
int yy_more_flag;
int yy_more_len;
#endif
#ifdef YY_REENTRANT_BISON_PURE
- YYSTYPE * yylval;
+ YYSTYPE * yylval_r;
#ifdef YYLTYPE
- YYLTYPE * yylloc;
+ YYLTYPE * yylloc_r;
#endif
#endif
/* 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)
+# define yylval YY_G(yylval_r)
# ifdef YYLTYPE
-# define yylloc_r YY_G(yylloc)
+# define yylloc YY_G(yylloc_r)
# endif
#endif
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( YY_G(yytext), YY_G(yyleng), 1, YY_G(yyout) )
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
%+ C++ definition
#define ECHO LexerOutput( yytext, yyleng )
%*
%% [7.0] user's declarations go here
#ifdef YY_REENTRANT_BISON_PURE
- YY_G(yylval) = yylvalp;
+ yylval = yylvalp;
#ifdef YYLTYPE
- YY_G(yylloc) = yyllocp;
+ yylloc = yyllocp;
#endif
#endif
if ( ! YY_G(yy_start) )
YY_G(yy_start) = 1; /* first start state */
- if ( ! YY_G(yyin) )
+ if ( ! yyin )
%-
- YY_G(yyin) = stdin;
+ yyin = stdin;
%+
yyin = & FLEX_STD cin;
%*
- if ( ! YY_G(yyout) )
+ if ( ! yyout )
%-
- YY_G(yyout) = stdout;
+ yyout = stdout;
%+
yyout = & FLEX_STD cout;
%*
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_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
* back-up) that will match for the new input source.
*/
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_input_file = yyin;
YY_G(yy_current_buffer)->yy_buffer_status = YY_BUFFER_NORMAL;
}
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( YY_G(yyin) YY_CALL_LAST_ARG);
+ yyrestart( yyin YY_CALL_LAST_ARG);
}
else
*/
/* Reset buffer status. */
- yyrestart( YY_G(yyin) YY_CALL_LAST_ARG);
+ yyrestart( yyin YY_CALL_LAST_ARG);
/* fall through */
{
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_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
yy_init_buffer( YY_G(yy_current_buffer), input_file YY_CALL_LAST_ARG);
yy_load_buffer_state( YY_CALL_ONLY_ARG );
{
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;
+ yyin = YY_G(yy_current_buffer)->yy_input_file;
YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
}
do \
{ \
/* Undo effects of setting up yytext. */ \
- YY_G(yytext)[YY_G(yyleng)] = YY_G(yy_hold_char); \
- YY_G(yy_c_buf_p) = YY_G(yytext) + n; \
+ yytext[yyleng] = YY_G(yy_hold_char); \
+ YY_G(yy_c_buf_p) = yytext + n; \
YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \
*YY_G(yy_c_buf_p) = '\0'; \
- YY_G(yyleng) = n; \
+ yyleng = n; \
} \
while ( 0 )
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yyextra);
+ return yyextra;
}
#endif /* !YY_NO_GET_EXTRA */
YY_DECL_LAST_ARG
# endif
{
- return YY_G(yylineno);
+ return yylineno;
}
#endif /* !YY_NO_GET_LINENO */
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yyin);
+ return yyin;
}
#endif /* !YY_NO_GET_IN */
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yyout);
+ return yyout;
}
#endif /* !YY_NO_GET_OUT */
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yyleng);
+ return yyleng;
}
#endif /* !YY_NO_GET_LENG */
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yytext);
+ return yytext;
}
#endif /* !YY_NO_GET_TEXT */
YY_DECL_LAST_ARG
#endif
{
- YY_G(yyextra) = user_defined ;
+ yyextra = user_defined ;
}
#endif /* !YY_NO_SET_EXTRA */
YY_DECL_LAST_ARG
# endif
{
- YY_G(yylineno) = line_number;
+ yylineno = line_number;
}
#endif /* !YY_NO_SET_LINENO */
YY_DECL_LAST_ARG
#endif
{
- YY_G(yyin) = in_str ;
+ yyin = in_str ;
}
#endif /* !YY_NO_SET_IN */
YY_DECL_LAST_ARG
#endif
{
- YY_G(yyout) = out_str ;
+ yyout = out_str ;
}
#endif /* !YY_NO_SET_OUT */
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yylval);
+ return yylval;
}
#endif /* !YY_NO_GET_LVAL */
YY_DECL_LAST_ARG
#endif
{
- YY_G(yylval) = yylvalp;
+ yylval = yylvalp;
}
#endif /* !YY_NO_SET_LVAL */
YY_DECL_LAST_ARG
#endif
{
- return YY_G(yylloc);
+ return yylloc;
}
#endif /* !YY_NO_GET_LLOC */
YY_DECL_LAST_ARG
#endif
{
- YY_G(yylloc) = yyllocp;
+ yylloc = yyllocp;
}
#endif /* !YY_NO_SET_LLOC */
/* We do not touch yylineno unless the option is enabled. */
#ifdef YY_USE_LINENO
- YY_G(yylineno) = 1;
+ yylineno = 1;
#endif
YY_G(yy_current_buffer) = 0;
YY_G(yy_c_buf_p) = (char *) 0;
/* Defined in main.c */
#ifdef YY_STDINIT
- YY_G(yyin) = stdin;
- YY_G(yyout) = stdout;
+ yyin = stdin;
+ yyout = stdout;
#else
- YY_G(yyin) = (FILE *) 0;
- YY_G(yyout) = (FILE *) 0;
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
#endif
return 0;
}
compatibility. In particular, the declaration of
@code{yylex}
is modified, and support for
-@code{yylval_r}
+@code{yylval}
and
-@code{yylloc_r}
+@code{yylloc}
is incorporated. @xref{bison pure}.
The options @samp{--reentrant} and @samp{--reentrant-bison} do not affect the performance of
directs @code{flex} to generate a scanner
that maintains the number of the current line read from its input in the
global variable @code{yylineno}. This option is implied by @code{%option
-lex-compat}. In a reentrant C scanner, the macro @code{yylineno_r} is
+lex-compat}. In a reentrant C scanner, the macro @code{yylineno} is
accessible regardless of the value of @code{%option yylineno}, however, its
value is not modified by @code{flex} unless @code{%option yylineno} is enabled.
"eval(".+")" {
void * scanner;
yylex_init( &scanner );
- yytext_r[yyleng_r-1] = ' ';
+ yytext[yyleng-1] = ' ';
- yyscan_string( yytext_r + 5, scanner );
+ yyscan_string( yytext + 5, scanner );
yylex( scanner );
yylex_destroy( scanner );
All functions take one additional argument: @code{yy_globals}
@item
-All global variables are replaced by their @samp{_r} equivalents.
+All global variables are replaced by their macro equivalents.
@item
@code{yylex_init} and @code{yylex_destroy} must be called before and
@code{flex} variables.
@item
-User-specific data can be stored in @code{yyextra_r}.
+User-specific data can be stored in @code{yyextra}.
@end itemize
@node reentrant example, reentrant detail, reentrant overview, reentrant
"//" yy_push_state( COMMENT, yy_globals);
.|\n
<COMMENT>\n yy_pop_state( yy_globals );
- <COMMENT>[^\n]+ fprintf( yyout_r, "%s\n", yytext_r);
+ <COMMENT>[^\n]+ fprintf( yyout, "%s\n", yytext);
%%
int main ( int argc, char * argv[] )
{
@node specify reentrant, extra reentrant argument, reentrant detail, reentrant detail
@subsection Declaring a Scanner as Reentrant
- %option reentrant
-must be specified.
+ %option reentrant (--reentrant) must be specified.
Notice that @code{%option reentrant} is specified in the above example
(@pxref{reentrant example}. Had this option not been specified,
additional argument.
@node global replacement, init and destroy and destroy, extra reentrant argument, reentrant detail
-@subsection Global Variables Replaced
+@subsection Global Variables Replaced by Macros
-All global variables are replaced by their @code{_r} equivalents.
+All global variables are replaced by macro equivalents.
-Notice in the above example that @code{yyout} and @code{yytext} are
-replaced by @code{yyout_r} and @code{yytext_r}. These are macros that
-will expand to their equivalent lvalue. All of the familiar @code{flex}
-globals have been replaced by their @code{_r} equivalents. Wherever you
-would normally use @code{yytext} in actions, you must use @code{yytext_r}
-instead. This rule applies to all @code{flex} variables. The following
-is an example that uses the @code{_r} macros:
+Note that in the above example, @code{yyout} and @code{yytext} are
+not plain variables. These are macros that will expand to their equivalent lvalue.
+All of the familiar @code{flex} globals have been replaced by their macro
+equivalents. In particular, @code{yytext}, @code{yyleng}, @code{yylineno},
+@code{yyin}, @code{yyout}, @code{yyextra}, @code{yylval}, and @code{yylloc}
+are macros. You may safely use these macros in actions as if they were plain
+variables. We only tell you this so you don't expect to link to these variables
+externally. Currently, each macro expands to a member of an internal struct, e.g.,
@example
@verbatim
- %%
- #define SWAP(a,b) do{int t=a; a=b; b=t;}while(0)
- "reverse me" {
- int i;
- for( i =0; i yyleng_r/2 ; i++ )
- SWAP( yytext_r[i], yytext_r[yyleng_r-i-1] );
- fprintf( yyout_r, "%s", yytext_r );
- }
+#define yytext (((struct yy_globals_t*)yy_globals)->yytext_r)
@end verbatim
@end example
One important thing to remember about
-@code{yytext_r}
+@code{yytext}
and friends is that
-@code{yytext_r}
+@code{yytext}
is not a global variable in a reentrant
scanner, you can not access it directly from outside an action or from
-other functions. You must use the accessor method
-@code{yyget_text}
+other functions. You must use an accessor method, e.g.,
+@code{yyget_text},
to accomplish this. (See below).
@node init and destroy and destroy, accessor methods, global replacement, reentrant detail
Many scanners that you build will be part of a larger project. Portions
of your project will need access to @code{flex} values, such as
@code{yytext}. In a non-reentrant scanner, these values are global, so
-there is no problem. However, in a reentrant scanner, there are no
+there is no problem accessing them. However, in a reentrant scanner, there are no
global @code{flex} values. You can not access them directly. Instead,
you must access @code{flex} values using accessor methods (get/set
functions). Each accessor method is named @code{yyget_NAME} or
@node extra data, , accessor methods, reentrant detail
@subsection Extra Data
-User-specific data can be stored in @code{yyextra_r}.
+User-specific data can be stored in @code{yyextra}.
In a reentrant scanner, it is unwise to use global variables to
communicate with or maintain state between different pieces of your program.
and
@code{yyset_extra}
from outside the scanner, and through the shortcut macro
-@code{yyextra_r}
+@code{yyextra}
from within the scanner itself. They are defined as follows:
@example
@end example
By default, @code{YY_EXTRA_TYPE} is defined as type @code{void *}. You
-will have to cast @code{yyextra_r} and the return value from
+will have to cast @code{yyextra} and the return value from
@code{yyget_extra} to the appropriate value each time you access the
extra data. To avoid casting, you may override the default type by
defining @code{YY_EXTRA_TYPE} in section 1 of your scanner:
%option reentrant
%%
- __filesize__ printf( "%ld", yyextra_r->st_size );
- __lastmod__ printf( "%ld", yyextra_r->st_mtime );
+ __filesize__ printf( "%ld", yyextra->st_size );
+ __lastmod__ printf( "%ld", yyextra->st_mtime );
%%
void scan_file( char* filename )
{
@code{bison} in any detail. For more information about generating pure
@code{bison} parsers, see @ref{Top, , , bison, The GNU Bison Manual} A
@code{bison}-compatible scanner is generated by declaring @samp{%option
-reentrant-bison} or by supplying @samp{-Rb} when invoking @code{flex}
+reentrant-bison} or by supplying @samp{--reentran-bison} when invoking @code{flex}
from the command line. This instructs @code{flex} that the macros
-@code{yylval_r} and @code{yylloc_r} may be used. The data types for
-@code{yylval_r} and @code{yylloc_r}, (@code{YYSTYPE} and @code{YYLTYPE},
+@code{yylval} and @code{yylloc} may be used. The data types for
+@code{yylval} and @code{yylloc}, (@code{YYSTYPE} and @code{YYLTYPE},
are typically defined in a header file, included in section 1 of the
@code{flex} input file. @code{%option reentrant-bison} implies
@code{%option reentrant}. If @code{%option reentrant-bison} is
specified, @code{flex} provides support for the functions
@code{yyget_lval}, @code{yyset_lval}, @code{yyget_lloc}, and
@code{yyset_lloc}, defined below, and the corresponding macros
-@code{yylval_r} and @code{yylloc_r}, for use within actions.
+@code{yylval} and @code{yylloc}, for use within actions.
@example
@verbatim
@end verbatim
@end example
-Note that the macros @code{yylval_r} and @code{yylloc_r} evaluate to
+Note that the macros @code{yylval} and @code{yylloc} evaluate to
pointers. Support for @code{yylloc} is optional in @code{bison}, so it
is optional in @code{flex} as well. This support is automatically
handled by @code{flex}. Specifically, support for @code{yyloc} is only
%option reentrant-bison
%
- [[:digit:]]+ { yylval_r->num = atoi(yytext_r); return NUMBER;}
- [[:alnum:]]+ { yylval_r->str = strdup(yytext_r); return STRING;}
- "="|";" { return yytext_r[0];}
+ [[:digit:]]+ { yylval->num = atoi(yytext); return NUMBER;}
+ [[:alnum:]]+ { yylval->str = strdup(yytext); return STRING;}
+ "="|";" { return yytext[0];}
. {}
%
-@end vernbatim
+@end verbatim
@end example
As you can see, there really is no magic here. We just use
-@code{yylval_r} as we would any other variable. The data type of
-@code{yylval_r} is generated by @code{bison}, and included in the file
+@code{yylval} as we would any other variable. The data type of
+@code{yylval} is generated by @code{bison}, and included in the file
@file{y.tab.h}. Here is the corresponding @code{bison} parser:
@example
%union {
int num;
char* str;
- }
+ }
%token <str> STRING
%token <num> NUMBER
%%
@node reentrant functions, , bison pure, reentrant
@section FUNCTIONS AND MACROS AVAILABLE IN REENTRANT C SCANNERS
-The ffollowing Functions are available in a reentrant scanner:
+The following Functions are available in a reentrant scanner:
@example
@verbatim
@end verbatim
@end example
-There are no ``set'' functions for yytext_r and yyleng_r. This is intentional.
+There are no ``set'' functions for yytext and yyleng. This is intentional.
The following Macro shortcuts are available in actions in a reentrant
scanner:
@example
@verbatim
- yytext_r
- yyleng_r
- yyin_r
- yyout_r
- yylineno_r
- yyextra_r
+ yytext
+ yyleng
+ yyin
+ yyout
+ yylineno
+ yyextra
@end verbatim
@end example
-In a reentrant C scanner, support for yylineno_r is always present
-(i.e., you may access yylineno_r), but the value is never modified by
+In a reentrant C scanner, support for yylineno is always present
+(i.e., you may access yylineno), but the value is never modified by
@code{flex} unless @code{%option yylineno} is enabled. This is to allow
the user to maintain the line count independently of @code{flex}.
The following functions and macros are made available when @code{%option
-reentrant-bison} (@samp{-Rb}) is specified:
+reentrant-bison} (@samp{--reentrant-bison}) is specified:
@example
@verbatim
YYLTYPE *yyget_lloc ( void * scanner );
void yyset_lval ( YYSTYPE * yylvalp , void * scanner );
void yyset_lloc ( YYLTYPE * yyllocp , void * scanner );
- yylval_r
- yylloc_r
+ yylval
+ yylloc
@end verbatim
@end example
if ( yymore_used && ! yytext_is_array )
{
indent_puts( "YY_G(yytext_ptr) -= YY_G(yy_more_len); \\" );
- indent_puts( "YY_G(yyleng) = (size_t) (yy_cp - YY_G(yytext_ptr)); \\" );
+ indent_puts( "yyleng = (size_t) (yy_cp - YY_G(yytext_ptr)); \\" );
}
else
- indent_puts( "YY_G(yyleng) = (size_t) (yy_cp - yy_bp); \\" );
+ indent_puts( "yyleng = (size_t) (yy_cp - yy_bp); \\" );
/* Now also deal with copying yytext_ptr to yytext if needed. */
skelout(); /* %% [3.0] - break point in skel */
{
if ( yymore_used )
indent_puts(
- "if ( YY_G(yyleng) + YY_G(yy_more_offset) >= YYLMAX ) \\" );
+ "if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \\" );
else
- indent_puts( "if ( YY_G(yyleng) >= YYLMAX ) \\" );
+ indent_puts( "if ( yyleng >= YYLMAX ) \\" );
indent_up();
indent_puts(
if ( yymore_used )
{
indent_puts(
-"yy_flex_strncpy( &YY_G(yytext)[YY_G(yy_more_offset)], YY_G(yytext_ptr), YY_G(yyleng) + 1 YY_CALL_LAST_ARG); \\" );
- indent_puts( "YY_G(yyleng) += YY_G(yy_more_offset); \\" );
+"yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \\" );
+ indent_puts( "yyleng += YY_G(yy_more_offset); \\" );
indent_puts(
"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( YY_G(yytext), YY_G(yytext_ptr), YY_G(yyleng) + 1 YY_CALL_LAST_ARG); \\" );
+ "yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \\" );
}
}
if ( yytext_is_array )
{
indent_puts(
- "#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( YY_G(yytext) YY_CALL_LAST_ARG))" );
+ "#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext YY_CALL_LAST_ARG))" );
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_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\" );
- indent_puts( "YY_G(yyleng) -= YY_G(yy_more_offset); \\" );
+ indent_puts( "yyleng -= YY_G(yy_more_offset); \\" );
indent_puts( "}" );
indent_down();
}
if ( use_read )
{
outn(
-"\tif ( (result = read( fileno(YY_G(yyin)), (char *) buf, max_size )) < 0 ) \\" );
+"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
outn( "\t\tint c = '*'; \\");
outn( "\t\tsize_t n; \\" );
outn( "\t\tfor ( n = 0; n < max_size && \\" );
- outn( "\t\t\t (c = getc( YY_G(yyin) )) != EOF && c != '\\n'; ++n ) \\" );
+ outn( "\t\t\t (c = getc( 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( YY_G(yyin) ) ) \\" );
+ outn( "\t\tif ( c == EOF && ferror( 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, YY_G(yyin) )) == 0) \\" );
- outn( "\t\t && ferror( YY_G(yyin) ) ) \\" );
+ "\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\" );
+ outn( "\t\t && ferror( yyin ) ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
indent_up();
if ( bol_needed )
{
- indent_puts( "if ( YY_G(yyleng) > 0 ) \\" );
+ indent_puts( "if ( yyleng > 0 ) \\" );
indent_up();
indent_puts( "YY_G(yy_current_buffer)->yy_at_bol = \\" );
- indent_puts( "\t\t(YY_G(yytext)[YY_G(yyleng) - 1] == '\\n'); \\" );
+ indent_puts( "\t\t(yytext[yyleng - 1] == '\\n'); \\" );
indent_down();
}
indent_puts( "YY_USER_ACTION" );
indent_puts( "{" );
indent_puts( "int yyl;" );
do_indent();
- out_str( "for ( yyl = %s; yyl < YY_G(yyleng); ++yyl )\n",
+ out_str( "for ( yyl = %s; yyl < yyleng; ++yyl )\n",
yymore_used ? (yytext_is_array ? "yy_prev_more_offset" :
"yy_more_len") : "0");
indent_up();
- indent_puts( "if ( YY_G(yytext)[yyl] == '\\n' )" );
+ indent_puts( "if ( yytext[yyl] == '\\n' )" );
indent_up();
- indent_puts( "++YY_G(yylineno);" );
+ indent_puts( "++yylineno;" );
indent_down();
indent_down();
indent_puts( "}" );
"fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
indent_puts(
- " yy_rule_linenum[yy_act], YY_G(yytext) );" );
+ " yy_rule_linenum[yy_act], yytext );" );
}
indent_down();
{
indent_puts(
"fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," );
- indent_puts( " YY_G(yytext) );" );
+ indent_puts( " yytext );" );
}
indent_down();
{ /* update yylineno inside of unput() */
indent_puts( "if ( c == '\\n' )" );
indent_up();
- indent_puts( "--YY_G(yylineno);" );
+ indent_puts( "--yylineno;" );
indent_down();
}
{
indent_puts( "if ( YY_G(yy_current_buffer)->yy_at_bol )" );
indent_up();
- indent_puts( "++YY_G(yylineno);" );
+ indent_puts( "++yylineno;" );
indent_down();
}
}
{
indent_puts( "if ( c == '\\n' )" );
indent_up();
- indent_puts( "++YY_G(yylineno);" );
+ indent_puts( "++yylineno;" );
indent_down();
}
GEN_PREFIX( "_flush_buffer" );
GEN_PREFIX( "_load_buffer_state" );
GEN_PREFIX( "_switch_to_buffer" );
- GEN_PREFIX( "in" );
- GEN_PREFIX( "leng" );
GEN_PREFIX( "lex" );
- GEN_PREFIX( "out" );
GEN_PREFIX( "restart" );
- GEN_PREFIX( "text" );
GEN_PREFIX( "lex_init" );
GEN_PREFIX( "lex_destroy" );
GEN_PREFIX( "get_extra" );
outn( "#endif" );
outn( "#endif" );
- if ( do_yylineno )
- GEN_PREFIX( "lineno" );
-
if ( do_yylineno && reentrant)
outn ( "#define YY_USE_LINENO 1");
}
else
{
- outn( "#ifdef YY_REENTRANT" );
- outn( "#define yytext_ptr YY_G(yytext)" );
- outn( "#else" );
+ outn( "#ifndef YY_REENTRANT" );
outn( "extern char *yytext;" );
- outn( "#define yytext_ptr yytext" );
outn( "#endif" );
+ outn( "#define yytext_ptr yytext" );
}
if ( yyclass )
%%
- if ( !yyextra_r)
- yyextra_r = 1;
+ if ( !yyextra)
+ yyextra = 1;
^[[:digit:]]+ {
- yylval_r->lineno = yyextra_r++;
- yylloc_r->first_line = (int)strtol(yytext_r,NULL,10);
+ yylval->lineno = yyextra++;
+ yylloc->first_line = (int)strtol(yytext,NULL,10);
return LINENO;
}
":" { return COLON; }
" " { return SPACE; }
"=" { return EQUAL; }
-[[:alnum:]_]+ { yylval_r->str = STRDUP(yytext_r); return IDENT;}
+[[:alnum:]_]+ { yylval->str = STRDUP(yytext); return IDENT;}
\r|\n { }
. { yyterminate();}
%x DISCARD_THRU_GT
%%
- #define YY_USER_INIT yyextra_r = no;
- #define NEED_TAG_NAME yyextra_r
+ #define YY_USER_INIT yyextra = no;
+ #define NEED_TAG_NAME yyextra
<INITIAL>{
"</" { NEED_TAG_NAME= yes; yy_push_state( IN_TAG, yy_globals); return LTSLASH;}
"<"[^[:alpha:]] { yy_push_state(DISCARD_THRU_GT,yy_globals); }
"<" { NEED_TAG_NAME= yes; yy_push_state( IN_TAG, yy_globals); return LT; }
-[^<]{1,512} { yyget_lval(yy_globals)->str = STRDUP(yytext_r); return TEXT;}
+[^<]{1,512} { yyget_lval(yy_globals)->str = STRDUP(yytext); return TEXT;}
}
<IN_TAG>{
">" { yy_pop_state( yy_globals ); return GT; }
[[:alpha:]][[:alnum:]]* {
if( NEED_TAG_NAME == yes){
NEED_TAG_NAME=no;
- yylval_r->str = STRDUP(yytext_r);
+ yylval->str = STRDUP(yytext);
return TAGNAME;
}
}
/* recurse */
void * scanner;
FILE * fp;
- yytext_r[yyleng_r-1]='\0';
- if((fp=fopen(yytext_r,"r"))==NULL) {
+ yytext[yyleng-1]='\0';
+ if((fp=fopen(yytext,"r"))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",
- yytext_r);
+ yytext);
yyterminate();
}
yylex_init(&scanner);
BEGIN(0);
}
.|\n {
- fprintf(stderr,"Invalid input \"%s\".\n", yytext_r);
+ fprintf(stderr,"Invalid input \"%s\".\n", yytext);
yyterminate();
}
}
-<<EOF>> { fclose(yyin_r); yyterminate();}
+<<EOF>> { fclose(yyin); yyterminate();}
%%
FOO_scan_bytes((yyconst char*)0, 0);
FOO_scan_string((yyconst char*)0);
FOO_switch_to_buffer((YY_BUFFER_STATE)0);
- FOOin = (FILE*)0;
- FOOout = (FILE*)0;
- FOOleng = 0;
- FOOlex();
- FOOrestart((FILE*)0);
- FOOtext = (char*)0;
+ yyin = (FILE*)0;
+ yyout = (FILE*)0;
+ yyleng = 0;
+ yylex();
+ yyrestart((FILE*)0);
+ yytext = (char*)0;
}
}
%%
int
main ( int argc, char** argv )
{
- FOOin = stdin;
- FOOout = stdout;
+ yyin = stdin;
+ yyout = stdout;
FOOlex();
printf("TEST RETURNING OK.\n");
return 0;
#define NUMBER 200
#define WORD 201
-<INITIAL>[[:digit:]]+ { BEGIN(STATE_1); process_text(yytext_r,yy_globals); return NUMBER; }
-<INITIAL>[[:alpha:]]+ { BEGIN(STATE_2); process_text(yytext_r,yy_globals); return WORD; }
+<INITIAL>[[:digit:]]+ { BEGIN(STATE_1); process_text(yytext,yy_globals); return NUMBER; }
+<INITIAL>[[:alpha:]]+ { BEGIN(STATE_2); process_text(yytext,yy_globals); return WORD; }
-<STATE_1>[[:alpha:]]+ { BEGIN(0); process_text(yytext_r,yy_globals); return WORD; }
-<STATE_1>[[:digit:]]+ { BEGIN(0); process_text(yytext_r,yy_globals); return NUMBER; }
+<STATE_1>[[:alpha:]]+ { BEGIN(0); process_text(yytext,yy_globals); return WORD; }
+<STATE_1>[[:digit:]]+ { BEGIN(0); process_text(yytext,yy_globals); return NUMBER; }
-<STATE_2>[[:alpha:]]+ { BEGIN(0); process_text(yytext_r,yy_globals); return WORD; }
-<STATE_2>[[:digit:]]+ { BEGIN(0); process_text(yytext_r,yy_globals); return NUMBER; }
+<STATE_2>[[:alpha:]]+ { BEGIN(0); process_text(yytext,yy_globals); return WORD; }
+<STATE_2>[[:digit:]]+ { BEGIN(0); process_text(yytext,yy_globals); return NUMBER; }
-<INITIAL,STATE_1,STATE_2>" "|\t|\r|\n { process_text(yytext_r,yy_globals); }
+<INITIAL,STATE_1,STATE_2>" "|\t|\r|\n { process_text(yytext,yy_globals); }
<INITIAL,STATE_1,STATE_2>[^[:alnum:][:space:]\t\r\n] {
- /*fprintf(stderr,"*** Error: bad input char '%c'.\n", yytext_r[0]); */
+ /*fprintf(stderr,"*** Error: bad input char '%c'.\n", yytext[0]); */
yyterminate();
}
<INITIAL,STATE_1,STATE_2>[[:space:]\r\n]+ { }
[[:alpha:]]+ { printf("WORD "); fflush(stdout);}
. {
fprintf(stderr,"*** Error: Unrecognized character '%c' while scanning.\n",
- yytext_r[0]);
+ yytext[0]);
yyterminate();
}
%%
-.|\r|\n { append_char (yytext_r[0],yy_globals); }
+.|\r|\n { append_char (yytext[0],yy_globals); }
%%