I tried to run 2 pieces of code on flex. The first code works fine. I changed only line 5 from "printable ([bc])" to "printable ((?!a)[abc])" which is exactly the same meaning, and the code failed with these errors:
...(lots of bad character errors)
ex.lex:21: bad character: %
ex.lex:21: bad character: %
ex.lex:21: EOF encountered inside pattern
ex.lex:21: unrecognized rule
ex.lex:21: fatal parse error
Any suggestions?
Thanks, Nadav
This code works:(didn't add the functions' declerations)
%}
%option noyywrap
letter [a-zA-Z]
lower [a-z]
printable ([bc])
%x COMMENT
%%
\/\* BEGIN(COMMENT);
<COMMENT>\/\* error(1);
<COMMENT>\*\/ BEGIN(INITIAL);
<COMMENT>{printable}* showToken("comment");
<COMMENT>. error(1);
@import showToken("import");
@ error(2);
. showToken("idk");
%%
This code doesn't work:
...
printable ((?!a)[abc])
...