Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lex: forcing scan?

Tags:

c++

c

lex

I'm writing a fairly simple program with LEX, that after parsing a few files, parses input from a user.

Now, with the files, everything works like a charm. However, when it comes to user input from stdin, LEX rules won't run until an EOF (via ctrl+D) character is sent. When I do that, LEX parses all I wrote and then waits for more input. A second consecutive EOF terminates the scanner.

Thing is, I want the program to react on \n, outputting some data. Is there a way to force a scan from inside a rule, or to configure LEX buffering somehow to match this behaviour?

like image 225
slezica Avatar asked Jul 13 '26 02:07

slezica


1 Answers

Solved! This did the trick:

%option always-interactive

I'm leaving this here for future reference, in case... well, who knows.

like image 192
slezica Avatar answered Jul 14 '26 20:07

slezica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!