naga::front::glsl::parser

Struct ParsingContext

source
pub struct ParsingContext<'source> {
    lexer: Peekable<Lexer<'source>>,
    backtracked_token: Option<Token>,
    last_meta: Span,
}

Fields§

§lexer: Peekable<Lexer<'source>>§backtracked_token: Option<Token>

Used to store tokens already consumed by the parser but that need to be backtracked

§last_meta: Span

Implementations§

source§

impl ParsingContext<'_>

source

pub fn parse_external_declaration( &mut self, frontend: &mut Frontend, global_ctx: &mut Context<'_>, ) -> Result<(), Error>

source

pub fn parse_initializer( &mut self, frontend: &mut Frontend, ty: Handle<Type>, ctx: &mut Context<'_>, ) -> Result<(Handle<Expression>, Span), Error>

source

pub fn parse_init_declarator_list( &mut self, frontend: &mut Frontend, ty: Handle<Type>, ctx: &mut DeclarationContext<'_, '_, '_>, ) -> Result<(), Error>

source

pub fn parse_declaration( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, external: bool, is_inside_loop: bool, ) -> Result<Option<Span>, Error>

external whether or not we are in a global or local context

source

pub fn parse_block_declaration( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, qualifiers: &mut TypeQualifiers<'_>, ty_name: String, meta: Span, ) -> Result<Span, Error>

source

pub fn parse_struct_declaration_list( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, members: &mut Vec<StructMember>, layout: StructLayout, ) -> Result<u32, Error>

source§

impl ParsingContext<'_>

source

pub fn parse_primary( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>

source

pub fn parse_function_call_args( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, meta: &mut Span, ) -> Result<Vec<Handle<HirExpr>>, Error>

source

pub fn parse_postfix( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>

source

pub fn parse_unary( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>

source

pub fn parse_binary( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, passthrough: Option<Handle<HirExpr>>, min_bp: u8, ) -> Result<Handle<HirExpr>, Error>

source

pub fn parse_conditional( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, passthrough: Option<Handle<HirExpr>>, ) -> Result<Handle<HirExpr>, Error>

source

pub fn parse_assignment( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>

source

pub fn parse_expression( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>

source§

impl ParsingContext<'_>

source

pub fn peek_parameter_qualifier(&mut self, frontend: &mut Frontend) -> bool

source

pub fn parse_parameter_qualifier( &mut self, frontend: &mut Frontend, ) -> ParameterQualifier

Returns the parsed ParameterQualifier or ParameterQualifier::In

source

pub fn parse_statement( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, terminator: &mut Option<usize>, is_inside_loop: bool, ) -> Result<Option<Span>, Error>

source

pub fn parse_compound_statement( &mut self, meta: Span, frontend: &mut Frontend, ctx: &mut Context<'_>, terminator: &mut Option<usize>, is_inside_loop: bool, ) -> Result<Span, Error>

source

pub fn parse_function_args( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(), Error>

source§

impl ParsingContext<'_>

source

pub fn parse_array_specifier( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, span: &mut Span, ty: &mut Handle<Type>, ) -> Result<(), Error>

Parses an optional array_specifier returning whether or not it’s present and modifying the type handle if it exists

source

fn parse_array_specifier_single( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, span: &mut Span, ty: &mut Handle<Type>, ) -> Result<bool, Error>

Implementation of Self::parse_array_specifier for a single array_specifier

source

pub fn parse_type( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(Option<Handle<Type>>, Span), Error>

source

pub fn parse_type_non_void( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(Handle<Type>, Span), Error>

source

pub fn peek_type_qualifier(&mut self, frontend: &mut Frontend) -> bool

source

pub fn parse_type_qualifiers<'a>( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<TypeQualifiers<'a>, Error>

source

pub fn parse_layout_qualifier_id_list( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, qualifiers: &mut TypeQualifiers<'_>, ) -> Result<(), Error>

source

pub fn parse_layout_qualifier_id( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, qualifiers: &mut FastHashMap<QualifierKey<'_>, (QualifierValue, Span)>, ) -> Result<(), Error>

source

pub fn peek_type_name(&mut self, frontend: &mut Frontend) -> bool

source§

impl<'source> ParsingContext<'source>

source

pub fn new(lexer: Lexer<'source>) -> Self

source

pub fn backtrack(&mut self, token: Token) -> Result<(), Error>

Helper method for backtracking from a consumed token

This method should always be used instead of assigning to backtracked_token since it validates that backtracking hasn’t occurred more than one time in a row

§Panics
  • If the parser already backtracked without bumping in between
source

pub fn expect_ident( &mut self, frontend: &mut Frontend, ) -> Result<(String, Span), Error>

source

pub fn expect( &mut self, frontend: &mut Frontend, value: TokenValue, ) -> Result<Token, Error>

source

pub fn next(&mut self, frontend: &mut Frontend) -> Option<Token>

source

pub fn bump(&mut self, frontend: &mut Frontend) -> Result<Token, Error>

source

pub fn bump_if( &mut self, frontend: &mut Frontend, value: TokenValue, ) -> Option<Token>

Returns None on the end of the file rather than an error like other methods

source

pub fn peek(&mut self, frontend: &mut Frontend) -> Option<&Token>

source

pub fn expect_peek(&mut self, frontend: &mut Frontend) -> Result<&Token, Error>

source

pub fn parse(&mut self, frontend: &mut Frontend) -> Result<Module, Error>

source

fn parse_uint_constant( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(u32, Span), Error>

source

fn parse_constant_expression( &mut self, frontend: &mut Frontend, module: &mut Module, global_expression_kind_tracker: &mut ExpressionKindTracker, ) -> Result<(Handle<Expression>, Span), Error>

Auto Trait Implementations§

§

impl<'source> Freeze for ParsingContext<'source>

§

impl<'source> RefUnwindSafe for ParsingContext<'source>

§

impl<'source> !Send for ParsingContext<'source>

§

impl<'source> !Sync for ParsingContext<'source>

§

impl<'source> Unpin for ParsingContext<'source>

§

impl<'source> UnwindSafe for ParsingContext<'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.