Parser

Struct Parser 

Source
pub struct Parser<'tokens, 'source: 'tokens> { /* private fields */ }

Implementations§

Source§

impl<'tokens, 'source: 'tokens> Parser<'tokens, 'source>

Source

pub fn new(tokens: &'tokens [Loc<Token<'source>>]) -> Self

Source

pub fn diagnostics(&self) -> &[Diagnostic]

Source

pub fn is_eof(&self) -> bool

Source

pub fn eof_span(&self) -> Span

Source

pub fn get(&self, offset: isize) -> Option<&Loc<Token<'source>>>

Source

pub fn is_at(&self, pattern: &Token<'_>) -> bool

Source

pub fn next_is(&self, pattern: &Token<'_>) -> bool

Source

pub fn advance(&mut self)

Source

pub fn try_eat(&mut self, pattern: Token<'_>) -> Option<Loc<Token<'source>>>

Source

pub fn eat<'a>( &mut self, pattern: impl TokenPattern<'a>, message: impl Into<String>, ) -> Result<Loc<Token<'source>>>

Source

pub fn skip_newlines(&mut self)

Source

pub fn recover( &mut self, goals: impl IntoIterator<Item = Token<'source>>, message: impl Into<String>, )

Source

pub fn parse_separated<'a, U, F: FnMut(&mut Self) -> Result<U>>( &mut self, f: F, separators: impl TokenPattern<'a>, terminators: impl TokenPattern<'a>, message: impl Into<String>, ) -> Result<(Vec<U>, Loc<Token<'source>>)>

Source

pub fn parse_local_name( &mut self, message: impl Into<String>, ) -> Result<Loc<&'source str>>

Source

pub fn parse_imported_function_alias( &mut self, as_token: Loc<()>, ) -> Result<Loc<ImportedFunctionAlias<'source>>>

Source

pub fn parse_imported_function( &mut self, ) -> Result<Loc<ImportedFunction<'source>>>

Source

pub fn parse_import( &mut self, from_token: Loc<()>, ) -> Result<Loc<Import<'source>>>

Source

pub fn parse_label(&mut self) -> Result<Loc<Label<'source>>>

Source

pub fn parse_constant_value(&mut self) -> Result<Loc<ConstantValue>>

Source

pub fn parse_constant( &mut self, name: Loc<&'source str>, type_annotation: Option<Loc<TypeAnnotation>>, equals_token: Loc<()>, const_token: Loc<()>, ) -> Result<Loc<Constant<'source>>>

Source

pub fn parse_value_operation_op( &mut self, op_name: Loc<&'source str>, ) -> Result<Loc<ValueOperationOp<'source>>>

Source

pub fn parse_value_operation( &mut self, name: Loc<&'source str>, type_annotation: Option<Loc<TypeAnnotation>>, equals_token: Loc<()>, op_name: Loc<&'source str>, ) -> Result<Loc<ValueOperation<'source>>>

Source

pub fn parse_effect_operation_op( &mut self, ) -> Result<Loc<EffectOperationOp<'source>>>

Source

pub fn parse_effect_operation( &mut self, ) -> Result<Loc<EffectOperation<'source>>>

Source

pub fn parse_instruction(&mut self) -> Result<Loc<Instruction<'source>>>

Source

pub fn parse_function_code(&mut self) -> Result<Loc<FunctionCode<'source>>>

Source

pub fn parse_type(&mut self) -> Result<Loc<Type>>

Source

pub fn parse_type_annotation(&mut self) -> Result<Loc<TypeAnnotation>>

Source

pub fn parse_function_parameter( &mut self, ) -> Result<(Loc<&'source str>, Loc<TypeAnnotation>)>

Source

pub fn parse_function( &mut self, name: Loc<&'source str>, ) -> Result<Loc<Function<'source>>>

Source

pub fn parse_program(&mut self) -> Result<Program<'source>>

Auto Trait Implementations§

§

impl<'tokens, 'source> Freeze for Parser<'tokens, 'source>

§

impl<'tokens, 'source> RefUnwindSafe for Parser<'tokens, 'source>

§

impl<'tokens, 'source> Send for Parser<'tokens, 'source>

§

impl<'tokens, 'source> Sync for Parser<'tokens, 'source>

§

impl<'tokens, 'source> Unpin for Parser<'tokens, 'source>

§

impl<'tokens, 'source> UnwindSafe for Parser<'tokens, 'source>

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.
Source§

impl<T> WithLocation for T

Source§

fn at(self, spanned: impl Spanned) -> Loc<Self>
where Self: Sized,

Source§

fn between(self, start: impl Spanned, end: impl Spanned) -> Loc<Self>
where Self: Sized,