flex icon indicating copy to clipboard operation
flex copied to clipboard

Make C++ lexers standalone: please no requirement on system's FlexLexer.h

Open dcolascione opened this issue 3 years ago • 2 comments

I'm writing a program using flex that supports cross-compilation between architectures. I'm using the C++ lexer mode. I'm generally happy with it, except for the way that the generated lexer uses #include <FlexLexer.h> and doesn't provide a FlexLexer.h --- the header needs to come from the system, and in the cross-compilation case, we may end up including the wrong FlexLexer.h or fail to find the header at all.

Can we just change the C++ lexer to include the contents of FlexLexer.h directly in the generated code so that it's nice and standalone?

dcolascione avatar Apr 21 '21 14:04 dcolascione

A couple of PRs that will make this possible are in the pipeline. It's been a challenge in the past because so much C was emitted from Flex's compiled code. We'll soon be able to choose the output language and customize the skeleton to match so we won't need the separate C++ header anymore.

In the meantime, when I'm in your situation I copy the system's FlexLexer.h into my source tree and add its include path. It's not a perfect solution.

If memory serves, the default system header is in /use/share/include. Most of the packaged versions I've used install it under /usr/share too.

Mightyjo avatar May 03 '21 11:05 Mightyjo

And the retargeting stuff is merged in, so does the current tip of master do what you need?

westes avatar Jul 08 '21 00:07 westes