GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/mklocale/lex.l Lines: 0 0 0.0 %
Date: 2017-11-07 Branches: 0 0 0.0 %

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