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

Please add an example on how to define multiple Parser structs in the same crate #335

Closed
lucatrv opened this issue Nov 8, 2018 · 2 comments · Fixed by #730
Closed

Please add an example on how to define multiple Parser structs in the same crate #335

lucatrv opened this issue Nov 8, 2018 · 2 comments · Fixed by #730

Comments

@lucatrv
Copy link

lucatrv commented Nov 8, 2018

As in subject, I am struggling to understand how to define multiple Parser structs in the same crate, each one relying on its own grammar file.

@CAD97
Copy link
Contributor

CAD97 commented Nov 9, 2018

Due to the fact that the current derive spills the Rule enum into the same namespace, the parsers need to be in different namespaces. However, the following should work:

mod a {
    #[derive(Parser)]
    #[grammar = "a.pest"]
    pub struct Parser;
}
mod b {
    #[derive(Parser)]
    #[grammar = "b.pest"]
    pub struct Parser;
}

You then have a::Parser/a::Rule and b::Parser/b::Rule.

@lucatrv
Copy link
Author

lucatrv commented Nov 9, 2018

This works, thanks for your hint! However if you agree I would keep this issue open, as in my opinion a similar example should be reported in the pest book.

@dragostis dragostis added this to the Under the hood milestone Nov 15, 2018
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau added a commit that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes #335
Closes #299
Closes #298
Closes #297
Closes #185

Co-authored-by: Tomas Tauber <me@tomtau.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants