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
504 stars 85 forks source link

Inconsities in generated file names and documentation. #164

Closed SouravKB closed 1 year ago

SouravKB commented 1 year ago

Documented:

−−header-file[=FILE] This option generates a C++ header file FILE.h that declares the lexer class ...

Actual: This option generates a C++ header file FILE rather than FILE.h.


Documented:

−−tables-file[=FILE] This option generates a C++ file FILE.cpp with the finite state machine in source code form ...

Actual: This option generates a C++ file FILE if FILE ends with .cpp, otherwise generates FILE.cpp.


Documented:

−−regexp-file[=FILE] This option generates a text file FILE.txt that contains the scanner's regular expression patterns ...

Actual: This option generates a text file FILE if FILE ends with .txt, otherwise generates FILE.txt.


Documented:

−−graphs-file[=FILE] This option generates a Graphviz file FILE.gv ...

Actual: This option generates a Graphviz file FILE if FILE ends with .gv, otherwise generates FILE.gv.

SouravKB commented 1 year ago

The constants - REFLEX_OPTION_tables_file, REFLEX_OPTION_regexp_file, REFLEX_OPTION_graphs_file - in generated outfile always has the value of FILE, whereas the corresponding constants in generated header-file has the value of actual generated file names (FILE[.cpp], FILE[.txt], FILE[.gv]).

SouravKB commented 1 year ago

My personal suggestion would be to always use FILE as generated file name. Though it may not be possible to change that now as it may break existing projects.

genivia-inc commented 1 year ago

Documented:

−−tables-file[=FILE] This option generates a C++ file FILE.cpp with the finite state machine in source code form ...

Actual: This option generates a C++ file FILE if FILE ends with .cpp, otherwise generates FILE.cpp.

When the extension is the default like .cpp, then here is no need to add an extension, which would produce files like FILE.cpp.cpp. So this is correct. Same for graphs-file and regexp-file. This is logical and doesn't need further explanation.

The header-file should add a .h if not provided, but that appears not to be the case so I'll check the logic to correct this.

genivia-inc commented 1 year ago

BTW. The fact that header-file doesn't add the extension is because Flex doesn't and RE/flex is largely backward compatible to Flex. The same applies to option outfile that behaves the same as Flex, i.e. no extension. The other options are new and do not require an extension, but if one is given it must be of the right type corresponding to the type of output.

SouravKB commented 1 year ago

In that convention, outfile should also add .cpp extension if not present in FILE.

You can add .hpp extension to header-file and .cpp extension to outfile only when %o flex is not specified. Much like how other backward comapatibilty featues work.

SouravKB commented 1 year ago

The constants - REFLEX_OPTION_tables_file, REFLEX_OPTION_regexp_file, REFLEX_OPTION_graphs_file - in generated outfile always has the value of FILE, whereas the corresponding constants in generated header-file has the value of actual generated file names (FILE[.cpp], FILE[.txt], FILE[.gv]).

You haven't said anything about this!