Small parser changes.

This commit is contained in:
Jesse Brault 2026-03-30 14:04:29 -05:00
parent f95d504f88
commit 64526a0b1c

View File

@ -96,7 +96,7 @@ struct Parser<'a> {
lexer: Lexer<'a>,
current: Option<Token>,
lookahead: Option<Token>,
node_index: usize,
node_id: usize,
}
impl<'a> Parser<'a> {
@ -106,7 +106,7 @@ impl<'a> Parser<'a> {
lexer: Lexer::new(input),
current: None,
lookahead: None,
node_index: 0,
node_id: 0,
}
}
@ -212,6 +212,7 @@ impl<'a> Parser<'a> {
.with_primary_label_message(&format!("Expected {}.", Self::join_kinds(kinds)))
}
#[must_use]
fn expect_advance(&mut self, token_kind: TokenKind) -> (Option<Token>, Diagnostics) {
match self.current.take() {
None => (
@ -290,6 +291,12 @@ impl<'a> Parser<'a> {
self.sample_input(token.start(), token.end())
}
fn next_node_id(&mut self) -> usize {
let node_id = self.node_id;
self.node_id += 1;
node_id
}
fn compilation_unit(&mut self) -> ParseResult<CompilationUnit> {
let mut functions: Vec<Function> = vec![];
let mut extern_functions: Vec<ExternFunction> = vec![];