Next: , Previous: , Up: flex   [Contents][Index]


20 Incompatibilities with Lex and Posix

flex is a rewrite of the AT&T Unix lex tool (the two implementations do not share any code, though), with some extensions and incompatibilities, both of which are of concern to those who wish to write scanners acceptable to both implementations. flex is fully compliant with the POSIX lex specification, except that when using %pointer (the default), a call to unput() destroys the contents of yytext, which is counter to the POSIX specification. In this section we discuss all of the known areas of incompatibility between flex, AT&T lex, and the POSIX specification. flex’s ‘-l’ option turns on maximum compatibility with the original AT&T lex implementation, at the cost of a major loss in the generated scanner’s performance. We note below which incompatibilities can be overcome using the ‘-l’ option. flex is fully compatible with lex with the following exceptions:

The following flex features are not included in lex or the POSIX specification:

The feature “multiple actions on a line” refers to the fact that with flex you can put multiple actions on the same line, separated with semi-colons, while with lex, the following:

    foo    handle_foo(); ++num_foos_seen;

is (rather surprisingly) truncated to

    foo    handle_foo();

flex does not truncate the action. Actions that are not enclosed in braces are simply terminated at the end of the line.


Next: Memory Management, Previous: Reentrant C Scanners, Up: flex   [Contents][Index]