How to put tabs in the input of a lex program?

25 views Asked by At

I am making a code in lex that identifies tokens and key word from another programming language. When i put my input i want to be able to introduce tabs so i can write a whole function but at the first tab that i introduce, the program automaticaly gives me the output for the first line. How can i put tabs in the input without that happening and only get the output when i press ctrl+D?

%%
(public|private|protected|package) {printf("ACCESS_MODIFIER"); }
(int|float|char|short|byte|double|bool|string|void)   {printf("TYPE"); }
(return|RETURN)   {printf("RETURN"); }

\{    {printf("BLOCK_START"); }
\}    {printf("BLOCK_END"); }

\(    {printf("FN_PARAMS_START"); }
\)    {printf("FN PARAMS END"); }

[a-zA-Z_][a-zA-Z0-9_]*\(   {printf("FUNCTION_NAME FN_PARAMS_START"); }
[a-zA-Z_][a-zA-Z0-9]*   {printf("VARIABLE_NAME"); }

=   {printf("ASSIGN"); }
[\+|\-|\*|\/|\%|\||\&]    {printf("OPERATOR"); }

\,    {printf(","); }
\;    {printf(";"); }
[  \t]    {printf(" "); }
[\n]    {printf("\n"); }
.   ;
%%

int yywrap(){ return 1;    }

int main() {
  printf("Enter the code :\n");
  yylex();
  return 0;
}
0

There are 0 answers