bisonflex-lexercortex-mbare-metal

flex/bison for embedded bare-metal system


I develop software for Cortex M, and for that I use Arm GNU Toolchain.
I need to parse data packages for which I have the grammar.

I have problems with flex though, since it normally requires the libfl.a library which I don't have compiled for cortex M.

How can I get around this problem (other than recompiling just the libfl.a for cortex M)? Maybe some flex parameters?

Also, this raises other doubts for me, since my system is bare-metal:

so I wonder if, even overcoming the libfl.a problem, flex and bison would have problems with the constraints mentioned above.


Solution

  • libfl.a only defines main and yywrap. So if you don't need either of those (because you have you own main and you either use %option noyywrap or you have your own yywrap), you don't need libfl.a

    However, scanners generated by flex do need malloc/realloc from the C library, so if you don't have that, you'll need to supply a replacement. The default YY_INPUT/ECHO macros also use stdio, so you'll need to redefine (or not use) them if you want to avoid that part of the standard library.