1 /* $NetBSD: src/usr.bin/mklocale/lex.l,v 1.13 2003/10/27 00:12:43 lukem Exp $ */
2 /* $DragonFly: src/usr.bin/mklocale/lex.l,v 1.7 2008/06/21 20:01:14 swildner Exp $ */
7 * The Regents of the University of California. All rights reserved.
9 * This code is derived from software contributed to Berkeley by
10 * Paul Borman at Krystal Technologies.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 #include "locale/runetype.h"
54 \'.\' { yylval.rune = (unsigned char)yytext[1];
57 '\\a' { yylval.rune = '\a';
59 '\\b' { yylval.rune = '\b';
61 '\\f' { yylval.rune = '\f';
63 '\\n' { yylval.rune = '\n';
65 '\\r' { yylval.rune = '\r';
67 '\\t' { yylval.rune = '\t';
69 '\\v' { yylval.rune = '\v';
72 0x{XDIGIT}+ { yylval.rune = strtoul(yytext, 0, 16);
74 0{ODIGIT}+ { yylval.rune = strtoul(yytext, 0, 8);
76 {DIGIT}+ { yylval.rune = strtoul(yytext, 0, 10);
80 MAPLOWER { return(MAPLOWER); }
81 MAPUPPER { return(MAPUPPER); }
82 TODIGIT { return(DIGITMAP); }
83 INVALID { return(INVALID); }
85 ALPHA { yylval.i = _RUNETYPE_A|_RUNETYPE_R|_RUNETYPE_G;
87 CONTROL { yylval.i = _RUNETYPE_C;
89 DIGIT { yylval.i = _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G;
91 GRAPH { yylval.i = _RUNETYPE_G|_RUNETYPE_R;
93 LOWER { yylval.i = _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G;
95 PUNCT { yylval.i = _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G;
97 SPACE { yylval.i = _RUNETYPE_S;
99 UPPER { yylval.i = _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G;
101 XDIGIT { yylval.i = _RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G;
103 BLANK { yylval.i = _RUNETYPE_B;
105 PRINT { yylval.i = _RUNETYPE_R;
107 IDEOGRAM { yylval.i = _RUNETYPE_I|_RUNETYPE_R|_RUNETYPE_G;
109 SPECIAL { yylval.i = _RUNETYPE_T|_RUNETYPE_R|_RUNETYPE_G;
111 PHONOGRAM { yylval.i = _RUNETYPE_Q|_RUNETYPE_R|_RUNETYPE_G;
113 SWIDTH0 { yylval.i = _RUNETYPE_SW0; return(LIST); }
114 SWIDTH1 { yylval.i = _RUNETYPE_SW1; return(LIST); }
115 SWIDTH2 { yylval.i = _RUNETYPE_SW2; return(LIST); }
116 SWIDTH3 { yylval.i = _RUNETYPE_SW3; return(LIST); }
118 VARIABLE[\t ] { static char vbuf[1024];
120 while ((*v = input()) && *v != '\n')
130 CHARSET { return(CHARSET); }
132 ENCODING { return(ENCODING); }
134 \".*\" { char *e = yytext + 1;
136 while (*e && *e != '"')
141 \<|\(|\[ { return(LBRK); }
143 \>|\)|\] { return(RBRK); }
146 \.\.\. { return(THRU); }
156 if ((lc = input()) == 0)
158 } while((lc = input()) != '/');
162 . { printf("Lex is skipping '%s'\n", yytext); }