Open mingodad opened 1 month ago
Flex itself is a compiler-like tool. It isn't meant to be re-entrant. The code it generates is re-entrant, though.
We collected the state into structures a few years ago. That was good. I'm not seeing the value in allocating that state dynamically and changing every prototype in the code base.
Please let us know when your build process runs successfully.
This is an experiment that replace all globals by a dynamic allocated structure to hold the state that is passed everywhere and also releasing all acquired resources (memory/file handles) at the end.
The main drive behind this changes is to create something like https://mingodad.github.io/parsertl-playground/playground/ using this fork and https://github.com/mingodad/lalr-parser-test/tree/main/byacc (also with globals replaced) or doing a similar work with bison.
If anything here is useful to the original project feel free to grab it.
All tests are passing.
If someone want to try build this branch be aware that the build will fail when trying to parse the generated
parse.c
at that point you need to change to thesrc
folder and issue this commandmake fix-parse
then againmake
andmake check
to see hopefully all tests passing.