summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2020-10-09 23:28:42 -0400
committerEric S. Raymond <esr@thyrsus.com>2020-10-09 23:28:42 -0400
commit76affdf8942bf5627a815edcb486f9dcc3067ae6 (patch)
tree256dbb1a0ee071a291cede5f9796a8a62f77335e
parent3612bc281e0ee68a8b9b5c609c42ced02366a82e (diff)
downloadflex-git-76affdf8942bf5627a815edcb486f9dcc3067ae6.tar.gz
Deprecate ECHO in favor of yyecho().
I changed the tests to use yyecho(), but the ECHO macro is still exercised in the bootstrap scanner.
-rw-r--r--doc/flex.texi49
-rw-r--r--src/cpp-flex.skl8
-rw-r--r--tests/include_by_buffer.direct.l2
-rw-r--r--tests/include_by_push.direct.l2
-rw-r--r--tests/include_by_reentrant.direct.l2
-rw-r--r--tests/quote_in_comment.l2
6 files changed, 35 insertions, 30 deletions
diff --git a/doc/flex.texi b/doc/flex.texi
index cee94f2..337de10 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) */
<STATE_X>{
-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();
<incl>[ \t]* /* eat the whitespace */
<incl>[^ \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();
<incl>[ \t]* /* eat the whitespace */
<incl>[^ \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'.
> <snext8>{and}{bb}/{ROMAN}[^A-Za-z] { yybegin...
>
> to the next 2 rules:
-> <snext8>{and}{bb}/{ROMAN}[A-Za-z] { ECHO;}
+> <snext8>{and}{bb}/{ROMAN}[A-Za-z] { yyecho();}
> <snext8>{and}{bb}/{ROMAN} { yybegin...
>
> Again, I understand the using [^...] will cause a great performance loss
@@ -8724,7 +8724,7 @@ 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
@@ -8732,6 +8732,9 @@ in any other.
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 5cd089f..1eced3d 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 3b5df8a..684d34b 100644
--- a/tests/include_by_buffer.direct.l
+++ b/tests/include_by_buffer.direct.l
@@ -48,7 +48,7 @@ int include_stack_ptr = 0;
<INITIAL>{
^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); }
-.|\n { ECHO; }
+.|\n { yyecho(); }
}
<GET_FILENAME>{
diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l
index b7661f6..5f5fbf3 100644
--- a/tests/include_by_push.direct.l
+++ b/tests/include_by_push.direct.l
@@ -43,7 +43,7 @@ int error = 0;
<INITIAL>{
^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); }
-.|\n { ECHO; }
+.|\n { yyecho(); }
}
<GET_FILENAME>{
diff --git a/tests/include_by_reentrant.direct.l b/tests/include_by_reentrant.direct.l
index a593652..544dd2f 100644
--- a/tests/include_by_reentrant.direct.l
+++ b/tests/include_by_reentrant.direct.l
@@ -44,7 +44,7 @@ int error = 0;
<INITIAL>{
^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); }
-.|\n { ECHO; }
+.|\n { yyecho(); }
}
<GET_FILENAME>{
diff --git a/tests/quote_in_comment.l b/tests/quote_in_comment.l
index a5743c2..cb17e2f 100644
--- a/tests/quote_in_comment.l
+++ b/tests/quote_in_comment.l
@@ -1,6 +1,6 @@
%option 8bit noyywrap
%%
-.|\n { ECHO;
+.|\n { yyecho();
//' "
}
%%