finished resolver (chapter 11) and started classes (chapter 12)

This commit is contained in:
Moritz Gmeiner 2023-01-28 01:11:55 +01:00
commit 10540708d4
34 changed files with 1449 additions and 439 deletions

View file

@ -1,34 +0,0 @@
use std::fmt::{Debug, Display};
#[derive(Copy, Clone)]
pub struct CodePos {
pub line: u32,
pub col: u32,
}
impl Default for CodePos {
fn default() -> Self {
Self { line: 1, col: 0 }
}
}
impl Display for CodePos {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "line {}, col {}", self.line, self.col)
}
}
impl Debug for CodePos {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}:{}", self.line, self.col)
}
}
/*====================================================================================================================*/
pub fn indent(s: String) -> String {
s.split('\n')
.map(|line| format!("\t{line}"))
.collect::<Vec<String>>()
.join("\n")
}