lex.l revision 45219
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
391590Srgrimesstatic char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
401590Srgrimes#endif /* not lint */
411590Srgrimes
421590Srgrimes#include <ctype.h>
431590Srgrimes#include <stdio.h>
441590Srgrimes#include <stdlib.h>
451590Srgrimes
461590Srgrimes#include "ldef.h"
4716073Sphk#include "y.tab.h"
481590Srgrimes%}
491590Srgrimes
501590SrgrimesODIGIT	[0-7]
511590SrgrimesDIGIT	[0-9]
521590SrgrimesXDIGIT	[0-9a-fA-F]
531590SrgrimesW	[\t\n\r ]
541590Srgrimes
551590Srgrimes%%
5645219Sache\'.\'				{ yylval.rune = (unsigned char)yytext[1];
571590Srgrimes				  return(RUNE); }
581590Srgrimes
591590Srgrimes'\\a'				{ yylval.rune = '\a';
601590Srgrimes				  return(RUNE); }
611590Srgrimes'\\b'				{ yylval.rune = '\b';
621590Srgrimes				  return(RUNE); }
631590Srgrimes'\\f'				{ yylval.rune = '\f';
641590Srgrimes				  return(RUNE); }
651590Srgrimes'\\n'				{ yylval.rune = '\n';
661590Srgrimes				  return(RUNE); }
671590Srgrimes'\\r'				{ yylval.rune = '\r';
681590Srgrimes				  return(RUNE); }
691590Srgrimes'\\t'				{ yylval.rune = '\t';
701590Srgrimes				  return(RUNE); }
711590Srgrimes'\\v'				{ yylval.rune = '\v';
721590Srgrimes				  return(RUNE); }
731590Srgrimes
741590Srgrimes0x{XDIGIT}+			{ yylval.rune = strtol(yytext, 0, 16);
751590Srgrimes				  return(RUNE); }
761590Srgrimes0{ODIGIT}+			{ yylval.rune = strtol(yytext, 0, 8);
771590Srgrimes				  return(RUNE); }
781590Srgrimes{DIGIT}+			{ yylval.rune = strtol(yytext, 0, 10);
791590Srgrimes				  return(RUNE); }
801590Srgrimes
811590Srgrimes
821590SrgrimesMAPLOWER			{ return(MAPLOWER); }
831590SrgrimesMAPUPPER			{ return(MAPUPPER); }
841590SrgrimesTODIGIT				{ return(DIGITMAP); }
851590SrgrimesINVALID				{ return(INVALID); }
861590Srgrimes
871590SrgrimesALPHA				{ yylval.i = _A|_R|_G; return(LIST); }
881590SrgrimesCONTROL				{ yylval.i = _C; return(LIST); }
891590SrgrimesDIGIT				{ yylval.i = _D|_R|_G; return(LIST); }
901590SrgrimesGRAPH				{ yylval.i = _G|_R; return(LIST); }
911590SrgrimesLOWER				{ yylval.i = _L|_R|_G; return(LIST); }
921590SrgrimesPUNCT				{ yylval.i = _P|_R|_G; return(LIST); }
931590SrgrimesSPACE				{ yylval.i = _S; return(LIST); }
941590SrgrimesUPPER				{ yylval.i = _U|_R|_G; return(LIST); }
951590SrgrimesXDIGIT				{ yylval.i = _X|_R|_G; return(LIST); }
961590SrgrimesBLANK				{ yylval.i = _B; return(LIST); }
971590SrgrimesPRINT				{ yylval.i = _R; return(LIST); }
981590SrgrimesIDEOGRAM			{ yylval.i = _I|_R|_G; return(LIST); }
991590SrgrimesSPECIAL				{ yylval.i = _T|_R|_G; return(LIST); }
1001590SrgrimesPHONOGRAM			{ yylval.i = _Q|_R|_G; return(LIST); }
1011590Srgrimes
1021590SrgrimesVARIABLE[\t ]			{ static char vbuf[1024];
1031590Srgrimes				  char *v = vbuf;
1041590Srgrimes				  while ((*v = input()) && *v != '\n')
1051590Srgrimes					++v;
1061590Srgrimes                                  if (*v) {
1071590Srgrimes					unput(*v);
1081590Srgrimes					*v = 0;
1091590Srgrimes				  }
1101590Srgrimes				  yylval.str = vbuf;
1111590Srgrimes				  return(VARIABLE);
1121590Srgrimes				}
1131590Srgrimes
1141590SrgrimesENCODING			{ return(ENCODING); }
1151590Srgrimes
1161590Srgrimes\".*\"				{ char *e = yytext + 1;
1171590Srgrimes				  yylval.str = e;
1181590Srgrimes				  while (*e && *e != '"')
1191590Srgrimes					++e;
1201590Srgrimes				  *e = 0;
1211590Srgrimes				  return(STRING); }
1221590Srgrimes
1231590Srgrimes\<|\(|\[			{ return(LBRK); }
1241590Srgrimes
1251590Srgrimes\>|\)|\]			{ return(RBRK); }
1261590Srgrimes
1271590Srgrimes\-				{ return(THRU); }
1281590Srgrimes\.\.\.				{ return(THRU); }
1291590Srgrimes
1301590Srgrimes\:				{ return(':'); }
1311590Srgrimes
1321590Srgrimes{W}+				;
1331590Srgrimes
1341590Srgrimes^\#.*\n				;
1351590Srgrimes\/\*				{ char lc = 0;
1361590Srgrimes				  do {
1371590Srgrimes				    while ((lc) != '*')
1381590Srgrimes					if ((lc = input()) == 0)
1391590Srgrimes					    break;
1401590Srgrimes				  } while((lc = input()) != '/');
1411590Srgrimes				}
1421590Srgrimes
1431590Srgrimes\\$				;
1441590Srgrimes.				{ printf("Lex is skipping '%s'\n", yytext); }
1451590Srgrimes%%
1461590Srgrimes
1471590Srgrimes#if	!defined(yywrap)
1481590Srgrimesyywrap()
1491590Srgrimes{
1501590Srgrimes	return(1);
1511590Srgrimes}
1521590Srgrimes#endif
153