Genivia / RE-flex

A high-performance C++ regex library and lexical analyzer generator with Unicode support. Extends Flex++ with Unicode support, indent/dedent anchors, lazy quantifiers, functions for lex and syntax error reporting and more. Seamlessly integrates with Bison and other parsers.
https://www.genivia.com/doc/reflex/html
BSD 3-Clause "New" or "Revised" License
522 stars 85 forks source link

Incorrect documentation #116

Closed jafl closed 3 years ago

jafl commented 3 years ago

To combine multiple lexers in one application, use the −−lexer=NAME option.

This doesn't work for me because the symbol reflex_code_INITIAL is defined as extern in the generated source, and every lexer has it. Only by using namespaces can I successfully run the linker.

Robert-van-Engelen commented 3 years ago

The option does what it says: it names the lexer class. It does not claim that code will be separable, since you'll need C++ namespaces for that or use option -P to specify a prefix.

There is also no problem to include header files in practice. They do specify the options used, which will be undef-defined if multiple header files are included. In between these includes, you can extract the REFLEX_OPTION value's you need, if any.

I can only see that perhaps -P should apply to REFLEX_code_INITIAL -> REFLEX_PREFIX_code_INITIAL, since it needs to be globally accessible when -P is used instead of C++ namespaces.

jafl commented 3 years ago

That would work. It would have to be for all of them, however, not just INITIAL. I have multiple lexers in the same program that have the same state names.

genivia-inc commented 3 years ago

Fixed.