Am-Utils Cross Reference
am-utils/amd/conf_tok.l

source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Version: 6.0.1 ] [ 6.0.2 ] [ 6.0.3 ] [ 6.0.4 ] [ 6.0.5 ] [ 6.0.6 ] [ 6.0.7 ] [ 6.0.8 ] [ 6.0.9 ] [ 6.0.10 ] [ 6.1 ] [ 6.1.1 ]

  1 %{
  2 /*
  3  * Copyright (c) 1997-2005 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.
  7  * All rights reserved.
  8  *
  9  * This code is derived from software contributed to Berkeley by
 10  * Jan-Simon Pendry at Imperial College, London.
 11  *
 12  * Redistribution and use in source and binary forms, with or without
 13  * modification, are permitted provided that the following conditions
 14  * are met:
 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.
 27  *
 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
 38  * SUCH DAMAGE.
 39  *
 40  *
 41  * File: am-utils/amd/conf_tok.l
 42  *
 43  */
 44 
 45 /*
 46  * Lexical analyzer for AMD configuration parser.
 47  */
 48 
 49 #ifdef HAVE_CONFIG_H
 50 # include <config.h>
 51 #endif /* HAVE_CONFIG_H */
 52 /*
 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.
 59  */
 60 #ifdef ECHO
 61 # undef ECHO
 62 #endif /* ECHO */
 63 #include <am_defs.h>
 64 #include <amd.h>
 65 #include <conf_parse.h>
 66 /* and once again undefine this, just in case */
 67 #ifdef ECHO
 68 # undef ECHO
 69 #endif /* ECHO */
 70 
 71 /*
 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
 74  */
 75 #ifdef FLEX_SCANNER
 76 # ifndef ECHO
 77 #  define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
 78 # endif /* not ECHO */
 79 #endif /* FLEX_SCANNER */
 80 
 81 int ayylineno = 0;
 82 
 83 int yylex(void);
 84 /*
 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.
 88  */
 89 #ifndef yywrap
 90 int yywrap(void);
 91 #endif /* not yywrap */
 92 
 93 #define TOK_DEBUG 0
 94 
 95 #if TOK_DEBUG
 96 # define dprintf(f,s) fprintf(stderr, (f), ayylineno, (s))
 97 # define amu_return(v)
 98 #else /* not TOK_DEBUG */
 99 # define dprintf(f,s)
100 # define amu_return(v) return((v))
101 #endif /* not TOK_DEBUG */
102 
103 /* no need to use yywrap() */
104 #define YY_SKIP_YYWRAP
105 
106 %}
107 
108 /* This option causes Solaris lex to fail.  Use flex.  See BUGS file */
109 /* no need to use yyunput() */
110 %option nounput
111 
112 /* allocate more output slots so lex scanners don't run out of mem */
113 %o 1024
114 
115 DIGIT           [0-9]
116 ALPHA           [A-Za-z]
117 ALPHANUM        [A-Za-z0-9]
118 SYMBOL          [A-Za-z0-9_-]
119 PATH            [A-Za-z0-9_-/]
120 NONWSCHAR       [^ \t\n\[\]=]
121 NONWSEQCHAR     [^ \t\n\[\]]
122 NONNL           [^\n]
123 NONQUOTE        [^\"]
124 
125 %%
126 
127 \n                      {
128                         ayylineno++;
129                         amu_return(NEWLINE);
130                         }
131 
132 \[                      {
133                         dprintf("%8d: Left bracket \"%s\"\n", yytext);
134                         yylval.strtype = strdup((char *)yytext);
135                         amu_return(LEFT_BRACKET);
136                         }
137 
138 \]                      {
139                         dprintf("%8d: Right bracket \"%s\"\n", yytext);
140                         yylval.strtype = strdup((char *)yytext);
141                         amu_return(RIGHT_BRACKET);
142                         }
143 
144 =                       {
145                         dprintf("%8d: Equal \"%s\"\n", yytext);
146                         yylval.strtype = strdup((char *)yytext);
147                         amu_return(EQUAL);
148                         }
149 
150 [ \t]*                  {
151                         dprintf("%8d: Whitespace \"%s\"\n", yytext);
152                         }
153 "#"[^\n]*\n             {
154                         /* a comment line includes the terminating \n */
155                         ayylineno++;
156                         yytext[strlen((char *)yytext)-1] = '\0';
157                         dprintf("%8d: Comment \"%s\"\n", yytext);
158                         }
159 
160 {NONWSCHAR}{NONWSCHAR}* {
161                         dprintf("%8d: Non-WS string \"%s\"\n", yytext);
162                         yylval.strtype = strdup((char *)yytext);
163                         amu_return(NONWS_STRING);
164                         }
165 
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);
172                         }
173 
174 {NONWSEQCHAR}{NONWSEQCHAR}*     {
175                         dprintf("%8d: Non-WS-EQ string \"%s\"\n", yytext);
176                         yylval.strtype = strdup((char *)yytext);
177                         amu_return(NONWSEQ_STRING);
178                         }
179 
180 %%
181 
182 /*
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.
186  */
187 #ifndef yywrap
188 int yywrap(void)
189 {
190   return 1;
191 }
192 #endif /* not yywrap */

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
This page is hosted at the Filesystems and Storage Lab at Stony Brook.