0

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])
...
Georgi Hristozov
  • 3,899
  • 2
  • 17
  • 23
  • 2
    Possible duplicate of [Flex seems do not support a regex lookahead assertion (the fast lex analyzer)](https://stackoverflow.com/questions/22326399/flex-seems-do-not-support-a-regex-lookahead-assertion-the-fast-lex-analyzer) – CAustin Apr 03 '19 at 23:58
  • 1
    Say the assertion don't work. What is it you're trying to accomplish ? –  Apr 04 '19 at 00:12
  • 3
    It's not a "strange bug"; it's just not a supported feature in flex's flavor of regex – CAustin Apr 04 '19 at 00:14
  • for the example I put simple expression. I actually need a complicated expression , but except for 2 or 3 characters. – נדב רובינשטיין Apr 04 '19 at 00:14
  • 1
    You should perhaps ask about how to accomplish your task within the constraints of flex regular expressions. – rici Apr 04 '19 at 14:56
  • and do you have an idea on how doing it? – נדב רובינשטיין Apr 05 '19 at 20:26
  • I don't know what you are trying to do, but if I knew I might well be able to help. So I suggest you ask a question about what you are trying to do rather than this one, which is about a non-existent feature which might, if it existed, help you do some unspecified computation. – rici Apr 06 '19 at 07:31
  • Also, see this explanation of comment notification: https://meta.stackexchange.com/a/43020/212668 – rici Apr 06 '19 at 07:37

0 Answers0