flex cleanup, silence errors
[dragonfly.git] / usr.bin / mklocale / lex.l
1 /*      $NetBSD: src/usr.bin/mklocale/lex.l,v 1.13 2003/10/27 00:12:43 lukem Exp $      */
2
3 %{
4 /*-
5  * Copyright (c) 1993
6  *      The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * Paul Borman at Krystal Technologies.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35
36 #pragma GCC diagnostic ignored "-Wsign-compare"
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <unistd.h>
40
41 #include "locale/runetype.h"
42 #include "ldef.h"
43 #include "yacc.h"
44
45 %}
46
47 ODIGIT  [0-7]
48 DIGIT   [0-9]
49 XDIGIT  [0-9a-fA-F]
50 W       [\t\n\r ]
51
52 %%
53 \'.\'                           { yylval.rune = (unsigned char)yytext[1];
54                                   return(RUNE); }
55
56 '\\a'                           { yylval.rune = '\a';
57                                   return(RUNE); }
58 '\\b'                           { yylval.rune = '\b';
59                                   return(RUNE); }
60 '\\f'                           { yylval.rune = '\f';
61                                   return(RUNE); }
62 '\\n'                           { yylval.rune = '\n';
63                                   return(RUNE); }
64 '\\r'                           { yylval.rune = '\r';
65                                   return(RUNE); }
66 '\\t'                           { yylval.rune = '\t';
67                                   return(RUNE); }
68 '\\v'                           { yylval.rune = '\v';
69                                   return(RUNE); }
70
71 0x{XDIGIT}+                     { yylval.rune = strtoul(yytext, 0, 16);
72                                   return(RUNE); }
73 0{ODIGIT}+                      { yylval.rune = strtoul(yytext, 0, 8);
74                                   return(RUNE); }
75 {DIGIT}+                        { yylval.rune = strtoul(yytext, 0, 10);
76                                   return(RUNE); }
77
78
79 MAPLOWER                        { return(MAPLOWER); }
80 MAPUPPER                        { return(MAPUPPER); }
81 TODIGIT                         { return(DIGITMAP); }
82 INVALID                         { return(INVALID); }
83
84 ALPHA                           { yylval.i = _RUNETYPE_A|_RUNETYPE_R|_RUNETYPE_G;
85                                   return(LIST); }
86 CONTROL                         { yylval.i = _RUNETYPE_C;
87                                   return(LIST); }
88 DIGIT                           { yylval.i = _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G;
89                                   return(LIST); }
90 GRAPH                           { yylval.i = _RUNETYPE_G|_RUNETYPE_R;
91                                   return(LIST); }
92 LOWER                           { yylval.i = _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G;
93                                   return(LIST); }
94 PUNCT                           { yylval.i = _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G;
95                                   return(LIST); }
96 SPACE                           { yylval.i = _RUNETYPE_S;
97                                   return(LIST); }
98 UPPER                           { yylval.i = _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G;
99                                   return(LIST); }
100 XDIGIT                          { yylval.i = _RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G;
101                                   return(LIST); }
102 BLANK                           { yylval.i = _RUNETYPE_B;
103                                   return(LIST); }
104 PRINT                           { yylval.i = _RUNETYPE_R;
105                                   return(LIST); }
106 IDEOGRAM                        { yylval.i = _RUNETYPE_I|_RUNETYPE_R|_RUNETYPE_G;
107                                   return(LIST); }
108 SPECIAL                         { yylval.i = _RUNETYPE_T|_RUNETYPE_R|_RUNETYPE_G;
109                                   return(LIST); }
110 PHONOGRAM                       { yylval.i = _RUNETYPE_Q|_RUNETYPE_R|_RUNETYPE_G;
111                                   return(LIST); }
112 SWIDTH0                         { yylval.i = _RUNETYPE_SW0; return(LIST); }
113 SWIDTH1                         { yylval.i = _RUNETYPE_SW1; return(LIST); }
114 SWIDTH2                         { yylval.i = _RUNETYPE_SW2; return(LIST); }
115 SWIDTH3                         { yylval.i = _RUNETYPE_SW3; return(LIST); }
116
117 VARIABLE[\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
129 CHARSET                         { return(CHARSET); }
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(void)
167 {
168         return(1);
169 }
170 #endif