pest
pest copied to clipboard
Sharing rules between grammars?
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.
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.
Could you provide a couple of getting started pointers and I will see if I can tackle it?
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.