usesuper::{
ast::{FunctionKind, Profile, TypeQualifiers},
context::{Context, ExprPos},
error::ExpectedToken,
error::{Error, ErrorKind},
lex::{Lexer, LexerResultKind},
token::{Directive, DirectiveKind},
token::{Token, TokenValue},
variables::{GlobalOrConstant, VarDeclaration},
Frontend, Result,
}; usecrate::{arena::Handle, proc::U32EvalError, Expression, Module, Span, Type}; use pp_rs::token::{PreprocessorError, Token as PPToken, TokenValue as PPTokenValue}; use std::iter::Peekable;
mod declarations; mod expressions; mod functions; mod types;
pubstruct ParsingContext<'source> {
lexer: Peekable<Lexer<'source>>, /// Used to store tokens already consumed by the parser but that need to be backtracked
backtracked_token: Option<Token>,
last_meta: Span,
}
/// 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 pubfn backtrack(&mutself, token: Token) -> Result<()> { // This should never happen iflet Some(ref prev_token) = self.backtracked_token { return Err(Error {
kind: ErrorKind::InternalError("The parser tried to backtrack twice in a row"),
meta: prev_token.meta,
});
}
/// Returns None on the end of the file rather than an error like other methods pubfn bump_if(&mutself, frontend: &mut Frontend, value: TokenValue) -> Option<Token> { ifself.peek(frontend).filter(|t| t.value == value).is_some() { self.bump(frontend).ok()
} else {
None
}
}
// Body and expression arena for global initialization letmut ctx = Context::new(
frontend,
&mut module, false,
&mut global_expression_kind_tracker,
)?;
// Add an `EntryPoint` to `parser.module` for `main`, if a // suitable overload exists. Error out if we can't find one. iflet Some(declaration) = frontend.lookup_function.get("main") { for decl in declaration.overloads.iter() { iflet FunctionKind::Call(handle) = decl.kind { if decl.defined && decl.parameters.is_empty() {
frontend.add_entry_point(handle, ctx)?; return Ok(module);
}
}
}
}
matchself.external { true => { let global = frontend.add_global_var(self.ctx, decl)?; let expr = match global {
GlobalOrConstant::Global(handle) => Expression::GlobalVariable(handle),
GlobalOrConstant::Constant(handle) => Expression::Constant(handle),
};
Ok(self.ctx.add_expression(expr, meta)?)
} false => frontend.add_local_var(self.ctx, decl),
}
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.