Home > Net >  Flex: unrecognized rule `(?s:.)`
Flex: unrecognized rule `(?s:.)`

Time:01-02

In my flex program, I am unable to use any of these regex. Usage of any of them are generating unrecognized rule error.

%{
#include<stdio.h>
%}

%option nodefault
%option noyywrap
%option outfile="scanner.c"

%%

(?i:a) printf("rule1");

(?s:.) printf("rule2");

(?x:a b) printf("rule3");

(?#foo) printf("rule4");

[a-z]{-}[aeiou] printf("rule5");

%%

All of these are well defined in this docs. I am confused, whether I am using wrong variant of flex! I am using windows machine with GnuWin32 flex v2.5.4.

This is the error being generated:

$flex misc/test_lexer.l
"misc/test_lexer.l", line 11: unrecognized rule
"misc/test_lexer.l", line 11: unrecognized rule
"misc/test_lexer.l", line 11: unrecognized rule
"misc/test_lexer.l", line 11: unrecognized rule
"misc/test_lexer.l", line 11: unrecognized rule
"misc/test_lexer.l", line 11: unrecognized rule
"misc/test_lexer.l", line 13: unrecognized rule
"misc/test_lexer.l", line 13: unrecognized rule
"misc/test_lexer.l", line 13: unrecognized rule
"misc/test_lexer.l", line 13: unrecognized rule
"misc/test_lexer.l", line 13: unrecognized rule
"misc/test_lexer.l", line 13: unrecognized rule
"misc/test_lexer.l", line 15: unrecognized rule
"misc/test_lexer.l", line 15: unrecognized rule
"misc/test_lexer.l", line 15: unrecognized rule
"misc/test_lexer.l", line 15: unrecognized rule
"misc/test_lexer.l", line 15: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 17: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule
"misc/test_lexer.l", line 19: unrecognized rule

CodePudding user response:

You need to update your flex installation if you want to use those constructs.

Flex 2.5.4, which was released more than 25 years ago, does not implement {-} nor does it implement any of the (?:...) syntaxes.

The manual you cite, which is also not the current version, specifies:

This edition of The flex Manual documents flex version 2.6.3. It was last updated on 13 January 2017.

Flex v2.5.4 did implement the / trailing context operator, which was in the original version of this question. But note that / cannot be used inside parentheses, and since flex normally adds parentheses around macro expansions, / cannot be used in a macro expansion either.

  • Related