Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making flex re-entrant and releasing all acquired resources at the end #675

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mingodad
Copy link

@mingodad mingodad commented Oct 3, 2024

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 the src folder and issue this command make fix-parse then again make and make check to see hopefully all tests passing.

@Mightyjo
Copy link
Contributor

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.

@westes
Copy link
Owner

westes commented Oct 23, 2024

Please let us know when your build process runs successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants