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<'_>
impl ParsingContext<'_>
pub fn parse_external_declaration( &mut self, frontend: &mut Frontend, global_ctx: &mut Context<'_>, ) -> Result<(), Error>
pub fn parse_initializer( &mut self, frontend: &mut Frontend, ty: Handle<Type>, ctx: &mut Context<'_>, ) -> Result<(Handle<Expression>, Span), Error>
pub fn parse_init_declarator_list( &mut self, frontend: &mut Frontend, ty: Handle<Type>, ctx: &mut DeclarationContext<'_, '_, '_>, ) -> Result<(), Error>
sourcepub fn parse_declaration(
&mut self,
frontend: &mut Frontend,
ctx: &mut Context<'_>,
external: bool,
is_inside_loop: bool,
) -> Result<Option<Span>, Error>
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
pub fn parse_block_declaration( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, qualifiers: &mut TypeQualifiers<'_>, ty_name: String, meta: Span, ) -> Result<Span, Error>
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<'_>
impl ParsingContext<'_>
pub fn parse_primary( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>
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>
pub fn parse_postfix( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>
pub fn parse_unary( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>
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>
pub fn parse_conditional( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, passthrough: Option<Handle<HirExpr>>, ) -> Result<Handle<HirExpr>, Error>
pub fn parse_assignment( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>
pub fn parse_expression( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, stmt: &mut StmtContext, ) -> Result<Handle<HirExpr>, Error>
source§impl ParsingContext<'_>
impl ParsingContext<'_>
pub fn peek_parameter_qualifier(&mut self, frontend: &mut Frontend) -> bool
sourcepub fn parse_parameter_qualifier(
&mut self,
frontend: &mut Frontend,
) -> ParameterQualifier
pub fn parse_parameter_qualifier( &mut self, frontend: &mut Frontend, ) -> ParameterQualifier
Returns the parsed ParameterQualifier
or ParameterQualifier::In
pub fn parse_statement( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, terminator: &mut Option<usize>, is_inside_loop: bool, ) -> Result<Option<Span>, Error>
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>
pub fn parse_function_args( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(), Error>
source§impl ParsingContext<'_>
impl ParsingContext<'_>
sourcepub fn parse_array_specifier(
&mut self,
frontend: &mut Frontend,
ctx: &mut Context<'_>,
span: &mut Span,
ty: &mut Handle<Type>,
) -> Result<(), Error>
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
sourcefn parse_array_specifier_single(
&mut self,
frontend: &mut Frontend,
ctx: &mut Context<'_>,
span: &mut Span,
ty: &mut Handle<Type>,
) -> Result<bool, Error>
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
pub fn parse_type( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(Option<Handle<Type>>, Span), Error>
pub fn parse_type_non_void( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(Handle<Type>, Span), Error>
pub fn peek_type_qualifier(&mut self, frontend: &mut Frontend) -> bool
pub fn parse_type_qualifiers<'a>( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<TypeQualifiers<'a>, Error>
pub fn parse_layout_qualifier_id_list( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, qualifiers: &mut TypeQualifiers<'_>, ) -> Result<(), Error>
pub fn parse_layout_qualifier_id( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, qualifiers: &mut FastHashMap<QualifierKey<'_>, (QualifierValue, Span)>, ) -> Result<(), Error>
pub fn peek_type_name(&mut self, frontend: &mut Frontend) -> bool
source§impl<'source> ParsingContext<'source>
impl<'source> ParsingContext<'source>
pub fn new(lexer: Lexer<'source>) -> Self
sourcepub fn backtrack(&mut self, token: Token) -> Result<(), Error>
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
pub fn expect_ident( &mut self, frontend: &mut Frontend, ) -> Result<(String, Span), Error>
pub fn expect( &mut self, frontend: &mut Frontend, value: TokenValue, ) -> Result<Token, Error>
pub fn next(&mut self, frontend: &mut Frontend) -> Option<Token>
pub fn bump(&mut self, frontend: &mut Frontend) -> Result<Token, Error>
sourcepub fn bump_if(
&mut self,
frontend: &mut Frontend,
value: TokenValue,
) -> Option<Token>
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
pub fn peek(&mut self, frontend: &mut Frontend) -> Option<&Token>
pub fn expect_peek(&mut self, frontend: &mut Frontend) -> Result<&Token, Error>
pub fn parse(&mut self, frontend: &mut Frontend) -> Result<Module, Error>
fn parse_uint_constant( &mut self, frontend: &mut Frontend, ctx: &mut Context<'_>, ) -> Result<(u32, Span), Error>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more