Parser

Struct Parser 

Source
pub struct Parser<'a> {
    pub parse_stack: Vec<ParseStackEntry>,
    pub diags: DiagList,
    /* private fields */
}

Fields§

§parse_stack: Vec<ParseStackEntry>§diags: DiagList

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn expression(&mut self) -> Result<Loc<Expression>>

Source

pub fn non_comptime_expression(&mut self) -> Result<Loc<Expression>>

We need a function like this in order to not run into parser conflicts when parsing blocks, since both statements and expressions can start with $if.

Source§

impl<'a> Parser<'a>

Source§

impl<'a> Parser<'a>

Source

pub fn new(lex: Lexer<'a, TokenKind>, file_id: usize) -> Self

Source§

impl<'a> Parser<'a>

Source

pub fn identifier(&mut self) -> Result<Loc<Identifier>>

Source

pub fn path(&mut self) -> Result<Loc<Path>>

Source

pub fn named_turbofish(&mut self) -> Result<Loc<NamedTurbofish>>

Source

pub fn turbofish(&mut self) -> Result<Option<Loc<TurbofishInner>>>

Source

pub fn path_with_turbofish( &mut self, ) -> Result<Option<(Loc<Path>, Option<Loc<TurbofishInner>>)>>

Source

pub fn if_expression( &mut self, allow_stages: bool, ) -> Result<Option<Loc<Expression>>>

Source

pub fn type_level_if(&mut self) -> Result<Option<Loc<Expression>>>

Source

pub fn match_expression(&mut self) -> Result<Option<Loc<Expression>>>

Source

pub fn int_literal(&mut self) -> Result<Option<Loc<IntLiteral>>>

Source

pub fn block(&mut self, is_pipeline: bool) -> Result<Option<Loc<Block>>>

Source

pub fn pipeline_reference(&mut self) -> Result<Option<Loc<Expression>>>

Source

pub fn pipeline_stage_reference( &mut self, stage_keyword: &Token, ) -> Result<Option<Loc<Expression>>>

Source

pub fn pipeline_stage_status( &mut self, stage_keyword: &Token, ) -> Result<Option<Loc<Expression>>>

Source

pub fn type_expression(&mut self) -> Result<Loc<TypeExpression>>

Source

pub fn type_spec(&mut self) -> Result<Loc<TypeSpec>>

Source

pub fn tuple_spec(&mut self) -> Result<Option<Loc<TypeSpec>>>

Source

pub fn array_spec(&mut self) -> Result<Option<Loc<TypeSpec>>>

Source

pub fn name_and_type(&mut self) -> Result<(Loc<Identifier>, Loc<TypeSpec>)>

A name with an associated type, as used in argument definitions as well as struct definitions

name: Type

Source

pub fn pattern(&mut self) -> Result<Loc<Pattern>>

Source

pub fn statements( &mut self, allow_stages: bool, ) -> Result<(Vec<Loc<Statement>>, Option<Loc<Expression>>)>

Source

pub fn self_arg(&mut self) -> Result<Option<Loc<()>>>

Source

pub fn parameter( &mut self, ) -> Result<(AttributeList, Loc<Identifier>, Loc<TypeSpec>)>

Source

pub fn parameter_list(&mut self) -> Result<ParameterList>

Source

pub fn type_parameter_list(&mut self) -> Result<ParameterList>

Source

pub fn type_param(&mut self) -> Result<Loc<TypeParam>>

Source

pub fn generics_list(&mut self) -> Result<Option<Loc<Vec<Loc<TypeParam>>>>>

Source

pub fn generic_spec_list( &mut self, ) -> Result<Option<Loc<Vec<Loc<TypeExpression>>>>>

Source

pub fn path_with_generic_spec( &mut self, ) -> Result<(Loc<Path>, Option<Loc<Vec<Loc<TypeExpression>>>>)>

Source

pub fn unit_kind( &mut self, start_token: &Token, ) -> Result<Option<Loc<UnitKind>>>

Source

pub fn unit_head( &mut self, attributes: &AttributeList, ) -> Result<Option<Loc<UnitHead>>>

Source

pub fn impl_body(&mut self) -> Result<Vec<Loc<Unit>>>

Source

pub fn enum_variant(&mut self) -> Result<EnumVariant>

Source

pub fn attribute_key_value<T>( &mut self, key: &str, value: impl Fn(&mut Self) -> Result<T>, ) -> Result<Option<(Loc<String>, T)>>

Source

pub fn attribute_inner(&mut self) -> Result<Attribute>

Source

pub fn attributes(&mut self) -> Result<AttributeList>

Source

pub fn module_body(&mut self) -> Result<ModuleBody>

Source

pub fn top_level_module_body(&mut self) -> Result<Loc<ModuleBody>>

A module body which is not part of a mod. Errors if there is anything but an item found after the last item

Source§

impl<'a> Parser<'a>

Source

pub fn comma_separated<T>( &mut self, inner: impl Fn(&mut Self) -> Result<T>, end_marker: &TokenKind, ) -> CommaSeparatedResult<Vec<T>>

Source

pub fn token_separated<T>( &mut self, inner: impl Fn(&mut Self) -> Result<T>, separator: &TokenKind, end_markers: Vec<TokenKind>, ) -> CommaSeparatedResult<Vec<T>>

Source

pub fn with_recovery<T>( &mut self, inner: impl Fn(&mut Self) -> Result<T>, continuations: Vec<TokenKind>, ) -> RecoveryResult<T>

Source§

impl<'a> Parser<'a>

Source

pub fn peek(&mut self) -> Result<Token>

Trait Implementations§

Source§

impl<'a> Clone for Parser<'a>

Source§

fn clone(&self) -> Parser<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more