lex.l revision 95643
1%{
2/*-
3 * Copyright (c) 1993
4 *	The Regents of the University of California.  All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Paul Borman at Krystal Technologies.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 *    must display the following acknowledgement:
19 *	This product includes software developed by the University of
20 *	California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 *    may be used to endorse or promote products derived from this software
23 *    without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
41#endif
42#endif /* not lint */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/usr.bin/mklocale/lex.l 95643 2002-04-28 12:34:54Z markm $");
46
47#include <ctype.h>
48#include <stdio.h>
49#include <stdlib.h>
50
51#include "ldef.h"
52#include "y.tab.h"
53#include "extern.h"
54%}
55
56ODIGIT	[0-7]
57DIGIT	[0-9]
58XDIGIT	[0-9a-fA-F]
59W	[\t\n\r ]
60
61%%
62\'.\'				{ yylval.rune = (unsigned char)yytext[1];
63				  return(RUNE); }
64
65'\\a'				{ yylval.rune = '\a';
66				  return(RUNE); }
67'\\b'				{ yylval.rune = '\b';
68				  return(RUNE); }
69'\\f'				{ yylval.rune = '\f';
70				  return(RUNE); }
71'\\n'				{ yylval.rune = '\n';
72				  return(RUNE); }
73'\\r'				{ yylval.rune = '\r';
74				  return(RUNE); }
75'\\t'				{ yylval.rune = '\t';
76				  return(RUNE); }
77'\\v'				{ yylval.rune = '\v';
78				  return(RUNE); }
79
800x{XDIGIT}+			{ yylval.rune = strtol(yytext, 0, 16);
81				  return(RUNE); }
820{ODIGIT}+			{ yylval.rune = strtol(yytext, 0, 8);
83				  return(RUNE); }
84{DIGIT}+			{ yylval.rune = strtol(yytext, 0, 10);
85				  return(RUNE); }
86
87
88MAPLOWER			{ return(MAPLOWER); }
89MAPUPPER			{ return(MAPUPPER); }
90TODIGIT				{ return(DIGITMAP); }
91INVALID				{ return(INVALID); }
92
93ALPHA				{ yylval.i = _CTYPE_A|_CTYPE_R|_CTYPE_G;
94				  return(LIST); }
95CONTROL				{ yylval.i = _CTYPE_C;
96				  return(LIST); }
97DIGIT				{ yylval.i = _CTYPE_D|_CTYPE_R|_CTYPE_G;
98				  return(LIST); }
99GRAPH				{ yylval.i = _CTYPE_G|_CTYPE_R;
100				  return(LIST); }
101LOWER				{ yylval.i = _CTYPE_L|_CTYPE_R|_CTYPE_G;
102				  return(LIST); }
103PUNCT				{ yylval.i = _CTYPE_P|_CTYPE_R|_CTYPE_G;
104				  return(LIST); }
105SPACE				{ yylval.i = _CTYPE_S;
106				  return(LIST); }
107UPPER				{ yylval.i = _CTYPE_U|_CTYPE_R|_CTYPE_G;
108				  return(LIST); }
109XDIGIT				{ yylval.i = _CTYPE_X|_CTYPE_R|_CTYPE_G;
110				  return(LIST); }
111BLANK				{ yylval.i = _CTYPE_B;
112				  return(LIST); }
113PRINT				{ yylval.i = _CTYPE_R;
114				  return(LIST); }
115IDEOGRAM			{ yylval.i = _CTYPE_I|_CTYPE_R|_CTYPE_G;
116				  return(LIST); }
117SPECIAL				{ yylval.i = _CTYPE_T|_CTYPE_R|_CTYPE_G;
118				  return(LIST); }
119PHONOGRAM			{ yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G;
120				  return(LIST); }
121
122VARIABLE[\t ]			{ static char vbuf[1024];
123				  char *v = vbuf;
124				  while ((*v = input()) && *v != '\n')
125					++v;
126                                  if (*v) {
127					unput(*v);
128					*v = 0;
129				  }
130				  yylval.str = vbuf;
131				  return(VARIABLE);
132				}
133
134ENCODING			{ return(ENCODING); }
135
136\".*\"				{ char *e = yytext + 1;
137				  yylval.str = e;
138				  while (*e && *e != '"')
139					++e;
140				  *e = 0;
141				  return(STRING); }
142
143\<|\(|\[			{ return(LBRK); }
144
145\>|\)|\]			{ return(RBRK); }
146
147\-				{ return(THRU); }
148\.\.\.				{ return(THRU); }
149
150\:				{ return(':'); }
151
152{W}+				;
153
154^\#.*\n				;
155\/\*				{ char lc = 0;
156				  do {
157				    while ((lc) != '*')
158					if ((lc = input()) == 0)
159					    break;
160				  } while((lc = input()) != '/');
161				}
162
163\\$				;
164.				{ printf("Lex is skipping '%s'\n", yytext); }
165%%
166
167#if	!defined(yywrap)
168int
169yywrap()
170{
171	return(1);
172}
173#endif
174