Abhay Mittal
Abhay Mittal

Reputation: 33

Flex does not recognize patterns of type (?r-s:pattern)

I have flex version 2.5.4 installed.

Whenever i input a flex program of the form:

%{
#include<stdio.h>
%}
%%
(?i:foo) printf("foo found");
%%

I get unrecognized rule error on the line (?i:foo) ...

Please let me know what I am doing wrong.

Thanks

Upvotes: 1

Views: 110

Answers (1)

rici
rici

Reputation: 241721

If you want to use pattern flags, you need to upgrade your version of flex. The pattern syntax (?i:...) was added in version 2.5.35 (but you might as well update to the current version, 2.5.39).

Note: ubuntu has two flex packages: flex and flex-old. Logically, flex-old is an older version of flex (2.5.4, in fact). I don't know under what circumstances an ubuntu installation will contain the outdated flex, but if you find yourself with flex-old installed, you should be able to replace it with flex using apt-get install.

Upvotes: 1

Related Questions