pub struct Grammar {
pub name: String,
pub version: String,
pub schema: RuleMap,
pub rules: BTreeMap<String, RuleMap>,
pub rule_common: RuleMap,
pub sections: BTreeMap<String, Spanned>,
}Expand description
The parsed grammar file.
Fields§
§name: StringThe name of the grammar: tramlines, then the name of the format
grammar laid on it.
version: StringThe grammar version.
schema: RuleMapThe schema vocabulary.
rules: BTreeMap<String, RuleMap>The rule maps under schema, by name.
rule_common: RuleMapThe rule-common keys.
sections: BTreeMap<String, Spanned>The sections an extension adds beside schema, by name, as written.
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn accepts_common(&self, name: &str) -> bool
pub fn accepts_common(&self, name: &str) -> bool
Whether name is a rule map that accepts the rule-common keys.
Sourcepub fn base(&mut self, text: &str) -> Result<(), Error>
pub fn base(&mut self, text: &str) -> Result<(), Error>
Lay a format grammar on this one, the core grammar: it names
itself with grammar and its base with base, and adds keys, rule
maps, values of an enum, block kinds a key requires, text of a
doc, and the constraint groups of any rule map. A format grammar
that changes what the core grammar says is a defect of the build.
Sourcepub fn extend(&mut self, text: &str) -> Result<(), Error>
pub fn extend(&mut self, text: &str) -> Result<(), Error>
Add a host’s extension, which names itself with extension and
names the format grammar it extends with extends: keys, rule maps
and sections of its own; on a key of the grammar, more enum
values, more block kinds it requires, and more doc. An extension
that changes what the grammar says is a defect of the build.