pest
pest copied to clipboard
Please add an example on how to define multiple `Parser` structs in the same crate
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.
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.
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.