My input consists of: A tab B tab C
I wrote a scanner with two rules: one rule matches on strings that don't contain a tab. The other rule matches on tabs. For the first rule, I output the string that was matched. I expected the first rule to be activated three times, outputting "A" the first time, "B" the second time, and "C" the third time. Instead, the rule is activated once and outputs: A B C
. Why? It appears that Flex (or the scanner) has converted the tabs in the input to spaces. Is my diagnosis correct? How to turn off that behavior? I don't want the tabs converted to spaces.
Here's my scanner:
%option noyywrap
%%
[^\t]+ { fprintf(stdout,"Got %s with length %d, \n",yytext,yyleng); }
\t { fprintf(stdout, "Found a tab\n"); }
%%
int main()
{yylex();}
No, flex does not ever convert tabs to spaces -- it does not do any conversion of input characters. So you probably have something else that has converted your tabs into spaces. Perhaps your editor has done so on the file you're feeding to your program.