type checking !?!?

This commit is contained in:
2025-03-22 14:40:32 -04:00
parent 606cb30c6b
commit 7f809d797c
44 changed files with 664 additions and 314 deletions
+5 -6
View File
@@ -1,7 +1,6 @@
use std::{iter::Peekable, str::Chars};
use super::super::ParserMsg;
use crate::ir::FilePos;
use super::super::{CompilerMsg, FilePos};
pub struct CharCursor<'a> {
chars: Peekable<Chars<'a>>,
@@ -15,12 +14,12 @@ impl CharCursor<'_> {
self.advance();
Some(res)
}
pub fn expect(&mut self, c: char) -> Result<(), ParserMsg> {
pub fn expect(&mut self, c: char) -> Result<(), CompilerMsg> {
let next = self.expect_next()?;
if next == c {
Ok(())
} else {
Err(ParserMsg::at(
Err(CompilerMsg::at(
self.prev_pos,
format!("unexpected char '{next}'; expected '{c}'"),
))
@@ -46,8 +45,8 @@ impl CharCursor<'_> {
self.next_pos.col += 1;
}
}
pub fn expect_next(&mut self) -> Result<char, ParserMsg> {
self.next().ok_or(ParserMsg::unexpected_end())
pub fn expect_next(&mut self) -> Result<char, CompilerMsg> {
self.next().ok_or(CompilerMsg::unexpected_end())
}
pub fn next_pos(&self) -> FilePos {
self.next_pos