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

Support parser rule includes/modules #198

Open
raehik opened this issue Aug 11, 2021 · 2 comments
Open

Support parser rule includes/modules #198

raehik opened this issue Aug 11, 2021 · 2 comments

Comments

@raehik
Copy link

raehik commented Aug 11, 2021

I'm working on some projects where we have multiple large Happy parsers, many of which reuse snippets or entire blocks of rules. We'd like to split some rules off into include-able files while staying platform-agnostic (I could easily solve it with some Bash, but then Windows will need its own solution, etc...). Having a Happy feature to allow "sharing" rules between parsers would help in refactoring larger parsers.

I've searched the internet and Happy code/docs and asked #haskell on Libera, but I'm not sure if there's any solution or precedent for this currently.

@Ericson2314
Copy link
Collaborator

Ericson2314 commented Aug 11, 2021

@int-index's and my long-term plan is to work on a Template-Haskell variant of happy that, among other benefits, should allow one to compute the grammar that is to be compiled at compile time however one likes. That ought to nail your use-case, but it will probably take a while as there some TH deficiencies to be fixed / worked around.

I would try to use C pre-processor in the meantime :(.

@raehik
Copy link
Author

raehik commented Aug 13, 2021

Thanks, great to hear. I wasn't sure if I could use Haskell's CPP extension, since I need to do it at parser generation, and Happy doesn't appear to run CPP (putting preprocessor directives in the rules section quickly gave me a parse error). It's only a maintainability problem, so we'll keep working around it while looking forward to the eventual improvements!

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

No branches or pull requests

2 participants