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

Ability to define two parsers from the same lexer #65

Open
fish-face opened this issue Dec 18, 2020 · 1 comment
Open

Ability to define two parsers from the same lexer #65

fish-face opened this issue Dec 18, 2020 · 1 comment

Comments

@fish-face
Copy link

If you define a lexer niml lexer[MyToken] and then two parsers nimy parserOne[MyToken] and nimy parserTwo[MyToken] you get an error due to a redefinition of the function parse (parsegen.nim:1001)

@loloicci
Copy link
Owner

loloicci commented Dec 19, 2020

@fish-face Thank you for the reporting! I won't fix this, but maybe I can help you.

nimy is designed as a macro to make the parsing table and define the function parse for the table.
So, if you define two parse in one module (with the same token type), these names are conflicted.

But, you can use two (or more) different nimy parser in one module if you define two (or more) parsers in two (or more) other modules.
https://github.com/loloicci/nimly/blob/master/tests/test_lr_lalr.nim is a good example to use two parsers in one module. (using https://github.com/loloicci/nimly/blob/master/tests/parser_415.nim and https://github.com/loloicci/nimly/blob/master/tests/parser_415_lr.nim)
Does it solve your problem?

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

No branches or pull requests

2 participants