Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replace escape character in flex

Tags:

flex-lexer

I use flex to work on a scanner to replace \" with "; and \\ with \.

so my code is like

%%
\\"    \";
\\\    \\;

but when I compile, I get an error message like missing quote. I think it's the right regular expression, did I get wrong or it's something special with flex?

like image 523
FloydChen Avatar asked May 24 '26 05:05

FloydChen


1 Answers

You should escape both the \ AND " character. In order to match \" you use \\\" not \\". To match \\ you use \\\\ not \\\.

Another thing is that flex matches a regexp and then execute the C code you placed in the associated action. Your example doesn't look like correct flex statements.

like image 58
fjardon Avatar answered May 27 '26 19:05

fjardon



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!