mirror of
https://github.com/westes/flex.git
synced 2026-01-26 15:39:06 +00:00
Deprecate input(); document yyinput() for the C back end...
...leaving an "input" macro in place for legacy compatibility. input() had already become yyinput() in the C++ back end in order to avoid collision with predefibed C++ inoput. In a multi-language world, this is good policy in general. There's no real reason for C to be different, and excellent reason to pull all possible entry points into the yy namespace.
This commit is contained in:
parent
526be1f459
commit
dad680611b
@ -1409,8 +1409,8 @@ elsewhere, or build your scanner using @code{%array} instead
|
||||
Finally, note that you cannot put back @samp{EOF} to attempt to mark the
|
||||
input stream with an end-of-file.
|
||||
|
||||
@cindex input()
|
||||
@code{input()} reads the next character from the input stream. For
|
||||
@cindex yyinput()
|
||||
@code{yyinput()} reads the next character from the input stream. For
|
||||
example, the following is one way to eat up C comments:
|
||||
|
||||
@cindex comments, discarding
|
||||
@ -1423,13 +1423,13 @@ example, the following is one way to eat up C comments:
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
while ( (c = input()) != '*' &&
|
||||
while ( (c = yyinput()) != '*' &&
|
||||
c != EOF )
|
||||
; /* eat up text of comment */
|
||||
|
||||
if ( c == '*' )
|
||||
{
|
||||
while ( (c = input()) == '*' )
|
||||
while ( (c = yyinput()) == '*' )
|
||||
;
|
||||
if ( c == '/' )
|
||||
break; /* found the end */
|
||||
@ -1445,13 +1445,6 @@ example, the following is one way to eat up C comments:
|
||||
@end verbatim
|
||||
@end example
|
||||
|
||||
@cindex input(), and C++
|
||||
@cindex yyinput()
|
||||
(Note that if the scanner is compiled using @code{C++}, then
|
||||
@code{input()} is instead referred to as @b{yyinput()}, in order to
|
||||
avoid a name clash with the @code{C++} stream by the name of
|
||||
@code{input}.)
|
||||
|
||||
@cindex flushing the internal buffer
|
||||
@cindex YY_FLUSH_BUFFER
|
||||
@code{YY_FLUSH_BUFFER;} flushes the scanner's internal buffer so that
|
||||
@ -4607,7 +4600,8 @@ a per-scanner (single global variable) basis.
|
||||
@code{yylineno} is not part of the POSIX specification.
|
||||
|
||||
@item
|
||||
The @code{input()} routine is not redefinable, though it may be called
|
||||
The @code{input()} routine (which has become @code{yyinput()} in modern
|
||||
Flex) is not redefinable, though it may be called
|
||||
to read characters following whatever has been matched by a rule. If
|
||||
@code{input()} encounters an end-of-file the normal @code{yywrap()}
|
||||
processing is done. A ``real'' end-of-file is returned by
|
||||
@ -5439,7 +5433,7 @@ other characters. Dynamic resizing of the input buffer is slow, as it
|
||||
entails rescanning all the text matched so far by the current (generally
|
||||
huge) token. Due to both buffering of input and read-ahead, you cannot
|
||||
intermix calls to @file{<stdio.h>} routines, such as, @b{getchar()},
|
||||
with @code{flex} rules and expect it to work. Call @code{input()}
|
||||
with @code{flex} rules and expect it to work. Call @code{yyinput()}
|
||||
instead. The total table entries listed by the @samp{-v} flag excludes
|
||||
the number of table entries needed to determine what rule has been
|
||||
matched. The number of entries is equal to the number of DFA states if
|
||||
@ -6235,7 +6229,7 @@ example,
|
||||
@end example
|
||||
|
||||
(You need to be careful to update your bookkeeping if you use @code{yymore(}),
|
||||
@code{yyless()}, @code{unput()}, or @code{input()}.)
|
||||
@code{yyless()}, @code{unput()}, or @code{yyinput()}.)
|
||||
|
||||
@node How do I use my own I/O classes in a C++ scanner?
|
||||
@section How do I use my own I/O classes in a C++ scanner?
|
||||
@ -8806,6 +8800,10 @@ YYSTART: Replaced by yystart()
|
||||
|
||||
@item
|
||||
YY_AT_BOL: Replaced by yy_at_bol()
|
||||
|
||||
@item
|
||||
input(): Replaced by yyinput(). This function was already yyinput()
|
||||
in the C++ back end.
|
||||
@end itemize
|
||||
|
||||
Flex also provides @code{YYSTATE} as an alias for @code{yystart()}
|
||||
|
||||
@ -1424,18 +1424,17 @@ static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG);
|
||||
static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG);
|
||||
#endif
|
||||
|
||||
m4_ifdef([[M4_MODE_NO_INPUT]], [[#define YY_NO_INPUT 1]])
|
||||
m4_ifdef([[M4_MODE_NO_YYINPUT]], [[#define YY_NO_YYINPUT 1]])
|
||||
|
||||
#ifndef YY_NO_INPUT
|
||||
%if-c-only Standard (non-C++) definition
|
||||
#ifndef YY_NO_YYINPUT
|
||||
//%if-c-only Standard (non-C++) definition
|
||||
%not-for-header
|
||||
#ifdef __cplusplus
|
||||
static int yyinput ( M4_YY_PROTO_ONLY_ARG );
|
||||
#else
|
||||
static int input ( M4_YY_PROTO_ONLY_ARG );
|
||||
#ifndef __cplusplus
|
||||
#define input yyinput
|
||||
#endif
|
||||
%ok-for-header
|
||||
%endif
|
||||
//%endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -2720,13 +2719,8 @@ m4_ifdef( [[M4_MODE_YYLINENO]],
|
||||
#endif
|
||||
|
||||
%if-c-only
|
||||
#ifndef YY_NO_INPUT
|
||||
#ifdef __cplusplus
|
||||
static int yyinput (M4_YY_DEF_ONLY_ARG)
|
||||
#else
|
||||
static int input (M4_YY_DEF_ONLY_ARG)
|
||||
#endif
|
||||
|
||||
#ifndef YY_NO_YYINPUT
|
||||
int yyinput (M4_YY_DEF_ONLY_ARG)
|
||||
%endif
|
||||
%if-c++-only
|
||||
int yyFlexLexer::yyinput()
|
||||
@ -2774,11 +2768,7 @@ int yyFlexLexer::yyinput()
|
||||
if ( ! YY_G(yy_did_buffer_switch_on_eof) ) {
|
||||
YY_NEW_FILE;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
return yyinput(M4_YY_CALL_ONLY_ARG);
|
||||
#else
|
||||
return input(M4_YY_CALL_ONLY_ARG);
|
||||
#endif
|
||||
|
||||
case EOB_ACT_CONTINUE_SCAN:
|
||||
YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset;
|
||||
@ -2810,7 +2800,7 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[
|
||||
return c;
|
||||
}
|
||||
%if-c-only
|
||||
#endif /* ifndef YY_NO_INPUT */
|
||||
#endif /* ifndef YY_NO_YYINPUT */
|
||||
%endif
|
||||
|
||||
/** Immediately switch to a different input stream.
|
||||
|
||||
@ -338,7 +338,7 @@ struct ctrl_bundle_t {
|
||||
bool never_interactive; // always use buffered input, don't check for tty.
|
||||
bool lex_compat; // (-l), maximize compatibility with AT&T lex
|
||||
bool long_align; // (-Ca flag), favor long-word alignment for speed
|
||||
bool no_input; // Suppress use of imnput()
|
||||
bool no_yyinput; // suppress use of yyinput()
|
||||
bool no_unistd; // suppress inclusion of unistd.h
|
||||
bool posix_compat; // (-X) maximize compatibility with POSIX lex
|
||||
char *prefix; // prefix for externally visible names, default "yy"
|
||||
|
||||
@ -1585,8 +1585,8 @@ void readin (void)
|
||||
if (ctrl.prefix != NULL)
|
||||
visible_define_str ( "M4_MODE_PREFIX", ctrl.prefix);
|
||||
|
||||
if (ctrl.no_input)
|
||||
visible_define("M4_MODE_NO_INPUT");
|
||||
if (ctrl.no_yyinput)
|
||||
visible_define("M4_MODE_NO_YYINPUT");
|
||||
|
||||
if (ctrl.no_yy_push_state)
|
||||
visible_define("M4_YY_NO_PUSH_STATE");
|
||||
@ -1789,4 +1789,3 @@ void usage (void)
|
||||
backing_name, "flex", outfile_path, "flex");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -384,7 +384,8 @@ M4QEND "]""]"
|
||||
ctrl.useecs = ctrl.usemecs = false;
|
||||
ctrl.use_read = ctrl.fulltbl = true;
|
||||
}
|
||||
input ctrl.no_input = ! option_sense;
|
||||
input ctrl.no_yyinput = ! option_sense;
|
||||
yyinput ctrl.no_yyinput = ! option_sense;
|
||||
interactive ctrl.interactive = (trit)option_sense;
|
||||
lex-compat ctrl.posix_compat = option_sense;
|
||||
posix-compat ctrl.posix_compat = option_sense;
|
||||
@ -659,7 +660,7 @@ M4QEND "]""]"
|
||||
*/
|
||||
&& (cclval = ccllookup( nmstr )) != 0 )
|
||||
{
|
||||
if ( input() != ']' )
|
||||
if ( yyinput() != ']' )
|
||||
synerr( _( "bad character class" ) );
|
||||
|
||||
yylval = cclval;
|
||||
|
||||
@ -48,7 +48,7 @@ static void append_char (char c, yyscan_t scanner );
|
||||
%}
|
||||
|
||||
%option 8bit prefix="test"
|
||||
%option nounput nomain noyywrap nodefault noinput
|
||||
%option nounput nomain noyywrap nodefault noyyinput
|
||||
%option warn
|
||||
%option reentrant
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user