Skip to main content

import_gbnf

Function import_gbnf 

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

Parses llama.cpp GBNF grammar text into the grammar IR.

The importer is a clean-room recursive-descent parser for the structural GBNF subset represented by the grammar IR: rules, unordered alternation, grouping, postfix repetition, string literals, and character classes.

ยงErrors

Returns GrammarImportError when the source cannot be parsed as GBNF or when the required root rule is missing.