From df512a08f3c14f8496b53dd15f30f772df208202 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 27 Feb 2026 11:14:09 +0100 Subject: Big work to the compiler job system --- oryxc/src/parser.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'oryxc/src/parser.rs') diff --git a/oryxc/src/parser.rs b/oryxc/src/parser.rs index 212d0db..d726f8d 100644 --- a/oryxc/src/parser.rs +++ b/oryxc/src/parser.rs @@ -9,8 +9,8 @@ use soa_rs::{ }; use crate::lexer::{ + Token, TokenType, - TokenizedBuffer, }; use crate::{ errors, @@ -87,33 +87,31 @@ pub union ExtraData { r#return: ManuallyDrop, } -struct Parser<'a, 'b> { +struct Parser<'a> { ast: Soa, extra_data: Vec, - tokbuf: &'a TokenizedBuffer<'b>, cursor: u32, scratch: Vec, + tokens: &'a Soa, + filename: &'a OsStr, } -impl<'a, 'b> Parser<'a, 'b> { - fn new(tokbuf: &'a TokenizedBuffer<'b>) -> Self { +impl<'a> Parser<'a> { + fn new(filename: &'a OsStr, tokens: &'a Soa) -> Self { return Self { ast: Soa::with_capacity(size::kibibytes(10)), extra_data: Vec::with_capacity(size::kibibytes(1)), - tokbuf, cursor: 0, scratch: Vec::with_capacity(64), + tokens, + filename, }; } #[inline(always)] fn get(&self) -> TokenType { return unsafe { - *self - .tokbuf - .tokens - .kind() - .get_unchecked(self.cursor as usize) + *self.tokens.kind().get_unchecked(self.cursor as usize) }; } @@ -146,10 +144,7 @@ impl<'a, 'b> Parser<'a, 'b> { where T: Display, { - errors::err_at_position( - self.tokbuf.filename.unwrap_or(OsStr::new("-")), - s, - ); + errors::err_at_position(self.filename, s); } fn parse_toplevel(&mut self) { @@ -535,8 +530,11 @@ impl<'a, 'b> Parser<'a, 'b> { } } -pub fn parse(tokbuf: &TokenizedBuffer) -> (Soa, Vec) { - let mut p = Parser::new(tokbuf); +pub fn parse( + filename: &OsStr, + tokens: &Soa, +) -> (Soa, Vec) { + let mut p = Parser::new(filename, tokens); while p.get() != TokenType::Eof { p.parse_toplevel(); } -- cgit v1.2.3