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
use std::path::PathBuf;

use diagnostic::DiagnosticLevel;

pub use self::errors::report::eprint;

mod errors;
mod for_3rd;
mod for_std;

pub use diagnostic::Span;
pub type Validation<T> = diagnostic::Validation<T, VosError>;

pub type VosResult<T = ()> = Result<T, VosError>;

#[derive(Debug)]
pub struct VosError {
    kind: Box<VosErrorKind>,
    level: DiagnosticLevel,
}

#[derive(Debug)]
pub enum VosErrorKind {
    IOError(IOError),
    ParseError(String),
    RuntimeError(String),
    DuplicateFields(DuplicateFields),
    UnknownError,
}

#[derive(Debug)]
pub struct IOError {
    pub error: String,
    pub source: PathBuf,
}

#[derive(Debug)]
pub struct DuplicateFields {
    pub path: String,
    pub symbol: String,
    pub lhs: Span,
    pub rhs: Span,
}