This is Unofficial EPICS BASE Doxygen Site
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
yylex.c
Go to the documentation of this file.
1
/*************************************************************************\
2
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3
* National Laboratory.
4
* Copyright (c) 2002 The Regents of the University of California, as
5
* Operator of Los Alamos National Laboratory.
6
* EPICS BASE is distributed subject to a Software License Agreement found
7
* in file LICENSE that is included with this distribution.
8
\*************************************************************************/
9
/* yylex - scanner front-end for flex */
10
11
/*-
12
* Copyright (c) 1990 The Regents of the University of California.
13
* All rights reserved.
14
*
15
* This code is derived from software contributed to Berkeley by
16
* Vern Paxson.
17
*
18
* The United States Government has rights in this work pursuant
19
* to contract no. DE-AC03-76SF00098 between the United States
20
* Department of Energy and the University of California.
21
*
22
* Redistribution and use in source and binary forms are permitted provided
23
* that: (1) source distributions retain this entire copyright notice and
24
* comment, and (2) distributions including binaries display the following
25
* acknowledgement: ``This product includes software developed by the
26
* University of California, Berkeley and its contributors'' in the
27
* documentation or other materials provided with the distribution and in
28
* all advertising materials mentioning features or use of this software.
29
* Neither the name of the University nor the names of its contributors may
30
* be used to endorse or promote products derived from this software without
31
* specific prior written permission.
32
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
33
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
34
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
35
*/
36
37
#include <ctype.h>
38
#include "
flexdef.h
"
39
#include "parse.h"
40
41
/* ANSI C does not guarantee that isascii() is defined */
42
#ifndef isascii
43
#define isascii(c) ((c) <= 0177)
44
#endif
45
46
47
/* yylex - scan for a regular expression token
48
*
49
* synopsis
50
*
51
* token = yylex();
52
*
53
* token - return token found
54
*/
55
56
int
yylex
(
void
)
57
{
58
int
toktype;
59
static
int
beglin =
false
;
60
61
if
(
eofseen
)
62
toktype = EOF;
63
else
64
toktype =
flexscan
();
65
66
if
( toktype == EOF || toktype == 0 )
67
{
68
eofseen
= 1;
69
70
if
(
sectnum
== 1 )
71
{
72
synerr
(
"premature EOF"
);
73
sectnum
= 2;
74
toktype = SECTEND;
75
}
76
77
else
if
(
sectnum
== 2 )
78
{
79
sectnum
= 3;
80
toktype = 0;
81
}
82
83
else
84
toktype = 0;
85
}
86
87
if
(
trace
)
88
{
89
if
( beglin )
90
{
91
fprintf(
stderr
,
"%d\t"
,
num_rules
+ 1 );
92
beglin = 0;
93
}
94
95
switch
( toktype )
96
{
97
case
'<'
:
98
case
'>'
:
99
case
'^'
:
100
case
'$'
:
101
case
'"'
:
102
case
'['
:
103
case
']'
:
104
case
'{'
:
105
case
'}'
:
106
case
'|'
:
107
case
'('
:
108
case
')'
:
109
case
'-'
:
110
case
'/'
:
111
case
'\\'
:
112
case
'?'
:
113
case
'.'
:
114
case
'*'
:
115
case
'+'
:
116
case
','
:
117
(void) putc( toktype,
stderr
);
118
break
;
119
120
case
'\n'
:
121
(void) putc(
'\n'
,
stderr
);
122
123
if
(
sectnum
== 2 )
124
beglin = 1;
125
126
break
;
127
128
case
SCDECL:
129
fputs(
"%s"
,
stderr
);
130
break
;
131
132
case
XSCDECL:
133
fputs(
"%x"
,
stderr
);
134
break
;
135
136
case
WHITESPACE:
137
(void) putc(
' '
,
stderr
);
138
break
;
139
140
case
SECTEND:
141
fputs(
"%%\n"
,
stderr
);
142
143
/* we set beglin to be true so we'll start
144
* writing out numbers as we echo rules. flexscan() has
145
* already assigned sectnum
146
*/
147
148
if
(
sectnum
== 2 )
149
beglin = 1;
150
151
break
;
152
153
case
NAME:
154
fprintf(
stderr
,
"'%s'"
,
nmstr
);
155
break
;
156
157
case
CHAR:
158
switch
( yylval )
159
{
160
case
'<'
:
161
case
'>'
:
162
case
'^'
:
163
case
'$'
:
164
case
'"'
:
165
case
'['
:
166
case
']'
:
167
case
'{'
:
168
case
'}'
:
169
case
'|'
:
170
case
'('
:
171
case
')'
:
172
case
'-'
:
173
case
'/'
:
174
case
'\\'
:
175
case
'?'
:
176
case
'.'
:
177
case
'*'
:
178
case
'+'
:
179
case
','
:
180
fprintf(
stderr
,
"\\%c"
, yylval );
181
break
;
182
183
default
:
184
if
( !
isascii
( yylval ) || ! isprint( yylval ) )
185
fprintf(
stderr
,
"\\%.3o"
, yylval );
186
else
187
(
void
) putc( yylval,
stderr
);
188
break
;
189
}
190
191
break
;
192
193
case
NUMBER:
194
fprintf(
stderr
,
"%d"
, yylval );
195
break
;
196
197
case
PREVCCL:
198
fprintf(
stderr
,
"[%d]"
, yylval );
199
break
;
200
201
case
EOF_OP:
202
fprintf(
stderr
,
"<<EOF>>"
);
203
break
;
204
205
case
0:
206
fprintf(
stderr
,
"End Marker"
);
207
break
;
208
209
default
:
210
fprintf(
stderr
,
"*Something Weird* - tok: %d val: %d\n"
,
211
toktype, yylval );
212
break
;
213
}
214
}
215
216
return
( toktype );
217
}
218
nmstr
char nmstr[MAXLINE]
Definition:
flex.c:99
num_rules
int num_rules
Definition:
flex.c:76
yylex
int yylex(void)
Definition:
yylex.c:56
synerr
void synerr(char[])
flexdef.h
flexscan
int flexscan()
trace
int trace
Definition:
flex.c:66
stderr
#define stderr
Definition:
epicsStdio.h:32
isascii
#define isascii(c)
Definition:
yylex.c:43
eofseen
int eofseen
Definition:
flex.c:66
sectnum
int sectnum
Definition:
flex.c:100
modules
libcom
src
flex
yylex.c
Generated by
1.8.11