//! This file contains information on where a [`Token`] or [`Node`] is within the source //! code for more informative errors. //! //! This will likely be attached to a [`Token`] which will in turn be attached to an AST //! [`Node`]. use std::fmt::Display; use crate::model::module::Module; /// Information on where the token is within the source. #[derive(Debug)] pub struct SourceInfo { /// The line number within the source file underpinned by `module_id`. pub line_no: usize, pub module: Module, /// The indexes where this token may be found (line-local). pub span: std::ops::Range, } impl Display for SourceInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.module.name) } }