11590Srgrimes%{ 21590Srgrimes/*- 31590Srgrimes * Copyright (c) 1993 41590Srgrimes * The Regents of the University of California. All rights reserved. 51590Srgrimes * 61590Srgrimes * This code is derived from software contributed to Berkeley by 71590Srgrimes * Paul Borman at Krystal Technologies. 81590Srgrimes * 91590Srgrimes * Redistribution and use in source and binary forms, with or without 101590Srgrimes * modification, are permitted provided that the following conditions 111590Srgrimes * are met: 121590Srgrimes * 1. Redistributions of source code must retain the above copyright 131590Srgrimes * notice, this list of conditions and the following disclaimer. 141590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151590Srgrimes * notice, this list of conditions and the following disclaimer in the 161590Srgrimes * documentation and/or other materials provided with the distribution. 171590Srgrimes * 4. Neither the name of the University nor the names of its contributors 181590Srgrimes * may be used to endorse or promote products derived from this software 191590Srgrimes * without specific prior written permission. 201590Srgrimes * 211590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241590Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311590Srgrimes * SUCH DAMAGE. 321590Srgrimes */ 331590Srgrimes 341590Srgrimes#ifndef lint 3595643Smarkm#if 0 361590Srgrimesstatic char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 6/6/93"; 3795643Smarkm#endif 381590Srgrimes#endif /* not lint */ 391590Srgrimes 4095643Smarkm#include <sys/cdefs.h> 4195643Smarkm__FBSDID("$FreeBSD: releng/10.2/usr.bin/mklocale/lex.l 250926 2013-05-23 05:42:35Z jkim $"); 4295643Smarkm 431590Srgrimes#include <ctype.h> 441590Srgrimes#include <stdio.h> 451590Srgrimes#include <stdlib.h> 461590Srgrimes 471590Srgrimes#include "ldef.h" 4816073Sphk#include "y.tab.h" 4995643Smarkm#include "extern.h" 50250926Sjkim 51250926Sjkim#define YY_DECL int yylex(void) 521590Srgrimes%} 531590Srgrimes 541590SrgrimesODIGIT [0-7] 551590SrgrimesDIGIT [0-9] 561590SrgrimesXDIGIT [0-9a-fA-F] 571590SrgrimesW [\t\n\r ] 581590Srgrimes 591590Srgrimes%% 6045219Sache\'.\' { yylval.rune = (unsigned char)yytext[1]; 611590Srgrimes return(RUNE); } 621590Srgrimes 631590Srgrimes'\\a' { yylval.rune = '\a'; 641590Srgrimes return(RUNE); } 651590Srgrimes'\\b' { yylval.rune = '\b'; 661590Srgrimes return(RUNE); } 671590Srgrimes'\\f' { yylval.rune = '\f'; 681590Srgrimes return(RUNE); } 691590Srgrimes'\\n' { yylval.rune = '\n'; 701590Srgrimes return(RUNE); } 711590Srgrimes'\\r' { yylval.rune = '\r'; 721590Srgrimes return(RUNE); } 731590Srgrimes'\\t' { yylval.rune = '\t'; 741590Srgrimes return(RUNE); } 751590Srgrimes'\\v' { yylval.rune = '\v'; 761590Srgrimes return(RUNE); } 771590Srgrimes 781590Srgrimes0x{XDIGIT}+ { yylval.rune = strtol(yytext, 0, 16); 791590Srgrimes return(RUNE); } 801590Srgrimes0{ODIGIT}+ { yylval.rune = strtol(yytext, 0, 8); 811590Srgrimes return(RUNE); } 821590Srgrimes{DIGIT}+ { yylval.rune = strtol(yytext, 0, 10); 831590Srgrimes return(RUNE); } 841590Srgrimes 851590Srgrimes 861590SrgrimesMAPLOWER { return(MAPLOWER); } 871590SrgrimesMAPUPPER { return(MAPUPPER); } 881590SrgrimesTODIGIT { return(DIGITMAP); } 891590SrgrimesINVALID { return(INVALID); } 901590Srgrimes 9157035SobrienALPHA { yylval.i = _CTYPE_A|_CTYPE_R|_CTYPE_G; 9257035Sobrien return(LIST); } 9357035SobrienCONTROL { yylval.i = _CTYPE_C; 9457035Sobrien return(LIST); } 9557035SobrienDIGIT { yylval.i = _CTYPE_D|_CTYPE_R|_CTYPE_G; 9657035Sobrien return(LIST); } 9757035SobrienGRAPH { yylval.i = _CTYPE_G|_CTYPE_R; 9857035Sobrien return(LIST); } 9957035SobrienLOWER { yylval.i = _CTYPE_L|_CTYPE_R|_CTYPE_G; 10057035Sobrien return(LIST); } 10157035SobrienPUNCT { yylval.i = _CTYPE_P|_CTYPE_R|_CTYPE_G; 10257035Sobrien return(LIST); } 10357035SobrienSPACE { yylval.i = _CTYPE_S; 10457035Sobrien return(LIST); } 10557035SobrienUPPER { yylval.i = _CTYPE_U|_CTYPE_R|_CTYPE_G; 10657035Sobrien return(LIST); } 10757035SobrienXDIGIT { yylval.i = _CTYPE_X|_CTYPE_R|_CTYPE_G; 10857035Sobrien return(LIST); } 10957035SobrienBLANK { yylval.i = _CTYPE_B; 11057035Sobrien return(LIST); } 11157035SobrienPRINT { yylval.i = _CTYPE_R; 11257035Sobrien return(LIST); } 11357035SobrienIDEOGRAM { yylval.i = _CTYPE_I|_CTYPE_R|_CTYPE_G; 11457035Sobrien return(LIST); } 11557035SobrienSPECIAL { yylval.i = _CTYPE_T|_CTYPE_R|_CTYPE_G; 11657035Sobrien return(LIST); } 11757035SobrienPHONOGRAM { yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G; 11857035Sobrien return(LIST); } 119101986SkeichiiSWIDTH0 { yylval.i = _CTYPE_SW0; return(LIST); } 120101986SkeichiiSWIDTH1 { yylval.i = _CTYPE_SW1; return(LIST); } 121101986SkeichiiSWIDTH2 { yylval.i = _CTYPE_SW2; return(LIST); } 122101986SkeichiiSWIDTH3 { yylval.i = _CTYPE_SW3; return(LIST); } 1231590Srgrimes 1241590SrgrimesVARIABLE[\t ] { static char vbuf[1024]; 1251590Srgrimes char *v = vbuf; 1261590Srgrimes while ((*v = input()) && *v != '\n') 1271590Srgrimes ++v; 1281590Srgrimes if (*v) { 1291590Srgrimes unput(*v); 1301590Srgrimes *v = 0; 1311590Srgrimes } 1321590Srgrimes yylval.str = vbuf; 1331590Srgrimes return(VARIABLE); 1341590Srgrimes } 1351590Srgrimes 1361590SrgrimesENCODING { return(ENCODING); } 1371590Srgrimes 1381590Srgrimes\".*\" { char *e = yytext + 1; 1391590Srgrimes yylval.str = e; 1401590Srgrimes while (*e && *e != '"') 1411590Srgrimes ++e; 1421590Srgrimes *e = 0; 1431590Srgrimes return(STRING); } 1441590Srgrimes 1451590Srgrimes\<|\(|\[ { return(LBRK); } 1461590Srgrimes 1471590Srgrimes\>|\)|\] { return(RBRK); } 1481590Srgrimes 1491590Srgrimes\- { return(THRU); } 1501590Srgrimes\.\.\. { return(THRU); } 1511590Srgrimes 1521590Srgrimes\: { return(':'); } 1531590Srgrimes 1541590Srgrimes{W}+ ; 1551590Srgrimes 1561590Srgrimes^\#.*\n ; 1571590Srgrimes\/\* { char lc = 0; 1581590Srgrimes do { 1591590Srgrimes while ((lc) != '*') 1601590Srgrimes if ((lc = input()) == 0) 1611590Srgrimes break; 1621590Srgrimes } while((lc = input()) != '/'); 1631590Srgrimes } 1641590Srgrimes 1651590Srgrimes\\$ ; 1661590Srgrimes. { printf("Lex is skipping '%s'\n", yytext); } 1671590Srgrimes%% 1681590Srgrimes 1691590Srgrimes#if !defined(yywrap) 17095643Smarkmint 171201227Sedyywrap(void) 1721590Srgrimes{ 1731590Srgrimes return(1); 1741590Srgrimes} 1751590Srgrimes#endif 176