lex.l revision 57035
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
39static char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
40static char rcsid[] = "$FreeBSD: head/usr.bin/mklocale/lex.l 57035 2000-02-08 07:43:26Z obrien $";
41#endif /* not lint */
42
43#include <ctype.h>
44#include <stdio.h>
45#include <stdlib.h>
46
47#include "ldef.h"
48#include "y.tab.h"
49%}
50
51ODIGIT	[0-7]
52DIGIT	[0-9]
53XDIGIT	[0-9a-fA-F]
54W	[\t\n\r ]
55
56%%
57\'.\'				{ yylval.rune = (unsigned char)yytext[1];
58				  return(RUNE); }
59
60'\\a'				{ yylval.rune = '\a';
61				  return(RUNE); }
62'\\b'				{ yylval.rune = '\b';
63				  return(RUNE); }
64'\\f'				{ yylval.rune = '\f';
65				  return(RUNE); }
66'\\n'				{ yylval.rune = '\n';
67				  return(RUNE); }
68'\\r'				{ yylval.rune = '\r';
69				  return(RUNE); }
70'\\t'				{ yylval.rune = '\t';
71				  return(RUNE); }
72'\\v'				{ yylval.rune = '\v';
73				  return(RUNE); }
74
750x{XDIGIT}+			{ yylval.rune = strtol(yytext, 0, 16);
76				  return(RUNE); }
770{ODIGIT}+			{ yylval.rune = strtol(yytext, 0, 8);
78				  return(RUNE); }
79{DIGIT}+			{ yylval.rune = strtol(yytext, 0, 10);
80				  return(RUNE); }
81
82
83MAPLOWER			{ return(MAPLOWER); }
84MAPUPPER			{ return(MAPUPPER); }
85TODIGIT				{ return(DIGITMAP); }
86INVALID				{ return(INVALID); }
87
88ALPHA				{ yylval.i = _CTYPE_A|_CTYPE_R|_CTYPE_G;
89				  return(LIST); }
90CONTROL				{ yylval.i = _CTYPE_C;
91				  return(LIST); }
92DIGIT				{ yylval.i = _CTYPE_D|_CTYPE_R|_CTYPE_G;
93				  return(LIST); }
94GRAPH				{ yylval.i = _CTYPE_G|_CTYPE_R;
95				  return(LIST); }
96LOWER				{ yylval.i = _CTYPE_L|_CTYPE_R|_CTYPE_G;
97				  return(LIST); }
98PUNCT				{ yylval.i = _CTYPE_P|_CTYPE_R|_CTYPE_G;
99				  return(LIST); }
100SPACE				{ yylval.i = _CTYPE_S;
101				  return(LIST); }
102UPPER				{ yylval.i = _CTYPE_U|_CTYPE_R|_CTYPE_G;
103				  return(LIST); }
104XDIGIT				{ yylval.i = _CTYPE_X|_CTYPE_R|_CTYPE_G;
105				  return(LIST); }
106BLANK				{ yylval.i = _CTYPE_B;
107				  return(LIST); }
108PRINT				{ yylval.i = _CTYPE_R;
109				  return(LIST); }
110IDEOGRAM			{ yylval.i = _CTYPE_I|_CTYPE_R|_CTYPE_G;
111				  return(LIST); }
112SPECIAL				{ yylval.i = _CTYPE_T|_CTYPE_R|_CTYPE_G;
113				  return(LIST); }
114PHONOGRAM			{ yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G;
115				  return(LIST); }
116
117VARIABLE[\t ]			{ static char vbuf[1024];
118				  char *v = vbuf;
119				  while ((*v = input()) && *v != '\n')
120					++v;
121                                  if (*v) {
122					unput(*v);
123					*v = 0;
124				  }
125				  yylval.str = vbuf;
126				  return(VARIABLE);
127				}
128
129ENCODING			{ return(ENCODING); }
130
131\".*\"				{ char *e = yytext + 1;
132				  yylval.str = e;
133				  while (*e && *e != '"')
134					++e;
135				  *e = 0;
136				  return(STRING); }
137
138\<|\(|\[			{ return(LBRK); }
139
140\>|\)|\]			{ return(RBRK); }
141
142\-				{ return(THRU); }
143\.\.\.				{ return(THRU); }
144
145\:				{ return(':'); }
146
147{W}+				;
148
149^\#.*\n				;
150\/\*				{ char lc = 0;
151				  do {
152				    while ((lc) != '*')
153					if ((lc = input()) == 0)
154					    break;
155				  } while((lc = input()) != '/');
156				}
157
158\\$				;
159.				{ printf("Lex is skipping '%s'\n", yytext); }
160%%
161
162#if	!defined(yywrap)
163yywrap()
164{
165	return(1);
166}
167#endif
168