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

Sharing rules between grammars? #197

Open
waywardmonkeys opened this issue Feb 19, 2018 · 3 comments
Open

Sharing rules between grammars? #197

waywardmonkeys opened this issue Feb 19, 2018 · 3 comments

Comments

@waywardmonkeys
Copy link
Contributor

@waywardmonkeys waywardmonkeys commented Feb 19, 2018

I have a few grammars for related formats / languages that share some common rules. Is there a way to readily share rules between separate grammar files?

It wouldn't make sense to just have a single big grammar file.

In nom, I would be able to define new combinators that I'd use for things like basic types and such.

@dragostis
Copy link
Collaborator

@dragostis dragostis commented Feb 19, 2018

Good point. There should be an import command in .pest files. This could be added in 1.1. Let me know if you want to tackle it.

@dragostis dragostis added this to the v1.1 milestone Feb 19, 2018
@waywardmonkeys
Copy link
Contributor Author

@waywardmonkeys waywardmonkeys commented Feb 19, 2018

Could you provide a couple of getting started pointers and I will see if I can tackle it?

@dragostis
Copy link
Collaborator

@dragostis dragostis commented Feb 19, 2018

Of course. The necessary grammar should be added to meta. Probably something like use generic.pest would do well.

Then this should be somehow integrated into the parser and validator in the meta crate. I'm not completely sure what the best approach would be in this case. My current hunch is to do the actual importing in parser::convert_rules, where one could call parse and validate recursively, but this might not work and a change in architecture may be needed.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.