pub struct ParserState {
pub arena: NodeArena,
pub context_flags: u32,
/* private fields */
}Expand description
This parser produces the same AST semantically as ParserState,
but uses the cache-optimized NodeArena for storage.
Fields§
§arena: NodeArenaArena for allocating Nodes
context_flags: u32Parser context flags
Implementations§
Source§impl ParserState
impl ParserState
Sourcepub fn new(file_name: String, source_text: String) -> Self
pub fn new(file_name: String, source_text: String) -> Self
Create a new Parser for the given source text.
pub fn reset(&mut self, file_name: String, source_text: String)
Sourcepub fn parse_optional(&mut self, kind: SyntaxKind) -> bool
pub fn parse_optional(&mut self, kind: SyntaxKind) -> bool
Parse optional token, returns true if found
Sourcepub fn parse_expected(&mut self, kind: SyntaxKind) -> bool
pub fn parse_expected(&mut self, kind: SyntaxKind) -> bool
Parse expected token, report error if not found
Suppresses error if we already emitted an error at the current position
(to prevent cascading errors from sequential parse_expected calls)
Sourcepub fn parse_error_at_current_token(&mut self, message: &str, code: u32)
pub fn parse_error_at_current_token(&mut self, message: &str, code: u32)
Report parse error at current token with specific error code
Source§impl ParserState
impl ParserState
pub fn parse_expression(&mut self) -> NodeIndex
Source§impl ParserState
impl ParserState
Sourcepub fn parse_source_file(&mut self) -> NodeIndex
pub fn parse_source_file(&mut self) -> NodeIndex
Parse a source file
pub fn parse_source_file_statements_from_offset( &mut self, file_name: String, source_text: String, start: u32, ) -> IncrementalParseResult
Sourcepub fn parse_statement(&mut self) -> NodeIndex
pub fn parse_statement(&mut self) -> NodeIndex
Parse a statement
Source§impl ParserState
impl ParserState
Sourcepub fn get_diagnostics(&self) -> &[ParseDiagnostic]
pub fn get_diagnostics(&self) -> &[ParseDiagnostic]
Get parse diagnostics
Sourcepub fn into_arena(self) -> NodeArena
pub fn into_arena(self) -> NodeArena
Consume the parser and return the arena. This is used for lib files where we need to store the arena in an Arc.
Sourcepub const fn get_node_count(&self) -> usize
pub const fn get_node_count(&self) -> usize
Get node count
Sourcepub fn get_source_text(&self) -> &str
pub fn get_source_text(&self) -> &str
Get the source text. Delegates to the scanner which owns the source text.
Sourcepub fn get_file_name(&self) -> &str
pub fn get_file_name(&self) -> &str
Get the file name
Sourcepub fn into_parts(self) -> (NodeArena, Vec<ParseDiagnostic>)
pub fn into_parts(self) -> (NodeArena, Vec<ParseDiagnostic>)
Consume the parser and return its parts. This is useful for taking ownership of the arena after parsing.