Skip to main content

reconstruct_grammar

Function reconstruct_grammar 

Source
pub fn reconstruct_grammar(
    executable: &str,
    metadata: &str,
    import: Option<GrammarImportFn<'_>>,
) -> Result<Grammar, GrammarLoweringError>
Expand description

Reconstructs the original grammar from an executable text and its lowering metadata.

The executable is imported, every renamed rule gets its original name back, every helper reference is replaced with the original expression the metadata records, the helpers are removed and the rule kinds and documentation the target did not keep, the rule fields and the grammar declarations are restored. import replaces the format’s own importer.

§Errors

Returns a GrammarLoweringError for malformed metadata, an importer error or an executable without a rule the metadata names.