pub struct Grammar { /* private fields */ }Expand description
The rule table read out of the embedded grammar text (see
grammar_text).
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn load() -> Grammar
pub fn load() -> Grammar
Read the embedded css-grammar.jsonic.
§Panics
If the embedded text is malformed. That is a build-time defect in this
crate, not anything a caller can provoke, and tests/grammar.rs fails
the build before it can ship.
Sourcepub fn parse(text: &str) -> Result<Grammar, String>
pub fn parse(text: &str) -> Result<Grammar, String>
Read a grammar document in the jsonic subset described above.
A key this reader does not implement is an ERROR, at every level.
The canonical ports hand the whole document to an engine that
understands the full jsonic grammar surface; this port implements the
part css-grammar.jsonic uses, and the two can only stay in step if
the grammar growing a field the machine does not run stops the build.
Ignoring it would leave the Rust port parsing a DIFFERENT grammar from
the one the other two runtimes run, with every suite green.