lex.l revision 95643
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 * 3. All advertising materials mentioning features or use of this software
181590Srgrimes *    must display the following acknowledgement:
191590Srgrimes *	This product includes software developed by the University of
201590Srgrimes *	California, Berkeley and its contributors.
211590Srgrimes * 4. Neither the name of the University nor the names of its contributors
221590Srgrimes *    may be used to endorse or promote products derived from this software
231590Srgrimes *    without specific prior written permission.
241590Srgrimes *
251590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
261590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
271590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
281590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
291590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
301590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
311590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
321590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
331590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
341590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
351590Srgrimes * SUCH DAMAGE.
361590Srgrimes */
371590Srgrimes
381590Srgrimes#ifndef lint
3995643Smarkm#if 0
401590Srgrimesstatic char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
4195643Smarkm#endif
421590Srgrimes#endif /* not lint */
431590Srgrimes
4495643Smarkm#include <sys/cdefs.h>
4595643Smarkm__FBSDID("$FreeBSD: head/usr.bin/mklocale/lex.l 95643 2002-04-28 12:34:54Z markm $");
4695643Smarkm
471590Srgrimes#include <ctype.h>
481590Srgrimes#include <stdio.h>
491590Srgrimes#include <stdlib.h>
501590Srgrimes
511590Srgrimes#include "ldef.h"
5216073Sphk#include "y.tab.h"
5395643Smarkm#include "extern.h"
541590Srgrimes%}
551590Srgrimes
561590SrgrimesODIGIT	[0-7]
571590SrgrimesDIGIT	[0-9]
581590SrgrimesXDIGIT	[0-9a-fA-F]
591590SrgrimesW	[\t\n\r ]
601590Srgrimes
611590Srgrimes%%
6245219Sache\'.\'				{ yylval.rune = (unsigned char)yytext[1];
631590Srgrimes				  return(RUNE); }
641590Srgrimes
651590Srgrimes'\\a'				{ yylval.rune = '\a';
661590Srgrimes				  return(RUNE); }
671590Srgrimes'\\b'				{ yylval.rune = '\b';
681590Srgrimes				  return(RUNE); }
691590Srgrimes'\\f'				{ yylval.rune = '\f';
701590Srgrimes				  return(RUNE); }
711590Srgrimes'\\n'				{ yylval.rune = '\n';
721590Srgrimes				  return(RUNE); }
731590Srgrimes'\\r'				{ yylval.rune = '\r';
741590Srgrimes				  return(RUNE); }
751590Srgrimes'\\t'				{ yylval.rune = '\t';
761590Srgrimes				  return(RUNE); }
771590Srgrimes'\\v'				{ yylval.rune = '\v';
781590Srgrimes				  return(RUNE); }
791590Srgrimes
801590Srgrimes0x{XDIGIT}+			{ yylval.rune = strtol(yytext, 0, 16);
811590Srgrimes				  return(RUNE); }
821590Srgrimes0{ODIGIT}+			{ yylval.rune = strtol(yytext, 0, 8);
831590Srgrimes				  return(RUNE); }
841590Srgrimes{DIGIT}+			{ yylval.rune = strtol(yytext, 0, 10);
851590Srgrimes				  return(RUNE); }
861590Srgrimes
871590Srgrimes
881590SrgrimesMAPLOWER			{ return(MAPLOWER); }
891590SrgrimesMAPUPPER			{ return(MAPUPPER); }
901590SrgrimesTODIGIT				{ return(DIGITMAP); }
911590SrgrimesINVALID				{ return(INVALID); }
921590Srgrimes
9357035SobrienALPHA				{ yylval.i = _CTYPE_A|_CTYPE_R|_CTYPE_G;
9457035Sobrien				  return(LIST); }
9557035SobrienCONTROL				{ yylval.i = _CTYPE_C;
9657035Sobrien				  return(LIST); }
9757035SobrienDIGIT				{ yylval.i = _CTYPE_D|_CTYPE_R|_CTYPE_G;
9857035Sobrien				  return(LIST); }
9957035SobrienGRAPH				{ yylval.i = _CTYPE_G|_CTYPE_R;
10057035Sobrien				  return(LIST); }
10157035SobrienLOWER				{ yylval.i = _CTYPE_L|_CTYPE_R|_CTYPE_G;
10257035Sobrien				  return(LIST); }
10357035SobrienPUNCT				{ yylval.i = _CTYPE_P|_CTYPE_R|_CTYPE_G;
10457035Sobrien				  return(LIST); }
10557035SobrienSPACE				{ yylval.i = _CTYPE_S;
10657035Sobrien				  return(LIST); }
10757035SobrienUPPER				{ yylval.i = _CTYPE_U|_CTYPE_R|_CTYPE_G;
10857035Sobrien				  return(LIST); }
10957035SobrienXDIGIT				{ yylval.i = _CTYPE_X|_CTYPE_R|_CTYPE_G;
11057035Sobrien				  return(LIST); }
11157035SobrienBLANK				{ yylval.i = _CTYPE_B;
11257035Sobrien				  return(LIST); }
11357035SobrienPRINT				{ yylval.i = _CTYPE_R;
11457035Sobrien				  return(LIST); }
11557035SobrienIDEOGRAM			{ yylval.i = _CTYPE_I|_CTYPE_R|_CTYPE_G;
11657035Sobrien				  return(LIST); }
11757035SobrienSPECIAL				{ yylval.i = _CTYPE_T|_CTYPE_R|_CTYPE_G;
11857035Sobrien				  return(LIST); }
11957035SobrienPHONOGRAM			{ yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G;
12057035Sobrien				  return(LIST); }
1211590Srgrimes
1221590SrgrimesVARIABLE[\t ]			{ static char vbuf[1024];
1231590Srgrimes				  char *v = vbuf;
1241590Srgrimes				  while ((*v = input()) && *v != '\n')
1251590Srgrimes					++v;
1261590Srgrimes                                  if (*v) {
1271590Srgrimes					unput(*v);
1281590Srgrimes					*v = 0;
1291590Srgrimes				  }
1301590Srgrimes				  yylval.str = vbuf;
1311590Srgrimes				  return(VARIABLE);
1321590Srgrimes				}
1331590Srgrimes
1341590SrgrimesENCODING			{ return(ENCODING); }
1351590Srgrimes
1361590Srgrimes\".*\"				{ char *e = yytext + 1;
1371590Srgrimes				  yylval.str = e;
1381590Srgrimes				  while (*e && *e != '"')
1391590Srgrimes					++e;
1401590Srgrimes				  *e = 0;
1411590Srgrimes				  return(STRING); }
1421590Srgrimes
1431590Srgrimes\<|\(|\[			{ return(LBRK); }
1441590Srgrimes
1451590Srgrimes\>|\)|\]			{ return(RBRK); }
1461590Srgrimes
1471590Srgrimes\-				{ return(THRU); }
1481590Srgrimes\.\.\.				{ return(THRU); }
1491590Srgrimes
1501590Srgrimes\:				{ return(':'); }
1511590Srgrimes
1521590Srgrimes{W}+				;
1531590Srgrimes
1541590Srgrimes^\#.*\n				;
1551590Srgrimes\/\*				{ char lc = 0;
1561590Srgrimes				  do {
1571590Srgrimes				    while ((lc) != '*')
1581590Srgrimes					if ((lc = input()) == 0)
1591590Srgrimes					    break;
1601590Srgrimes				  } while((lc = input()) != '/');
1611590Srgrimes				}
1621590Srgrimes
1631590Srgrimes\\$				;
1641590Srgrimes.				{ printf("Lex is skipping '%s'\n", yytext); }
1651590Srgrimes%%
1661590Srgrimes
1671590Srgrimes#if	!defined(yywrap)
16895643Smarkmint
1691590Srgrimesyywrap()
1701590Srgrimes{
1711590Srgrimes	return(1);
1721590Srgrimes}
1731590Srgrimes#endif
174