Skip to main content

translate_grammar_surface

Function translate_grammar_surface 

Source
pub fn translate_grammar_surface(
    grammar: &Grammar,
    target_language: &str,
    rules: &TranslationRuleSet,
) -> Result<Grammar, GrammarTranslateError>
Expand description

Translates a grammar’s rule names and documentation into target_language.

The grammar algebra is preserved: expressions are cloned with only NonTerminal references rewritten to match renamed rules. Rules without an explicit concept and without a known source-language surface are left unchanged.

§Errors

Returns GrammarTranslateError::UnknownConcept when an explicitly aligned rule concept cannot be rendered by rules, or GrammarTranslateError::NameCollision when distinct rules would share one translated name.