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 * 4. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
37#endif
38#endif /* not lint */
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD$");
42
43#include <ctype.h>
44#include <stdio.h>
45#include <stdlib.h>
46
47#include "ldef.h"
48#include "y.tab.h"
49#include "extern.h"
50
51#define	YY_DECL	int yylex(void)
52%}
53
54ODIGIT	[0-7]
55DIGIT	[0-9]
56XDIGIT	[0-9a-fA-F]
57W	[\t\n\r ]
58
59%%
60\'.\'				{ yylval.rune = (unsigned char)yytext[1];
61				  return(RUNE); }
62
63'\\a'				{ yylval.rune = '\a';
64				  return(RUNE); }
65'\\b'				{ yylval.rune = '\b';
66				  return(RUNE); }
67'\\f'				{ yylval.rune = '\f';
68				  return(RUNE); }
69'\\n'				{ yylval.rune = '\n';
70				  return(RUNE); }
71'\\r'				{ yylval.rune = '\r';
72				  return(RUNE); }
73'\\t'				{ yylval.rune = '\t';
74				  return(RUNE); }
75'\\v'				{ yylval.rune = '\v';
76				  return(RUNE); }
77
780x{XDIGIT}+			{ yylval.rune = strtol(yytext, 0, 16);
79				  return(RUNE); }
800{ODIGIT}+			{ yylval.rune = strtol(yytext, 0, 8);
81				  return(RUNE); }
82{DIGIT}+			{ yylval.rune = strtol(yytext, 0, 10);
83				  return(RUNE); }
84
85
86MAPLOWER			{ return(MAPLOWER); }
87MAPUPPER			{ return(MAPUPPER); }
88TODIGIT				{ return(DIGITMAP); }
89INVALID				{ return(INVALID); }
90
91ALPHA				{ yylval.i = _CTYPE_A|_CTYPE_R|_CTYPE_G;
92				  return(LIST); }
93CONTROL				{ yylval.i = _CTYPE_C;
94				  return(LIST); }
95DIGIT				{ yylval.i = _CTYPE_D|_CTYPE_R|_CTYPE_G;
96				  return(LIST); }
97GRAPH				{ yylval.i = _CTYPE_G|_CTYPE_R;
98				  return(LIST); }
99LOWER				{ yylval.i = _CTYPE_L|_CTYPE_R|_CTYPE_G;
100				  return(LIST); }
101PUNCT				{ yylval.i = _CTYPE_P|_CTYPE_R|_CTYPE_G;
102				  return(LIST); }
103SPACE				{ yylval.i = _CTYPE_S;
104				  return(LIST); }
105UPPER				{ yylval.i = _CTYPE_U|_CTYPE_R|_CTYPE_G;
106				  return(LIST); }
107XDIGIT				{ yylval.i = _CTYPE_X|_CTYPE_R|_CTYPE_G;
108				  return(LIST); }
109BLANK				{ yylval.i = _CTYPE_B;
110				  return(LIST); }
111PRINT				{ yylval.i = _CTYPE_R;
112				  return(LIST); }
113IDEOGRAM			{ yylval.i = _CTYPE_I|_CTYPE_R|_CTYPE_G;
114				  return(LIST); }
115SPECIAL				{ yylval.i = _CTYPE_T|_CTYPE_R|_CTYPE_G;
116				  return(LIST); }
117PHONOGRAM			{ yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G;
118				  return(LIST); }
119SWIDTH0				{ yylval.i = _CTYPE_SW0; return(LIST); }
120SWIDTH1				{ yylval.i = _CTYPE_SW1; return(LIST); }
121SWIDTH2				{ yylval.i = _CTYPE_SW2; return(LIST); }
122SWIDTH3				{ yylval.i = _CTYPE_SW3; return(LIST); }
123
124VARIABLE[\t ]			{ static char vbuf[1024];
125				  char *v = vbuf;
126				  while ((*v = input()) && *v != '\n')
127					++v;
128                                  if (*v) {
129					unput(*v);
130					*v = 0;
131				  }
132				  yylval.str = vbuf;
133				  return(VARIABLE);
134				}
135
136ENCODING			{ return(ENCODING); }
137
138\".*\"				{ char *e = yytext + 1;
139				  yylval.str = e;
140				  while (*e && *e != '"')
141					++e;
142				  *e = 0;
143				  return(STRING); }
144
145\<|\(|\[			{ return(LBRK); }
146
147\>|\)|\]			{ return(RBRK); }
148
149\-				{ return(THRU); }
150\.\.\.				{ return(THRU); }
151
152\:				{ return(':'); }
153
154{W}+				;
155
156^\#.*\n				;
157\/\*				{ char lc = 0;
158				  do {
159				    while ((lc) != '*')
160					if ((lc = input()) == 0)
161					    break;
162				  } while((lc = input()) != '/');
163				}
164
165\\$				;
166.				{ printf("Lex is skipping '%s'\n", yytext); }
167%%
168
169#if	!defined(yywrap)
170int
171yywrap(void)
172{
173	return(1);
174}
175#endif
176