flex/examples/manual/example_nr.lex
Eric S. Raymond 8d0162b80a Update all the examples to use the new API elements.
Add a fully reentrant example.  And update to TODO file.
2020-10-12 21:07:14 -04:00

17 lines
291 B
Plaintext

/* basic example - non-reentrant version */
%{
int num_lines = 0, num_chars = 0;
%}
%option noyywrap
%%
\n ++num_lines; ++num_chars;
. ++num_chars;
%%
int main() {
yylex();
printf( "# of lines = %d, # of chars = %d\n",
num_lines, num_chars );
}