pub struct Grammar {
pub name: String,
pub rules: Vec<(String, Rule)>,
pub extras: Vec<Rule>,
pub precedences: Vec<Vec<PrecedenceEntry>>,
pub conflicts: Vec<Vec<String>>,
pub externals: Vec<Rule>,
pub inline: Vec<String>,
pub supertypes: Vec<String>,
pub word: Option<String>,
pub reserved: Vec<(String, Vec<Rule>)>,
pub inherits: Option<String>,
}Expand description
Complete tree-sitter grammar.
Fields§
§name: StringGrammar name (e.g., “javascript”, “rust”).
rules: Vec<(String, Rule)>Production rules, preserving definition order.
extras: Vec<Rule>Extra/trivia nodes (comments, whitespace).
precedences: Vec<Vec<PrecedenceEntry>>Precedence orderings.
conflicts: Vec<Vec<String>>Expected conflicts.
externals: Vec<Rule>External scanner tokens.
inline: Vec<String>Rules to inline (hidden).
supertypes: Vec<String>Supertype rules.
word: Option<String>Keyword identifier rule.
reserved: Vec<(String, Vec<Rule>)>Reserved word contexts.
inherits: Option<String>Parent grammar name (for inheritance).
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn from_binary(bytes: &[u8]) -> Result<Self, GrammarError>
pub fn from_binary(bytes: &[u8]) -> Result<Self, GrammarError>
Deserialize grammar from binary format.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Grammar
impl<'de> Deserialize<'de> for Grammar
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Grammar
impl RefUnwindSafe for Grammar
impl Send for Grammar
impl Sync for Grammar
impl Unpin for Grammar
impl UnwindSafe for Grammar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more