1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
use std::fmt; #[derive(PartialEq, Eq, Hash, Copy, Clone)] pub struct LineColumn { pub offset: usize, pub line: usize, pub column: usize, } #[derive(PartialEq, Eq, Hash, Copy, Clone)] pub struct Span { pub start: LineColumn, pub end: LineColumn, } #[derive(PartialEq, Eq, Hash, Copy, Clone)] pub struct Loc { pub start: usize, pub end: usize, } impl fmt::Debug for LineColumn { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}:{:?}", self.line + 1, self.column) } } impl fmt::Debug for Loc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}..{:?}", self.start, self.end) } } impl fmt::Debug for Span { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}..{:?}", self.start, self.end) } } impl Default for LineColumn { fn default() -> Self { LineColumn { offset: 0, line: 0, column: 0, } } } impl Default for Span { fn default() -> Self { Span { start: LineColumn::default(), end: LineColumn::default(), } } } impl Default for Loc { fn default() -> Self { Loc { start: 0, end: 0, } } }