Skip to main content

import_antlr

Function import_antlr 

Source
pub fn import_antlr(text: &str) -> Result<Grammar, GrammarImportError>
Expand description

Parses ANTLR v4 .g4 grammar text into the grammar IR.

The importer is a clean-room parser for the structural ANTLR grammar subset needed by the grammar IR. ANTLR alternatives are lowered as unordered CFG choices, while lexer commands and dropped target-language actions are preserved in rule documentation; -> skip and -> channel(NAME) also put the rule on that channel, which makes it trivia. EOF is the end of the input, and character sets read \uXXXX, \u{X...} and \p{NAME} for a general category or script.

ยงErrors

Returns GrammarImportError when the source cannot be parsed as the supported ANTLR subset or when a parsed prelude construct is recognized but not yet representable.