The generated lexical analyzer will always choose the longest token. For your
printf("*");
rule .+
will give a longer token than [ \t]*
, so the former will be chosen.
By the way, you could try this example:
%{
%}
%%
[ \t]* {printf("| |");}
\n {printf("newline\n");}
[^ \n]+ {printf("%s", yytext);}
%%
int main() {
yylex();
return 0;
}