mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
finished resolver (chapter 11) and started classes (chapter 12)
This commit is contained in:
parent
42c9f17399
commit
10540708d4
34 changed files with 1449 additions and 439 deletions
23
frontend/src/lexer/code_pos.rs
Normal file
23
frontend/src/lexer/code_pos.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#[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 std::fmt::Display for CodePos {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "line {}, col {}", self.line, self.col)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for CodePos {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}:{}", self.line, self.col)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue