multifile/
multifile.rs

1use ariadne::{Report, ReportKind, Label, ColorGenerator, Fmt, sources};
2
3fn main() {
4    let mut colors = ColorGenerator::new();
5
6    // Generate some colours for each of our elements
7    let a = colors.next();
8    let b = colors.next();
9    let c = colors.next();
10
11    Report::build(ReportKind::Error, "b.tao", 10)
12        .with_code(3)
13        .with_message(format!("Cannot add types Nat and Str"))
14        .with_label(Label::new(("b.tao", 10..14))
15            .with_message(format!("This is of type {}", "Nat".fg(a)))
16            .with_color(a))
17        .with_label(Label::new(("b.tao", 17..20))
18            .with_message(format!("This is of type {}", "Str".fg(b)))
19            .with_color(b))
20        .with_label(Label::new(("b.tao", 15..16))
21            .with_message(format!(" {} and {} undergo addition here", "Nat".fg(a), "Str".fg(b)))
22            .with_color(c)
23            .with_order(10))
24        .with_label(Label::new(("a.tao", 4..8))
25            .with_message(format!("Original definition of {} is here", "five".fg(a)))
26            .with_color(a))
27        .with_note(format!("{} is a number and can only be added to other numbers", "Nat".fg(a)))
28        .finish()
29        .print(sources(vec![
30            ("a.tao", include_str!("a.tao")),
31            ("b.tao", include_str!("b.tao")),
32        ]))
33        .unwrap();
34}