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) -> ParserState
pub fn new(file_name: String, source_text: String) -> ParserState
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.
Auto Trait Implementations§
impl Freeze for ParserState
impl RefUnwindSafe for ParserState
impl Send for ParserState
impl Sync for ParserState
impl Unpin for ParserState
impl UnsafeUnpin for ParserState
impl UnwindSafe for ParserState
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more