Go to the previous, next section.

Incompatibilities with lex and POSIX

flex is a rewrite of the Unix tool lex (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 either implementation. At present, the POSIX lex draft is very close to the original lex implementation, so some of these incompatibilities are also in conflict with the POSIX draft. But the intent is that except as noted below, flex as it presently stands will ultimately be POSIX conformant (i.e., that those areas of conflict with the POSIX draft will be resolved in flex's favor). Please bear in mind that all the comments which follow are with regard to the POSIX draft standard of Summer 1989, and not the final document (or subsequent drafts); they are included so flex users can be aware of the standardization issues and those areas where flex may in the near future undergo changes incompatible with its current definition.

flex is fully compatible with lex with the following exceptions:

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

#line directives
`%{}' around actions
comments beginning with `#' (deprecated)
multiple actions on a line

This last feature refers to the fact that with flex you can put multiple actions on the same line, separated with semicolons, 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.

Go to the previous, next section.