pub struct Parser {
rules: Vec<(Rule, usize)>,
}
Fields§
§rules: Vec<(Rule, usize)>
Implementations§
source§impl Parser
impl Parser
pub const fn new() -> Self
fn reset(&mut self)
fn push_rule_span(&mut self, rule: Rule, lexer: &mut Lexer<'_>)
fn pop_rule_span(&mut self, lexer: &Lexer<'_>) -> Span
fn peek_rule_span(&mut self, lexer: &Lexer<'_>) -> Span
fn switch_value<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<SwitchValue<'a>, Error<'a>>
sourcefn constructor_type<'a>(
&mut self,
lexer: &mut Lexer<'a>,
word: &'a str,
span: Span,
ctx: &mut ExpressionContext<'a, '_, '_>,
) -> Result<Option<ConstructorType<'a>>, Error<'a>>
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
.
sourcefn arguments<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
) -> Result<Vec<Handle<Expression<'a>>>, Error<'a>>
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).
sourcefn 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>>
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).
fn ident_expr<'a>( &mut self, name: &'a str, name_span: Span, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> IdentExpr<'a>
fn primary_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>
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>>
sourcefn unary_expression<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
) -> Result<Handle<Expression<'a>>, Error<'a>>
fn unary_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>
Parse a unary_expression
.
sourcefn singular_expression<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
) -> Result<Handle<Expression<'a>>, Error<'a>>
fn singular_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>
Parse a singular_expression
.
fn equality_expression<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>
fn general_expression<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Handle<Expression<'a>>, Error<'a>>
fn general_expression_with_span<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, ) -> Result<(Handle<Expression<'a>>, Span), Error<'a>>
fn variable_decl<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<GlobalVariable<'a>, Error<'a>>
fn struct_body<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Vec<StructMember<'a>>, Error<'a>>
sourcefn singular_generic<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
) -> Result<(Handle<Type<'a>>, Span), Error<'a>>
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
fn matrix_with_type<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, columns: VectorSize, rows: VectorSize, ) -> Result<Type<'a>, Error<'a>>
fn type_decl_impl<'a>( &mut self, lexer: &mut Lexer<'a>, word: &'a str, ctx: &mut ExpressionContext<'a, '_, '_>, ) -> Result<Option<Type<'a>>, Error<'a>>
const fn check_texture_sample_type( scalar: Scalar, span: Span, ) -> Result<(), Error<'static>>
sourcefn type_decl<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
) -> Result<Handle<Type<'a>>, Error<'a>>
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.
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>>
sourcefn assignment_statement<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
block: &mut Block<'a>,
) -> Result<(), Error<'a>>
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)
sourcefn 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>>
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).
fn function_call_or_assignment_statement<'a>( &mut self, lexer: &mut Lexer<'a>, context: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, ) -> Result<(), Error<'a>>
fn statement<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, block: &mut Block<'a>, brace_nesting_level: u8, ) -> Result<(), Error<'a>>
fn loop<'a>( &mut self, lexer: &mut Lexer<'a>, ctx: &mut ExpressionContext<'a, '_, '_>, brace_nesting_level: u8, ) -> Result<StatementKind<'a>, Error<'a>>
sourcefn block<'a>(
&mut self,
lexer: &mut Lexer<'a>,
ctx: &mut ExpressionContext<'a, '_, '_>,
brace_nesting_level: u8,
) -> Result<(Block<'a>, Span), Error<'a>>
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