aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/ast/error.rs
blob: 21102ea5629b581276f17f08c6f9cf0f412c5e2d (plain)
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
use std::{
    error, fmt,
    num::{ParseFloatError, ParseIntError},
    rc::Rc,
};

#[derive(Debug)]
pub enum Error {
    // Number
    InvalidFloatLiteral(ParseFloatError),
    InvalidIntegerLiteral(ParseIntError),

    // String
    UnclosedString(Rc<str>),
    UnexpectedEscapeChar(char),

    // Par
    UnexpectedRightPar,
    UnclosedLeftPar,

    UnexpectedEof,

    RecursionLimit,
}

impl From<ParseFloatError> for Error {
    fn from(value: ParseFloatError) -> Self {
        Self::InvalidFloatLiteral(value)
    }
}

impl From<ParseIntError> for Error {
    fn from(value: ParseIntError) -> Self {
        Self::InvalidIntegerLiteral(value)
    }
}

impl fmt::Display for Error {
    fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
        todo!()
    }
}

impl error::Error for Error {}