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

Include a variable in the parser state #136

Open
alexflint opened this issue Oct 28, 2023 · 1 comment
Open

Include a variable in the parser state #136

alexflint opened this issue Oct 28, 2023 · 1 comment

Comments

@alexflint
Copy link

Is there any way that I can pass a variable into each of the bits of Go code that handle parse results in my grammar file? I would like to pass an io.Writer and write to it from inside the handlers in my grammar file. I don't want it to be a global variable, though.

@breml
Copy link
Collaborator

breml commented Oct 30, 2023

Hi @alexflint

There is a feature called globalStore which does provide what you are looking for. Search the documentation on https://pkg.go.dev/github.com/mna/pigeon for this keyword or have a look at the example in https://github.com/mna/pigeon/tree/master/test/global_store.

I hope this helps.

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