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: AstMetadata

Implementations§

§

impl Parser

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>

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>

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>

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
where F: FnOnce(&mut Parser) -> 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
where F: FnOnce(&mut Parser) -> 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
where F: FnOnce(&mut Parser, &mut Driver) -> 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
where F: FnOnce(&mut Parser) -> R,

Runs the given closure and then restores the TokenStream to its original position before the closure.

Auto Trait Implementations§

§

impl Freeze for Parser

§

impl RefUnwindSafe for Parser

§

impl Send for Parser

§

impl Sync for Parser

§

impl Unpin for Parser

§

impl UnwindSafe for Parser

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.