1 /* $NetBSD: src/usr.bin/mklocale/lex.l,v 1.13 2003/10/27 00:12:43 lukem Exp $ */
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Paul Borman at Krystal Technologies.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
36 #pragma GCC diagnostic ignored "-Wsign-compare"
41 #include "locale/runetype.h"
53 \'.\' { yylval.rune = (unsigned char)yytext[1];
56 '\\a' { yylval.rune = '\a';
58 '\\b' { yylval.rune = '\b';
60 '\\f' { yylval.rune = '\f';
62 '\\n' { yylval.rune = '\n';
64 '\\r' { yylval.rune = '\r';
66 '\\t' { yylval.rune = '\t';
68 '\\v' { yylval.rune = '\v';
71 0x{XDIGIT}+ { yylval.rune = strtoul(yytext, 0, 16);
73 0{ODIGIT}+ { yylval.rune = strtoul(yytext, 0, 8);
75 {DIGIT}+ { yylval.rune = strtoul(yytext, 0, 10);
79 MAPLOWER { return(MAPLOWER); }
80 MAPUPPER { return(MAPUPPER); }
81 TODIGIT { return(DIGITMAP); }
82 INVALID { return(INVALID); }
84 ALPHA { yylval.i = _RUNETYPE_A|_RUNETYPE_R|_RUNETYPE_G;
86 CONTROL { yylval.i = _RUNETYPE_C;
88 DIGIT { yylval.i = _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G;
90 GRAPH { yylval.i = _RUNETYPE_G|_RUNETYPE_R;
92 LOWER { yylval.i = _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G;
94 PUNCT { yylval.i = _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G;
96 SPACE { yylval.i = _RUNETYPE_S;
98 UPPER { yylval.i = _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G;
100 XDIGIT { yylval.i = _RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G;
102 BLANK { yylval.i = _RUNETYPE_B;
104 PRINT { yylval.i = _RUNETYPE_R;
106 IDEOGRAM { yylval.i = _RUNETYPE_I|_RUNETYPE_R|_RUNETYPE_G;
108 SPECIAL { yylval.i = _RUNETYPE_T|_RUNETYPE_R|_RUNETYPE_G;
110 PHONOGRAM { yylval.i = _RUNETYPE_Q|_RUNETYPE_R|_RUNETYPE_G;
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); }
117 VARIABLE[\t ] { static char vbuf[1024];
119 while ((*v = input()) && *v != '\n')
129 CHARSET { return(CHARSET); }
131 ENCODING { return(ENCODING); }
133 \".*\" { char *e = yytext + 1;
135 while (*e && *e != '"')
140 \<|\(|\[ { return(LBRK); }
142 \>|\)|\] { return(RBRK); }
145 \.\.\. { return(THRU); }
155 if ((lc = input()) == 0)
157 } while((lc = input()) != '/');
161 . { printf("Lex is skipping '%s'\n", yytext); }