Skip to main content

intent_lang_core/
lib.rs

1pub mod analysis;
2pub mod smt;
3pub mod typeck;
4pub mod vcgen;
5
6use intent_lang_syntax::ast::Span;
7
8#[derive(Debug, Clone)]
9pub struct Diagnostic {
10    pub level: DiagLevel,
11    pub code: String,
12    pub message: String,
13    pub span: Span,
14    pub notes: Vec<String>,
15}
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum DiagLevel {
19    Error,
20    Warning,
21    Info,
22}
23
24impl std::fmt::Display for Diagnostic {
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        let level = match self.level {
27            DiagLevel::Error => "error",
28            DiagLevel::Warning => "warning",
29            DiagLevel::Info => "info",
30        };
31        write!(f, "{}[{}]: {}", level, self.code, self.message)?;
32        for note in &self.notes {
33            write!(f, "\n  = {note}")?;
34        }
35        Ok(())
36    }
37}