3 * Copyright (c) 1997-2006 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
41 * File: am-utils/amd/conf_tok.l
46 * Lexical analyzer for AMD configuration parser.
51 #endif /* HAVE_CONFIG_H */
53 * Some systems include a definition for the macro ECHO in <sys/ioctl.h>,
54 * and their (bad) version of lex defines it too at the very beginning of
55 * the generated lex.yy.c file (before it can be easily undefined),
56 * resulting in a conflict. So undefine it here before needed.
57 * Luckily, it does not appear that this macro is actually used in the rest
58 * of the generated lex.yy.c file.
65 #include <conf_parse.h>
66 /* and once again undefine this, just in case */
72 * There are some things that need to be defined only if using GNU flex.
73 * These must not be defined if using standard lex
77 # define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
78 # endif /* not ECHO */
79 #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), ayylineno, (s))
97 # define amu_return(v)
98 #else /* not TOK_DEBUG */
100 # define amu_return(v) return((v))
101 #endif /* not TOK_DEBUG */
103 /* no need to use yywrap() */
104 #define YY_SKIP_YYWRAP
108 /* This option causes Solaris lex to fail. Use flex. See BUGS file */
109 /* no need to use yyunput() */
112 /* allocate more output slots so lex scanners don't run out of mem */
120 NONWSCHAR [^ \t\n\[\]=]
121 NONWSEQCHAR [^ \t\n\[\]]
133 dprintf("%8d: Left bracket \"%s\"\n", yytext);
134 yylval.strtype = strdup((char *)yytext);
135 amu_return(LEFT_BRACKET);
139 dprintf("%8d: Right bracket \"%s\"\n", yytext);
140 yylval.strtype = strdup((char *)yytext);
141 amu_return(RIGHT_BRACKET);
145 dprintf("%8d: Equal \"%s\"\n", yytext);
146 yylval.strtype = strdup((char *)yytext);
151 dprintf("%8d: Whitespace \"%s\"\n", yytext);
154 /* a comment line includes the terminating \n */
156 yytext[strlen((char *)yytext)-1] = '\0';
157 dprintf("%8d: Comment \"%s\"\n", yytext);
160 {NONWSCHAR}{NONWSCHAR}* {
161 dprintf("%8d: Non-WS string \"%s\"\n", yytext);
162 yylval.strtype = strdup((char *)yytext);
163 amu_return(NONWS_STRING);
166 \"{NONQUOTE}{NONQUOTE}*\" {
167 dprintf("%8d: QUOTED-Non-WS-EQ string \"%s\"\n", yytext);
168 /* must strip quotes */
169 yytext[strlen((char *)yytext)-1] = '\0';
170 yylval.strtype = strdup((char *)&yytext[1]);
171 amu_return(QUOTED_NONWSEQ_STRING);
174 {NONWSEQCHAR}{NONWSEQCHAR}* {
175 dprintf("%8d: Non-WS-EQ string \"%s\"\n", yytext);
176 yylval.strtype = strdup((char *)yytext);
177 amu_return(NONWSEQ_STRING);
183 * some systems such as DU-4.x have a different GNU flex in /usr/bin
184 * which automatically generates yywrap macros and symbols. So I must
185 * distinguish between them and when yywrap is actually needed.
192 #endif /* not yywrap */