pub enum ParseTreeStackEntry<'t> {
Nd(Node<ParseTreeType<'t>>),
Id(NodeId),
}Expand description
The type of elements in the parser’s parse tree stack.
- ‘Nd’ references nodes not yet inserted into the parse tree.
- ‘Id’ holds node ids to nodes that are already part of the parse tree.
Variants§
Nd(Node<ParseTreeType<'t>>)
The node is not inserted into the parse tree yet. Thus we can access it directly.
Id(NodeId)
The node is already inserted into the parse tree. Wee need to lookup the node in the parse tree via the NodeId.
Implementations§
source§impl<'t> ParseTreeStackEntry<'t>
impl<'t> ParseTreeStackEntry<'t>
sourcepub fn get_parse_tree_type<'a, 'b>(
&'a self,
parse_tree: &'b Tree<ParseTreeType<'t>>
) -> &'a ParseTreeType<'_>where
'b: 'a,
pub fn get_parse_tree_type<'a, 'b>(
&'a self,
parse_tree: &'b Tree<ParseTreeType<'t>>
) -> &'a ParseTreeType<'_>where
'b: 'a,
Abstracts from the actual place where the node exists and returns the inner ParseTreeType.
'a refers to the lifetime of self.
'b refers to the lifetime of the parse tree.
sourcepub fn token<'a, 'b>(
&'a self,
parse_tree: &'b Tree<ParseTreeType<'t>>
) -> Result<&'a Token<'t>, ParserError>where
'b: 'a,
pub fn token<'a, 'b>(
&'a self,
parse_tree: &'b Tree<ParseTreeType<'t>>
) -> Result<&'a Token<'t>, ParserError>where
'b: 'a,
Tries to access the Token of the ParseTreeStackEntry. Can fail if the entry is no terminal (i.e. a non-terminal).
'a refers to the lifetime of self.
'b refers to the lifetime of the parse tree.
't refers to the lifetime of the scanned text.
sourcepub fn text<'a, 'b>(
&'a self,
parse_tree: &'b Tree<ParseTreeType<'_>>
) -> Result<&'a str, ParserError>where
'b: 'a,
pub fn text<'a, 'b>(
&'a self,
parse_tree: &'b Tree<ParseTreeType<'_>>
) -> Result<&'a str, ParserError>where
'b: 'a,
Tries to access the text of the ParseTreeStackEntry. Can fail if the entry is no terminal (i.e. a non-terminal).
'a refers to the lifetime of self.
'b refers to the lifetime of the parse tree.