summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2020-10-09 08:19:51 -0400
committerEric S. Raymond <esr@thyrsus.com>2020-10-09 08:29:55 -0400
commit62a13a3a3d45be1c053566fee502302368d4e579 (patch)
tree68f98085a0f88b02f7c2f3a9c859e12417e4b7c0 /src
parent1e9c36271ea388cd155f2b7808c71113301e1631 (diff)
downloadflex-git-62a13a3a3d45be1c053566fee502302368d4e579.tar.gz
First step towards an interface independent of C macros.
This patch implements and documents a yyreject() macro to replace argumentless REJECT. It does not remove REJECT, but warns that this macro will not be supported in non-C languages and deprecates it. This commit begins a new appendix in the Flex manual, to list deprecated interfaces and explain why they have been superseded.
Diffstat (limited to 'src')
-rw-r--r--src/cpp-flex.skl10
-rw-r--r--src/scan.l8
2 files changed, 14 insertions, 4 deletions
diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl
index 31d84ca..8f48783 100644
--- a/src/cpp-flex.skl
+++ b/src/cpp-flex.skl
@@ -1039,7 +1039,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
m4_ifdef( [[M4_MODE_C_ONLY]], [[
m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[
m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[
-/* Definitions for backing up. We don't need them if REJECT
+/* Definitions for backing up. We don't need them if yyreject()
* is being used because then we use an alternative backing-up
* technique instead.
*/
@@ -1068,7 +1068,7 @@ static int *yy_full_state;
]])
]])
]])
-#define REJECT \
+#define yyreject() \
{ \
*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \
yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \
@@ -1080,11 +1080,13 @@ yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \
++YY_G(yy_lp); \
goto find_rule; \
}
+#define REJECT yyreject()
]])
m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[
/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
+ * any uses of yyreject() which flex missed.
*/
+#define yyreject() reject_used_but_not_detected
#define REJECT reject_used_but_not_detected
]])
@@ -2404,7 +2406,7 @@ int yyFlexLexer::yy_get_next_buffer()
m4_ifdef( [[M4_MODE_USES_REJECT]],
[[
YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+"input buffer overflow, can't enlarge buffer because scanner uses yyreject()" );
]],
[[
/* just a shorter name for the current buffer */
diff --git a/src/scan.l b/src/scan.l
index 82d57df..6f26e68 100644
--- a/src/scan.l
+++ b/src/scan.l
@@ -84,6 +84,10 @@ extern const char *escaped_qstart, *escaped_qend;
if ( all_upper( str ) ) \
reject = true;
+#define CHECK_YYREJECT(str) \
+ if ( all_lower( str ) ) \
+ reject = true;
+
#define CHECK_YYMORE(str) \
if ( all_lower( str ) ) \
yymore_used = true;
@@ -905,6 +909,10 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
ACTION_ECHO;
CHECK_REJECT(yytext);
}
+ "yyreject()" {
+ ACTION_ECHO;
+ CHECK_YYREJECT(yytext);
+ }
"yymore" {
ACTION_ECHO;
CHECK_YYMORE(yytext);