Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable ECHO() for unmatched characters in lex

Tags:

lex

I need to disable flex output for unmatched characters. I can't disable this by default ECHO(), can't disable yyout. Any variants?

like image 488
freakz Avatar asked Feb 14 '23 09:02

freakz


2 Answers

The creators of lex have provided a much simpler, more maintainable method. Add the following matching rules at the end of all your other rules:

[ \t\n]+          /* do nothing */
.+                /* do nothing */
like image 188
David Gorsline Avatar answered Mar 12 '23 07:03

David Gorsline


I've found the solution. When you compile with gcc/g++, you have to add the option '-DECHO'. So the 'ECHO' macro will be defined and the program will not print anything.

like image 39
pirobtumen Avatar answered Mar 12 '23 07:03

pirobtumen