mirror of
https://github.com/westes/flex.git
synced 2026-01-27 01:44:23 +00:00
22 lines
429 B
Plaintext
22 lines
429 B
Plaintext
/* basic example - flawed reentrant version with global */
|
|
%{
|
|
int num_lines = 0, num_chars = 0;
|
|
%}
|
|
%option reentrant noyywrap
|
|
%%
|
|
\n ++num_lines; ++num_chars;
|
|
. ++num_chars;
|
|
|
|
%%
|
|
|
|
int main() {
|
|
yyscan_t scanner;
|
|
|
|
yylex_init ( &scanner );
|
|
yylex ( scanner );
|
|
yylex_destroy ( scanner );
|
|
|
|
printf( "# of lines = %d, # of chars = %d\n",
|
|
num_lines, num_chars );
|
|
}
|