3 * Copyright (c) 1997-1999 Erez Zadok
4 * Copyright (c) 1989 Jan-Simon Pendry
5 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
6 * Copyright (c) 1989 The Regents of the University of California.
9 * This code is derived from software contributed to Berkeley by
10 * Jan-Simon Pendry at Imperial College, London.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgment:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * $Id: conf_tok.l,v 1.2 1999/01/10 21:53:45 ezk Exp $
47 * Lexical analyzer for AMD configuration parser.
52 #endif /* HAVE_CONFIG_H */
54 * Some systems include a definition for the macro ECHO in <sys/ioctl.h>,
55 * and their (bad) version of lex defines it too at the very beginning of
56 * the generated lex.yy.c file (before it can be easily undefined),
57 * resulting in a conflict. So undefine it here before needed.
58 * Luckily, it does not appear that this macro is actually used in the rest
59 * of the generated lex.yy.c file.
66 #include <conf_parse.h>
67 /* and once again undefine this, just in case */
73 * There are some things that need to be defined only if using GNU flex.
74 * These must not be defined if using standard lex
78 # define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
79 # endif /* not ECHO */
81 #endif /* FLEX_SCANNER */
85 * some systems such as DU-4.x have a different GNU flex in /usr/bin
86 * which automatically generates yywrap macros and symbols. So I must
87 * distinguish between them and when yywrap is actually needed.
91 #endif /* not yywrap */
96 # define dprintf(f,s) fprintf(stderr, (f), yylineno, (s))
97 # define amu_return(v)
100 # define amu_return(v) return((v))
101 #endif /* TOK_DEBUG */
103 /* no need to use yyunput() or yywrap() */
105 #define YY_SKIP_YYWRAP
114 NONWSCHAR [^ \t\n\[\]=]
115 NONWSEQCHAR [^ \t\n\[\]]
127 dprintf("%8d: Left bracket \"%s\"\n", yytext);
128 yylval.strtype = strdup((char *)yytext);
129 amu_return(LEFT_BRACKET);
133 dprintf("%8d: Right bracket \"%s\"\n", yytext);
134 yylval.strtype = strdup((char *)yytext);
135 amu_return(RIGHT_BRACKET);
139 dprintf("%8d: Equal \"%s\"\n", yytext);
140 yylval.strtype = strdup((char *)yytext);
145 dprintf("%8d: Whitespace \"%s\"\n", yytext);
148 /* a comment line includes the terminating \n */
150 yytext[strlen((char *)yytext)-1] = '\0';
151 dprintf("%8d: Comment \"%s\"\n", yytext);
154 {NONWSCHAR}{NONWSCHAR}* {
155 dprintf("%8d: Non-WS string \"%s\"\n", yytext);
156 yylval.strtype = strdup((char *)yytext);
157 amu_return(NONWS_STRING);
160 \"{NONQUOTE}{NONQUOTE}*\" {
161 dprintf("%8d: QUOTED-Non-WS-EQ string \"%s\"\n", yytext);
162 /* must strip quotes */
163 yytext[strlen((char *)yytext)-1] = '\0';
164 yylval.strtype = strdup((char *)&yytext[1]);
165 amu_return(QUOTED_NONWSEQ_STRING);
168 {NONWSEQCHAR}{NONWSEQCHAR}* {
169 dprintf("%8d: Non-WS-EQ string \"%s\"\n", yytext);
170 yylval.strtype = strdup((char *)yytext);
171 amu_return(NONWSEQ_STRING);
177 * some systems such as DU-4.x have a different GNU flex in /usr/bin
178 * which automatically generates yywrap macros and symbols. So I must
179 * distinguish between them and when yywrap is actually needed.
186 #endif /* not yywrap */