Parser

Struct Parser 

Source
pub struct Parser {
    rules: Vec<(Rule, usize)>,
    recursion_depth: u32,
}

Fields§

§rules: Vec<(Rule, usize)>§recursion_depth: u32

Implementations§

Source§

impl Parser

Source

pub const fn new() -> Self

Source

fn reset(&mut self)

Source

fn push_rule_span(&mut self, rule: Rule, lexer: &mut Lexer<'_>)

Source

fn pop_rule_span(&mut self, lexer: &Lexer<'_>) -> Span

Source

fn peek_rule_span(&mut self, lexer: &Lexer<'_>) -> Span

Source

fn race_rules(&self, rule0: Rule, rule1: Rule) -> Option<Rule>

Source

fn track_recursion<'a, F, R>(&mut self, f: F) -> Result<R, Box<Error<'a>>>
where F: FnOnce(&mut Self) -> Result<R, Box<Error<'a>>>,

Source

fn switch_value<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<SwitchValue<'a>, Box<Error<'a>>>

Source

fn arguments<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Vec<Handle<Expression<'a>>>, Box<Error<'a>>>

Expects name to be consumed (not in lexer).

Source

fn enclosed_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Source

fn ident_expr<'a>( &mut self, name: &'a str, name_span: Span, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> IdentExpr<'a>

Source

fn primary_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, token: (Token<'a>, Span), ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Source

fn component_or_swizzle_specifier<'a>( &mut self, expr_start: Span, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, expr: Handle<Expression<'a>>, ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Source

fn unary_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Parse a unary_expression.

Source

fn lhs_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, token: Option<(Token<'a>, Span)>, expected_token: ExpectedToken<'a>, ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Parse a lhs_expression.

LHS expressions only support the & and * operators and the [] and . postfix selectors.

Source

fn singular_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, token: (Token<'a>, Span), ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Parse a singular_expression.

Source

fn equality_expression<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Source

fn expression<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Box<Error<'a>>>

Source

fn optionally_typed_ident<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<(Ident<'a>, Option<TemplateElaboratedIdent<'a>>), Box<Error<'a>>>

Source

fn variable_decl<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<GlobalVariable<'a>, Box<Error<'a>>>

‘var’ _disambiguate_template template_list? optionally_typed_ident

Source

fn struct_body<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Vec<StructMember<'a>>, Box<Error<'a>>>

Source

fn maybe_template_list<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<(Vec<Handle<Expression<'a>>>, Span), Box<Error<'a>>>

Source

fn template_elaborated_ident<'a>( &mut self, word: &'a str, span: Span, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<TemplateElaboratedIdent<'a>, Box<Error<'a>>>

Source

fn type_specifier<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<TemplateElaboratedIdent<'a>, Box<Error<'a>>>

Source

fn variable_updating_statement<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, token: (Token<'a>, Span), expected_token: ExpectedToken<'a>, ) -> Result<(), Box<Error<'a>>>

Parses assignment, increment and decrement statements

This does not consume or require a final ; token. In the update expression of a C-style for loop header, there is no terminating ;.

Source

fn maybe_func_call_statement<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, token: (Token<'a>, Span), ) -> Result<bool, Box<Error<'a>>>

Parse a function call statement.

This assumes that token has been consumed from the lexer.

This does not consume or require a final ; token. In the update expression of a C-style for loop header, there is no terminating ;.

Source

fn func_call_or_variable_updating_statement<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, token: (Token<'a>, Span), expected_token: ExpectedToken<'a>, ) -> Result<(), Box<Error<'a>>>

Parses func_call_statement and variable_updating_statement

This does not consume or require a final ; token. In the update expression of a C-style for loop header, there is no terminating ;.

Source

fn variable_or_value_or_func_call_or_variable_updating_statement<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, token: (Token<'a>, Span), expected_token: ExpectedToken<'a>, ) -> Result<(), Box<Error<'a>>>

Parses variable_or_value_statement, func_call_statement and variable_updating_statement.

This is equivalent to the for_init production in the WGSL spec, but it’s also used for parsing these forms when they appear within a block, hence the longer name.

This does not consume the following ; token.

Source

fn statement<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, brace_nesting_level: u8, ) -> Result<(), Box<Error<'a>>>

Source

fn loop<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, brace_nesting_level: u8, ) -> Result<StatementKind<'a>, Box<Error<'a>>>

Source

fn block<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, brace_nesting_level: u8, ) -> Result<(Block<'a>, Span), Box<Error<'a>>>

compound_statement

Source

fn varying_binding<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Option<Binding<'a>>, Box<Error<'a>>>

Source

fn function_decl<'a>( &mut self, lexer: &mut Lexer<'a>, diagnostic_filter_leaf: Option<Handle<DiagnosticFilterNode>>, must_use: Option<Span>, out: &mut TranslationUnit<'a>, dependencies: &mut FastIndexSet<Dependency<'a>>, ) -> Result<Function<'a>, Box<Error<'a>>>

Source

fn directive_ident_list<'a>( &self, lexer: &mut Lexer<'a>, handler: impl FnMut(&'a str, Span) -> Result<(), Box<Error<'a>>>, ) -> Result<(), Box<Error<'a>>>

Source

fn global_decl<'a>( &mut self, lexer: &mut Lexer<'a>, out: &mut TranslationUnit<'a>, ) -> Result<(), Box<Error<'a>>>

Source

pub fn parse<'a>( &mut self, source: &'a str, options: &Options, ) -> Result<TranslationUnit<'a>, Box<Error<'a>>>

Source

fn increase_brace_nesting( brace_nesting_level: u8, brace_span: Span, ) -> Result<u8, Box<Error<'static>>>

Source

fn diagnostic_filter<'a>( &self, lexer: &mut Lexer<'a>, ) -> Result<DiagnosticFilter, Box<Error<'a>>>

Source

pub(crate) fn write_diagnostic_filters( arena: &mut Arena<DiagnosticFilterNode>, filters: DiagnosticFilterMap, parent: Option<Handle<DiagnosticFilterNode>>, ) -> Option<Handle<DiagnosticFilterNode>>

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.