Struct naga::front::wgsl::parse::Parser

source ·
pub struct Parser {
    rules: Vec<(Rule, usize)>,
}

Fields§

§rules: Vec<(Rule, usize)>

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 switch_value<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<SwitchValue<'a>, Error<'a>>

source

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

Decide if we’re looking at a construction expression, and return its type if so.

If the identifier word is a type-defining keyword, then return a ConstructorType value describing the type to build. Return an error if the type is not constructible (like sampler).

If word isn’t a type name, then return None.

source

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

Expects name to be consumed (not in lexer).

source

fn function_call<'a>( &mut self, lexer: &mut Lexer<'a>, name: &'a str, name_span: Span, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>

Expects Rule::PrimaryExpr or Rule::SingularExpr on top; does not pop it. Expects name to be consumed (not in lexer).

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, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>

source

fn postfix<'a>( &mut self, span_start: usize, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, expr: Handle<Expression<'a>>, ) -> Result<Handle<Expression<'a>>, Error<'a>>

source

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

Parse a unary_expression.

source

fn singular_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, 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>>, Error<'a>>

source

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

source

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

source

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

source

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

source

fn singular_generic<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<(Handle<Type<'a>>, Span), Error<'a>>

Parses <T>, returning T and span of T

source

fn matrix_with_type<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, columns: VectorSize, rows: VectorSize, ) -> Result<Type<'a>, Error<'a>>

source

fn type_decl_impl<'a>( &mut self, lexer: &mut Lexer<'a>, word: &'a str, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Option<Type<'a>>, Error<'a>>

source

const fn check_texture_sample_type( scalar: Scalar, span: Span, ) -> Result<(), Error<'static>>

source

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

Parse type declaration of a given name.

source

fn assignment_op_and_rhs<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, target: Handle<Expression<'a>>, span_start: usize, ) -> Result<(), Error<'a>>

source

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

Parse an assignment statement (will also parse increment and decrement statements)

source

fn function_statement<'a>( &mut self, lexer: &mut Lexer<'a>, ident: &'a str, ident_span: Span, span_start: usize, context: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, ) -> Result<(), Error<'a>>

Parse a function call statement. Expects ident to be consumed (not in the lexer).

source

fn function_call_or_assignment_statement<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, ) -> Result<(), Error<'a>>

source

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

source

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

source

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

compound_statement

source

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

source

fn function_decl<'a>( &mut self, lexer: &mut Lexer<'a>, out: &mut TranslationUnit<'a>, dependencies: &mut FastIndexSet<Dependency<'a>>, ) -> Result<Function<'a>, Error<'a>>

source

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

source

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

source

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

source

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

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>,

§

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>,

§

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.