2 /* $XConsortium: lex.l,v 5.9 95/01/05 19:18:40 kaleb Exp $ */
3 /* $XFree86: xc/fonts/PEX/lex.l,v 3.9 1996/10/17 15:10:45 dawes Exp $ */
5 /*****************************************************************
7 Copyright (c) 1989,1990, 1991 X Consortium
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 Except as contained in this notice, the name of the X Consortium shall not be
27 used in advertising or otherwise to promote the sale, use or other dealings
28 in this Software without prior written authorization from the X Consortium.
30 Copyright (c) 1989,1990, 1991 by Sun Microsystems, Inc.
34 Permission to use, copy, modify, and distribute this software and its
35 documentation for any purpose and without fee is hereby granted,
36 provided that the above copyright notice appear in all copies and that
37 both that copyright notice and this permission notice appear in
38 supporting documentation, and that the names of Sun Microsystems,
39 and the X Consortium, not be used in advertising or publicity
40 pertaining to distribution of the software without specific, written
43 SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
44 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
45 SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
46 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
47 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
48 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
51 ******************************************************************/
57 int string(char *, int), res_words(char *);
62 \"[^"]*\" return string(yytext, yyleng);
64 [ ,;\t\n\r]* /* natural dilimters */ ;
66 [a-zA-Z][a-zA-Z0-9_.]* {
68 if ( (token = res_words(yytext)) )
70 return string(yytext, yyleng);
73 [+-]?[0-9]+\.?[0-9]*[eE][+-]?[0-9]+ |
76 yylval.dval = atof((char *)yytext);
83 yylval.ival = atoi((char *)yytext);
89 int res_words(char *str)
91 static struct res_strct {
97 {"PROPERTIES", PROPERTIES},
99 {"FONTNAME", FONTNAME},
106 {"VERTICES", VERTICES},
107 {"BEARING", BEARING},
108 {"L_SPACE", L_SPACE},
110 {"R_SPACE", R_SPACE},
116 register struct res_strct *reserved;
118 reserved = res_table;
121 if (!strcmp(str, reserved->word))
123 while ((++reserved)->word != 0);
124 return reserved->token;
128 int string(char *str, int n)
130 if (*str == '\"' || *str == '\'')
133 n -= 2; /* one for EOL, one for end quote */
135 if ((yylval.cval = (char *)malloc(n + 1)) != NULL)
137 strncpy(yylval.cval, str, n);
138 yylval.cval[n] = '\0';