Date: Wed, 8 Aug 2012 14:59:51 -0600 From: Dan McGregor <danismostlikely@gmail.com> To: freebsd-hackers@freebsd.org Subject: Consistent use of lex flags Message-ID: <CACS%2B7ZSu5FuBfXDvJXXYX%2B_ugmYGDfvut9PrdmRX4zkxLmxnvg@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi.
I was just noticing that mkcsmapper doesn't build with clang. I saw two
ways to do this, the first being to #define YY_NO_INPUT, and the other to
use the %option noinput lex flag.
While there, I decided to explore and I changed a bunch of #defines to the
standard lex way of doing things. I thought it would be good if all the
code that originated in FreeBSD could be consistent.
Thoughts?
[-- Attachment #2 --]
Index: usr.bin/csup/token.l
===================================================================
--- usr.bin/csup/token.l (revision 239141)
+++ usr.bin/csup/token.l (working copy)
@@ -35,13 +35,12 @@
#include "misc.h"
#include "token.h"
-#define YY_NO_UNPUT
-
int lineno = 1;
%}
%option noyywrap
+%option nounput
%%
Index: usr.bin/colldef/Makefile
===================================================================
--- usr.bin/colldef/Makefile (revision 239141)
+++ usr.bin/colldef/Makefile (working copy)
@@ -4,7 +4,7 @@
SRCS= parse.y scan.l y.tab.h
LFLAGS= -8 -i
CFLAGS+=-I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/locale
-CFLAGS+=-DCOLLATE_DEBUG -DYY_NO_UNPUT -DYY_NO_INPUT
+CFLAGS+=-DCOLLATE_DEBUG
LDADD= -ll
DPADD= ${LIBL}
Index: usr.bin/colldef/scan.l
===================================================================
--- usr.bin/colldef/scan.l (revision 239141)
+++ usr.bin/colldef/scan.l (working copy)
@@ -49,6 +49,8 @@
#endif /* FLEX_DEBUG */
int yylex(void);
%}
+%option noinput
+%option nounput
%%
<INITIAL,charmap,nchar,subs,subs2>[ \t]+ ;
<subs2>\" { ptr = buf; BEGIN(string); }
Index: usr.bin/xlint/lint1/scan.l
===================================================================
--- usr.bin/xlint/lint1/scan.l (revision 239141)
+++ usr.bin/xlint/lint1/scan.l (working copy)
@@ -52,7 +52,6 @@
#include "cgram.h"
#define CHAR_MASK (~(~0 << CHAR_BIT))
-#define YY_NO_UNPUT
/* Current position (its also updated when an included file is parsed) */
pos_t curr_pos = { 1, "", 0 };
@@ -86,6 +85,8 @@
%}
+%option nounput
+
L [_A-Za-z]
D [0-9]
NZD [1-9]
Index: usr.bin/ar/acplex.l
===================================================================
--- usr.bin/ar/acplex.l (revision 239141)
+++ usr.bin/ar/acplex.l (working copy)
@@ -36,8 +36,6 @@
#include "y.tab.h"
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
int lineno = 1;
int yylex(void);
@@ -45,6 +43,8 @@
%}
%option noyywrap
+%option noinput
+%option nounput
%%
Index: usr.bin/bc/scan.l
===================================================================
--- usr.bin/bc/scan.l (revision 239141)
+++ usr.bin/bc/scan.l (working copy)
@@ -46,13 +46,13 @@
static void add_str(const char *);
static int bc_yyinput(char *, int);
-#define YY_NO_INPUT
#undef YY_INPUT
#define YY_INPUT(buf,retval,max) \
(retval = bc_yyinput(buf, max))
%}
%option always-interactive
+%option noinput
DIGIT [0-9A-F]
ALPHA [a-z_]
Index: usr.bin/mkcsmapper/lex.l
===================================================================
--- usr.bin/mkcsmapper/lex.l (revision 239141)
+++ usr.bin/mkcsmapper/lex.l (working copy)
@@ -43,6 +43,7 @@
int line_number = 1;
%}
+%option noinput
%option nounput
%x COMMENT
Index: usr.sbin/rrenumd/lexer.l
===================================================================
--- usr.sbin/rrenumd/lexer.l (revision 239141)
+++ usr.sbin/rrenumd/lexer.l (working copy)
@@ -32,8 +32,6 @@
*/
%{
-#define YY_NO_UNPUT
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -64,6 +62,8 @@
int yylex(void);
%}
+%option nounput
+
/* common section */
nl \n
ws [ \t]+
Index: usr.sbin/kbdcontrol/lex.l
===================================================================
--- usr.sbin/kbdcontrol/lex.l (revision 239141)
+++ usr.sbin/kbdcontrol/lex.l (working copy)
@@ -31,11 +31,12 @@
%{
#include "lex.h"
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
%}
+%option noinput
+%option nounput
+
D [0-9]
X [0-9a-fA-F]
A .
Index: usr.sbin/jail/jaillex.l
===================================================================
--- usr.sbin/jail/jaillex.l (revision 239141)
+++ usr.sbin/jail/jaillex.l (working copy)
@@ -36,9 +36,6 @@
#include "jailp.h"
#include "y.tab.h"
-#define YY_NO_INPUT
-#define YY_NO_UNPUT
-
extern int yynerrs;
static ssize_t text2lval(size_t triml, size_t trimr, int tovar);
@@ -47,6 +44,9 @@
static int lineno = 1;
%}
+%option noinput
+%option nounput
+
%start _ DQ
%%
Index: usr.sbin/ndiscvt/inf-token.l
===================================================================
--- usr.sbin/ndiscvt/inf-token.l (revision 239141)
+++ usr.sbin/ndiscvt/inf-token.l (working copy)
@@ -43,8 +43,6 @@
#include "y.tab.h"
int lineno = 1;
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
int yylex(void);
void yyerror(const char *);
@@ -59,6 +57,9 @@
%}
+%option noinput
+%option nounput
+
%%
[ \t]+ ;
Index: usr.sbin/apmd/apmdlex.l
===================================================================
--- usr.sbin/apmd/apmdlex.l (revision 239141)
+++ usr.sbin/apmd/apmdlex.l (working copy)
@@ -36,14 +36,13 @@
#include "apmd.h"
#include "y.tab.h"
-/* We don't need it, avoid the warning. */
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
-
int lineno;
int first_time;
%}
+%option noinput
+%option nounput
+
%s TOP
%%
Index: usr.sbin/config/lang.l
===================================================================
--- usr.sbin/config/lang.l (revision 239141)
+++ usr.sbin/config/lang.l (working copy)
@@ -38,9 +38,6 @@
#include "y.tab.h"
#include "config.h"
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
-
/*
* Data for returning to previous files from include files.
*/
@@ -97,6 +94,10 @@
int yyerror(const char *);
%}
+
+%option noinput
+%option nounput
+
ID [A-Za-z_][-A-Za-z_0-9]*
PATH [./][-/.%^A-Za-z_0-9]+
%START TOEOL
Index: lib/libc/net/nslexer.l
===================================================================
--- lib/libc/net/nslexer.l (revision 239141)
+++ lib/libc/net/nslexer.l (working copy)
@@ -53,12 +53,11 @@
#include "nsparser.h"
-#define YY_NO_INPUT
-#define YY_NO_UNPUT
-
%}
%option yylineno
+%option noinput
+%option nounput
BLANK [ \t]
CR \n
Index: sbin/devd/token.l
===================================================================
--- sbin/devd/token.l (revision 239141)
+++ sbin/devd/token.l (working copy)
@@ -37,8 +37,6 @@
#include "y.tab.h"
int lineno = 1;
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
static void
update_lineno(const char *cp)
@@ -50,6 +48,9 @@
%}
+%option noinput
+%option nounput
+
%%
[ \t]+ ;
Index: sbin/hastctl/Makefile
===================================================================
--- sbin/hastctl/Makefile (revision 239141)
+++ sbin/hastctl/Makefile (working copy)
@@ -27,9 +27,6 @@
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+=-DINET6
.endif
-# This is needed to have WARNS > 1.
-CFLAGS+=-DYY_NO_UNPUT
-CFLAGS+=-DYY_NO_INPUT
DPADD= ${LIBL} ${LIBUTIL}
LDADD= -ll -lutil
Index: sbin/setkey/token.l
===================================================================
--- sbin/setkey/token.l (revision 239141)
+++ sbin/setkey/token.l (working copy)
@@ -65,6 +65,8 @@
int yyparse(void);
%}
+%option nounput
+
/* common section */
nl \n
ws [ \t]+
Index: sbin/setkey/Makefile
===================================================================
--- sbin/setkey/Makefile (revision 239141)
+++ sbin/setkey/Makefile (working copy)
@@ -50,7 +50,7 @@
SRCS+= y.tab.h
y.tab.h: parse.y
-CFLAGS+= -DIPSEC_DEBUG -DYY_NO_UNPUT
+CFLAGS+= -DIPSEC_DEBUG
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+= -DINET6
.endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACS%2B7ZSu5FuBfXDvJXXYX%2B_ugmYGDfvut9PrdmRX4zkxLmxnvg>
