-
I'm trying to provide multiple grammars which have 1-to-1 mappings between them, which means I can map rules to rules between grammars, and I would like to map them all to a single grammar for processing, but I can't find a way to map between Just as a quick example, I could have two separate grammars: mod en {
#[derive(Parser, Clone, Copy)]
#[grammar = "english.pest"]
pub struct EnglishParser
}
mod es {
#[derive(Parser, Clone, Copy)]
#[grammar = "spanish.pest"]
pub struct SpanishParser
}
impl Into<en::Rule> for es::Rule {
// ...
}
fn translate<'a, R>(p: Pairs<'a, R>) -> Pairs<'a, en::Rule>
where
R: RuleType + Into<en::Rule>,
{
// how to implement this?
} Is there a way I can apply I've only seen examples of creating a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Just bumping this one. Still haven't figured out a good solution and would love some pointers if anyone has any ideas. |
Beta Was this translation helpful? Give feedback.
-
Would using |
Beta Was this translation helpful? Give feedback.
And is it needed to construct Pairs? What if instead you defined a custom (abstract?) syntax tree type and mapped all those language Pairs into it?