pub struct ASTNode {
pub children: Option<Vec<ASTNode>>,
pub token_count: u32,
pub text: u32,
}Expand description
AST node. Grammar rules have children, tokens do not.
The total structure of the AST is defined by the grammar that it was parsed with.
Fields§
§children: Option<Vec<ASTNode>>If Some, this node is a parent/nonterminal. If None, this node is a token/leaf/terminal.
token_count: u32Due to error recovery, AST nodes can be marked as “poisoned”.
When a node is poisoned, its token count is XOR’d with !0u32 (all one-bits).
text: u32Index into grammar.string_cache_inv, giving an Rc<String>.
For parents, it’s the name of the associated grammar rule.
For tokens, it’s the token content (the actual token contents, but what it was matched with, i.e. it’s not a regex).
Implementations§
Source§impl ASTNode
impl ASTNode
pub fn is_poisoned(&self) -> bool
pub fn get_real_token_count(&self) -> u32
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ASTNode
impl RefUnwindSafe for ASTNode
impl Send for ASTNode
impl Sync for ASTNode
impl Unpin for ASTNode
impl UnwindSafe for ASTNode
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