I have two similar but different enough inputs formats and would like to build two different scanners for these, using GNU Flex.
My two options are
make one big definition, with two separate start conditions. This requires me to keep track of what kind of file I'm scanning, because the common rules need to exit into the correct start condition afterwards.
write two definitions and include the common aspects from a common file. Because Flex does not have a facility for including source files, this loses line number information and makes debugging more difficult.
Is there a third approach I'm not seeing that allows me to share definitions, but also retains correct line number information for the original source files?