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
//! This file contains the error type that is used for diagnostics

use crate::{
    token::{Token, TokenKind},
    LocalSpan,
};

#[derive(Debug, Clone)]
pub enum ParseErrorKind {
    LeftOverInput(Token),
    UnexpectedComma(Token),
    UnexpectedFunctionIdent(Token),
    UnexpectedPath(LocalSpan),
    UnexpectedToken {
        got: Token,
        expected: Vec<ExpectedItem>,
    },
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ExpectedItem {
    ControlFlowOperator,
    FormatString,
    TokenKind(TokenKind),
    Statement,
    Value,
}

impl From<TokenKind> for ExpectedItem {
    fn from(kind: TokenKind) -> Self {
        Self::TokenKind(kind)
    }
}