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