blob: c0d103dd8894064974b38e75dec1cff87958bf95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*======================================================================
* Flex Options
*/
%option outfile="flextest.c"
%option header-file="flextest.h"
%option prefix="testme_yy"
%option reentrant
%option 8bit
%{
/*======================================================================
* User C Header
*/
int nlines=0;
%}
/*======================================================================
* Flex Definitions
*/
/*======================================================================
* Rules
*/
%%
\n { return 1; }
<<EOF>> { return 0; }
. { /* do nothing */; }
%%
/*======================================================================
* User C Code
*/
int main(void) {
yyscan_t scanner;
int nlines=0;
int tok;
testme_yylex_init(&scanner); //-- initialize reentrant flex scanner
while ((tok=testme_yylex(scanner))) {
//printf("tok=%d\n", tok);
nlines++;
}
testme_yylex_destroy(scanner); //-- cleanup reentrant flex scanner
printf("%d\n", nlines);
return 0;
}
int testme_yywrap(yyscan_t yyscanner) { return 1; }
|