From bd81647ad32c9efd824808c07b5aaf38189871fb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 8 Aug 2020 08:45:05 -0700 Subject: scanner: use %option never-interactive It looks like Flex has a "never-interactive" option which does what the batch option should be doing: it removes the use of isatty. Historically, it was an %option only with no corresponding command-line option; newer Flex has a --never-interactive command line option also. The batch option actually makes very little difference in the output. If never-interactive is used, then the batch option makes no difference. * parser.l (%option): Add never-interactive option, remove batch. (VER, FLEX_VER, YY_NO_UNISTD_H, isatty, no_isatty): Remove all these macros: under the never-interactive option, there are no isatty calls and no inclusion of . --- parser.l | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/parser.l b/parser.l index 7c8b3842..90d961c1 100644 --- a/parser.l +++ b/parser.l @@ -46,29 +46,6 @@ #include "parser.h" #include "txr.h" -#define VER(MAJ, MIN, SUB) ((MAJ) * 100000 + (MIN) * 1000 + SUB) - -#define FLEX_VER VER(YY_FLEX_MAJOR_VERSION, \ - YY_FLEX_MINOR_VERSION, \ - YY_FLEX_SUBMINOR_VERSION) - -#define YY_NO_UNISTD_H - -/* Defeat flex's calls to isatty, which happens even in batch mode */ - -#undef isatty - -/* - * Until 2.5.36, the Flex skeleton contained "extern int isatty(int)", - * requiring special handling. - */ -#if FLEX_VER <= VER(2, 5, 36) -#define isatty(x) no_isatty -int no_isatty = 0; -#else -#define isatty(x) 0 -#endif - #define YY_INPUT(buf, result, max_size) \ do { \ val self = lit("parser"); \ @@ -251,7 +228,8 @@ static wchar_t *unicode_ident(scanner_t *scn, const char *lex) %} -%option stack noinput reentrant bison-bridge extra-type="parser_t *" batch +%option stack noinput reentrant bison-bridge extra-type="parser_t *" +%option never-interactive TOK [a-zA-Z0-9_]+ SGN [+\-] -- cgit v1.2.3