diff --git a/doc/flex.texi b/doc/flex.texi index cee94f2d..337de104 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -644,8 +644,8 @@ All the comments in the following example are valid: ruleA /* after regex */ { /* code block */ } /* after code block */ /* Rules Section (indented) */ { -ruleC ECHO; -ruleD ECHO; +ruleC yyecho(); +ruleD yyecho(); %{ /* code block */ %} @@ -1227,8 +1227,8 @@ There are a number of special directives which can be included within an action: @table @code -@item ECHO -@cindex ECHO +@item yyecho() +@cindex yyecho() copies yytext to the scanner's output. @item yybegin() @@ -1272,7 +1272,7 @@ write @samp{abcdabcaba} to the output: a | ab | abc | - abcd ECHO; yyreject(); + abcd yyecho(); yyreject(); .|\n /* eat up any unmatched character */ @end verbatim @end example @@ -1303,8 +1303,8 @@ the output: @example @verbatim %% - mega- ECHO; yymore(); - kludge ECHO; + mega- yyecho(); yymore(); + kludge yyecho(); @end verbatim @end example @@ -1313,7 +1313,7 @@ is matched, but the previous @samp{mega-} is still hanging around at the beginning of @code{yytext} so the -@code{ECHO} +@code{yyecho()} for the @samp{kludge} rule will actually write @samp{mega-kludge}. @end table @@ -1338,8 +1338,8 @@ following will write out @samp{foobarbar}: @example @verbatim %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; + foobar yyecho(); yyless(3); + [a-z]+ yyecho(); @end verbatim @end example @@ -1584,10 +1584,10 @@ obtain the default version of the routine, which always returns 1. For scanning from in-memory buffers (e.g., scanning strings), see @ref{Scanning Strings}. @xref{Multiple Input Buffers}. -@cindex ECHO, and yyout +@cindex yyecho(), and yyout @cindex yyout @cindex stdout, as default for yyout -The scanner writes its @code{ECHO} output to the @file{yyout} global +The scanner writes its @code{yyecho()} output to the @file{yyout} global (default, @file{stdout}), which may be redefined by the user simply by assigning it to some other @code{FILE} pointer. @@ -1697,13 +1697,13 @@ have been written: @end verbatim @end example -The default rule (to @code{ECHO} any unmatched character) remains active +The default rule (to @code{yyecho()} any unmatched character) remains active in start conditions. It is equivalent to: @cindex start conditions, behavior of default rule @example @verbatim - <*>.|\n ECHO; + <*>.|\n yyecho(); @end verbatim @end example @@ -2118,8 +2118,8 @@ maintains the stack internally. %% include yybegin(incl); - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; + [a-z]+ yyecho(); + [^a-z\n]*\n? yyecho(); [ \t]* /* eat the whitespace */ [^ \t\n]+ { /* got the include file name */ @@ -2164,8 +2164,8 @@ manages its own input buffer stack manually (instead of letting flex do it). %% include yybegin(incl); - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; + [a-z]+ yyecho(); + [^a-z\n]*\n? yyecho(); [ \t]* /* eat the whitespace */ [^ \t\n]+ { /* got the include file name */ @@ -2439,7 +2439,7 @@ scanning the same input file. @vindex yyout @item FILE *yyout -is the file to which @code{ECHO} actions are done. It can be reassigned +is the file to which @code{yyecho()} actions are done. It can be reassigned by the user. @vindex YY_CURRENT_BUFFER @@ -4176,7 +4176,7 @@ always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, see @ref{Reentrant Functions}. Note that preprocessor macros, such as -@code{yyebegin()}, @code{ECHO}, and @code{yyreject()}, do not take this +@code{yyebegin()}, @code{yyecho()}, and @code{yyreject()}, do not take this additional argument. @node Global Replacement, Init and Destroy Functions, Extra Reentrant Argument, Reentrant Detail @@ -4598,7 +4598,7 @@ reentrant, so if using C++ is an option for you, you should use them instead. @xref{Cxx}, and @ref{Reentrant} for details. @item -@code{output()} is not supported. Output from the @b{ECHO} macro is +@code{output()} is not supported. Output from the @b{yyecho()} macro is done to the file-pointer @code{yyout} (default @file{stdout)}. @item @@ -6308,7 +6308,7 @@ this case '[Ff]oot' is preferred to '(F|f)oot'. > {and}{bb}/{ROMAN}[^A-Za-z] { yybegin... > > to the next 2 rules: -> {and}{bb}/{ROMAN}[A-Za-z] { ECHO;} +> {and}{bb}/{ROMAN}[A-Za-z] { yyecho();} > {and}{bb}/{ROMAN} { yybegin... > > Again, I understand the using [^...] will cause a great performance loss @@ -8724,13 +8724,16 @@ calls need to be functions, at least syntactically (though many are still implemented as macros for C/C++). A list of deprecated interfaces and their replacements follows. -Again, all are still available in the default C back end, but not +Again, all are still available in the default C/C++ back end, but not in any other. @itemize @item BEGIN: Replaced by yybegin() +@item +ECHO: Replaced by yyecho() + @item REJECT: Replaced by yyreject() @end itemize diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 5cd089f0..1eced3dd 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1481,17 +1481,19 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO +#ifndef yyecho %if-c-only Standard (non-C++) definition /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#define yyecho() do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) %endif %if-c++-only C++ definition -#define ECHO LexerOutput( yytext, yyleng ) +#define yyecho() LexerOutput( yytext, yyleng ) %endif #endif +/* Legacy interface */ +#define ECHO yyecho() ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], diff --git a/tests/include_by_buffer.direct.l b/tests/include_by_buffer.direct.l index 3b5df8af..684d34bd 100644 --- a/tests/include_by_buffer.direct.l +++ b/tests/include_by_buffer.direct.l @@ -48,7 +48,7 @@ int include_stack_ptr = 0; { ^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } -.|\n { ECHO; } +.|\n { yyecho(); } } { diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l index b7661f67..5f5fbf3d 100644 --- a/tests/include_by_push.direct.l +++ b/tests/include_by_push.direct.l @@ -43,7 +43,7 @@ int error = 0; { ^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } -.|\n { ECHO; } +.|\n { yyecho(); } } { diff --git a/tests/include_by_reentrant.direct.l b/tests/include_by_reentrant.direct.l index a5936526..544dd2f7 100644 --- a/tests/include_by_reentrant.direct.l +++ b/tests/include_by_reentrant.direct.l @@ -44,7 +44,7 @@ int error = 0; { ^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } -.|\n { ECHO; } +.|\n { yyecho(); } } { diff --git a/tests/quote_in_comment.l b/tests/quote_in_comment.l index a5743c2c..cb17e2f6 100644 --- a/tests/quote_in_comment.l +++ b/tests/quote_in_comment.l @@ -1,6 +1,6 @@ %option 8bit noyywrap %% -.|\n { ECHO; +.|\n { yyecho(); //' " } %%