naga::front::wgsl::parse

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 constructor_type<'a>( &mut self, lexer: &mut Lexer<'a>, word: &'a str, span: Span, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Option<ConstructorType<'a>>, Box<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>>>, 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 function_call<'a>( &mut self, lexer: &mut Lexer<'a>, name: &'a str, name_span: Span, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Box<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>>, Box<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>>, Box<Error<'a>>>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

fn assignment_statement<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, ) -> Result<(), Box<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<(), Box<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<(), Box<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<(), 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, ) -> 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.