1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
%option noyywrap digit [0-9] letter [A-Za-z] %{ int count; %} %% {letter}({letter}|{digit})* {fwrite(yytext, yyleng, 1, yyout); ++count;}; . %% int main(void) { yylex(); printf("%d\n", count); return 0; }