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