Struct Parser
pub struct Parser {
pub metadata: AstMetadata,
/* private fields */
}Expand description
The parser interprets tokens produced by the lexer to generate an abstract syntax tree.
Fields§
§metadata: AstMetadataImplementations§
§impl Parser
impl Parser
pub fn new(tokens: Vec<Token>) -> Self
pub fn new(tokens: Vec<Token>) -> Self
Creates a new parser which consumes the given vector of tokens.
pub fn get_identifier_if_declared_in_current_scope(
&self,
identifier: &str,
) -> Option<&DeclaredIdentifier>
pub fn get_identifier_if_declared_in_current_scope( &self, identifier: &str, ) -> Option<&DeclaredIdentifier>
Gets the metadata for the given identifier, if the identifier has been declared in the current scope. Otherwise
returns None.
pub fn get_identifier_if_visible_from_current_scope(
&self,
identifier: &str,
) -> Option<&DeclaredIdentifier>
pub fn get_identifier_if_visible_from_current_scope( &self, identifier: &str, ) -> Option<&DeclaredIdentifier>
Gets the metadata for the given identifier, if the identifier has been declared and is visible from the current
scope. Otherwise returns None.
pub fn current_enclosing_statement(&self) -> Option<EnclosingStatementChain>
pub fn current_enclosing_switch_statement_id(&self) -> Option<AstNodeId>
pub fn current_enclosing_switch_statement_id(&self) -> Option<AstNodeId>
The ID of the enclosing switch statement node, or None.
A switch statement may have other statements, like loops, inside it and this method will still return the ID of the enclosing switch statement node.
pub fn with_new_scope<F, R>(&mut self, f: F) -> R
pub fn with_new_scope<F, R>(&mut self, f: F) -> R
Runs the given closure after creating a new Symbol Table scope.
pub fn with_enclosing_statement<F, R>(
&mut self,
new_enclosing_stmt: EnclosingStatement,
f: F,
) -> R
pub fn with_enclosing_statement<F, R>( &mut self, new_enclosing_stmt: EnclosingStatement, f: F, ) -> R
Runs the given closure after capturing the id of the enclosing loop or switch statement.
pub fn disable_diagnostics_during<F, R>(
&mut self,
driver: &mut Driver,
f: F,
) -> R
pub fn disable_diagnostics_during<F, R>( &mut self, driver: &mut Driver, f: F, ) -> R
Runs the given closure without allowing any diagnostics to be recorded.
pub fn restore_token_stream_after<F, R>(&mut self, f: F) -> R
pub fn restore_token_stream_after<F, R>(&mut self, f: F) -> R
Runs the given closure and then restores the TokenStream to its original position before the closure.