27 lines
482 B
Rust
27 lines
482 B
Rust
|
use std::collections::HashMap;
|
||
|
use std::fmt;
|
||
|
|
||
|
use crate::ast::ItemId;
|
||
|
|
||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||
|
pub struct Location {
|
||
|
pub line_num: usize,
|
||
|
pub char_num: usize
|
||
|
}
|
||
|
|
||
|
impl fmt::Display for Location {
|
||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||
|
write!(f, "{}:{}", self.line_num, self.char_num)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub struct SourceMap {
|
||
|
map: HashMap<ItemId, Location>
|
||
|
}
|
||
|
|
||
|
impl SourceMap {
|
||
|
pub fn new() -> SourceMap {
|
||
|
SourceMap { map: HashMap::new() }
|
||
|
}
|
||
|
}
|