Previous: , Up: Appendices   [Contents][Index]


A.6 Deprecated interfaces, , Retargeting Flex

Long-time users of Flex and its predecessor, Lex, may notice that the examples in this manual look a little different than they used to. They have changed because of the support for targeting languages other than C/C++.

All the old interfaces are still in place for legacy C code to use. But some are now deprecated and should not be used in new code. Doing so will hinder forward portability someday.

These changes are necessary because the documented Flex interface can no longer rely on controlling scanner generation by defining preprocessor macros. Most languages other than C/C++ don’t have text macros, and none of those that do emulate C #define closely enough to preserve the behavior dependent on it. Thus interface calls in multi-language Flex need to be functions, at least syntactically (though many are still implemented as macros for C/C++).

A list of deprecated interfaces and their replacements follows. Again, all are still available in the default C/C++ back end, but not in any other.

Where entry point names have been downcased and had underscores removed, it’s because some languages in the expected target set for Flex - notably Go and Python - have validator/linter tools that would complain about uppercase or underscores or both. It would obviously be best if the parts of the public API that have to change to conform to local conventions are small and not commonly used.

This is also why the functions yy_current_buffer(), yy_flush_current_buffer(), and yy_set_interactive() do not have rewrite rules (see See option-rewrite); simply removing the underscores would have produced names that are uncomfortably long and hard on the eyeballs. We leave it to the API binding for each individual target language to choose whether they should be left as is, camel-cased, or otherwise adapted to local conventions.


Previous: Retargeting Flex, Up: Appendices   [Contents][Index]