Flex is somewhat a free implementation of Lex program, although there are some incompatibilities between them.
For instance Lex store the current line into a global variable yylineno whereas in flex to access it you should add in the code %option yylineno .
Is possible to write portable code knowing that %option tag is not recognized by Lex?
Update :
lex: Software Generation Utilities (SGU) Solaris-ELF (4.0)
flex version 2.5.2
I almost found the solution in this case, According To this link, to activate the global variable yylineno you should add -l option when executing flex so you don’t have to add the %option in the code,so you will have a compatible code between flex and lex .