Lex: force scan?

I am writing a fairly simple LEX program that, after parsing several files, parses user input.

Now, with files, everything works like a charm. However, when it comes to user input from stdin, LEX rules will not be executed until the EOF character is sent (via ctrl + D). When I do this, LEX parses everything I wrote, and then waits for more input. A second consecutive EOF completes the scan.

Thing is, I want the program to respond to \nby outputting some data. Is there a way to force a scan from within the rule or configure LEX buffering in some way to match this behavior?

+3
source share
2 answers

! :

%option always-interactive

, ... , .

+4

unix, lex yacc. , .

"\n"                    |
";"                     {
                        //yylval.sb = getsb(yytext);  for yacc stuff
                        fprintf(stderr,"EOL\n");
                        return(EOL);
                        }
0

All Articles