1/*	$NetBSD: lex.l,v 1.20 2016/09/03 05:56:59 dholland Exp $	*/
2
3%{
4/*-
5 * Copyright (c) 1993
6 *	The Regents of the University of California.  All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Paul Borman at Krystal Technologies.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 *    may be used to endorse or promote products derived from this software
21 *    without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#if HAVE_NBTOOL_CONFIG_H
37#include "nbtool_config.h"
38#endif
39
40#include <sys/cdefs.h>
41#ifndef lint
42#if 0
43static char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
44#else
45__RCSID("$NetBSD: lex.l,v 1.20 2016/09/03 05:56:59 dholland Exp $");
46#endif
47#endif /* not lint */
48
49#include <stdio.h>
50#include <stdlib.h>
51
52#include "citrus_namespace.h"
53#include "citrus_bcs.h"
54
55#include "runetype_file.h"
56
57#include "ldef.h"
58#include "yacc.h"
59
60int yylex(void);
61%}
62
63ODIGIT	[0-7]
64DIGIT	[0-9]
65XDIGIT	[0-9a-fA-F]
66W	[\t\n\r ]
67
68%%
69\'.\'				{ yylval.rune = (unsigned char)yytext[1];
70				  return(RUNE); }
71
72'\\a'				{ yylval.rune = '\a';
73				  return(RUNE); }
74'\\b'				{ yylval.rune = '\b';
75				  return(RUNE); }
76'\\f'				{ yylval.rune = '\f';
77				  return(RUNE); }
78'\\n'				{ yylval.rune = '\n';
79				  return(RUNE); }
80'\\r'				{ yylval.rune = '\r';
81				  return(RUNE); }
82'\\t'				{ yylval.rune = '\t';
83				  return(RUNE); }
84'\\v'				{ yylval.rune = '\v';
85				  return(RUNE); }
86
870x{XDIGIT}+			{ yylval.rune = _bcs_strtoul(yytext, 0, 16);
88				  return(RUNE); }
890{ODIGIT}+			{ yylval.rune = _bcs_strtoul(yytext, 0, 8);
90				  return(RUNE); }
91{DIGIT}+			{ yylval.rune = _bcs_strtoul(yytext, 0, 10);
92				  return(RUNE); }
93
94
95MAPLOWER			{ return(MAPLOWER); }
96MAPUPPER			{ return(MAPUPPER); }
97TODIGIT				{ return(DIGITMAP); }
98INVALID				{ return(INVALID); }
99
100ALPHA				{ yylval.i = _RUNETYPE_A|_RUNETYPE_R|_RUNETYPE_G;
101				  return(LIST); }
102CONTROL				{ yylval.i = _RUNETYPE_C;
103				  return(LIST); }
104DIGIT				{ yylval.i = _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G;
105				  return(LIST); }
106GRAPH				{ yylval.i = _RUNETYPE_G|_RUNETYPE_R;
107				  return(LIST); }
108LOWER				{ yylval.i = _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G;
109				  return(LIST); }
110PUNCT				{ yylval.i = _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G;
111				  return(LIST); }
112SPACE				{ yylval.i = _RUNETYPE_S;
113				  return(LIST); }
114UPPER				{ yylval.i = _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G;
115				  return(LIST); }
116XDIGIT				{ yylval.i = _RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G;
117				  return(LIST); }
118BLANK				{ yylval.i = _RUNETYPE_B;
119				  return(LIST); }
120PRINT				{ yylval.i = _RUNETYPE_R;
121				  return(LIST); }
122IDEOGRAM			{ yylval.i = _RUNETYPE_I|_RUNETYPE_R|_RUNETYPE_G;
123				  return(LIST); }
124SPECIAL				{ yylval.i = _RUNETYPE_T|_RUNETYPE_R|_RUNETYPE_G;
125				  return(LIST); }
126PHONOGRAM			{ yylval.i = _RUNETYPE_Q|_RUNETYPE_R|_RUNETYPE_G;
127				  return(LIST); }
128SWIDTH0				{ yylval.i = _RUNETYPE_SW0; return(LIST); }
129SWIDTH1				{ yylval.i = _RUNETYPE_SW1; return(LIST); }
130SWIDTH2				{ yylval.i = _RUNETYPE_SW2; return(LIST); }
131SWIDTH3				{ yylval.i = _RUNETYPE_SW3; return(LIST); }
132
133VARIABLE[\t ]			{ static char vbuf[1024];
134				  char *v = vbuf;
135				  while ((*v = input()) && *v != '\n')
136					++v;
137                                  if (*v) {
138					unput(*v);
139					*v = 0;
140				  }
141				  yylval.str = vbuf;
142				  return(VARIABLE);
143				}
144
145CHARSET				{ return(CHARSET); }
146
147ENCODING			{ return(ENCODING); }
148
149\".*\"				{ char *e = yytext + 1;
150				  yylval.str = e;
151				  while (*e && *e != '"')
152					++e;
153				  *e = 0;
154				  return(STRING); }
155
156\<|\(|\[			{ return(LBRK); }
157
158\>|\)|\]			{ return(RBRK); }
159
160\-				{ return(THRU); }
161\.\.\.				{ return(THRU); }
162
163\:				{ return(':'); }
164
165{W}+				;
166
167^\#.*\n				;
168\/\*				{ char lc = 0;
169				  do {
170				    while ((lc) != '*')
171					if ((lc = input()) == 0)
172					    break;
173				  } while((lc = input()) != '/');
174				}
175
176\\$				;
177.				{ printf("Lex is skipping '%s'\n", yytext); }
178%%
179
180#if	!defined(yywrap)
181int
182yywrap(void)
183{
184	return(1);
185}
186#endif
187