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

Comments

Projects
None yet
2 participants
@waywardmonkeys
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@dragostis

dragostis Feb 19, 2018

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@waywardmonkeys

waywardmonkeys Feb 19, 2018

Contributor

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

Contributor

waywardmonkeys commented Feb 19, 2018

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

@dragostis

This comment has been minimized.

Show comment
Hide comment
@dragostis

dragostis Feb 19, 2018

Collaborator

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.

Collaborator

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