use super::{ExpectedToken, TokenInfo};
use crate::error::SourceLocation;
#[derive(Debug, Clone, PartialEq)]
pub enum ParseErrorKind {
UnexpectedToken {
found: TokenInfo,
expected: Vec<ExpectedToken>,
},
UnexpectedEof {
expected: Vec<ExpectedToken>,
},
UnterminatedString {
start_location: SourceLocation,
delimiter: StringDelimiter,
},
UnterminatedComment {
start_location: SourceLocation,
},
InvalidNumber {
text: String,
reason: NumberError,
},
UnbalancedDelimiter {
opener: char,
open_location: SourceLocation,
found: Option<char>,
},
ReservedKeyword {
keyword: String,
context: IdentifierContext,
},
InvalidEscape {
sequence: String,
valid_escapes: Vec<String>,
},
InvalidCharacter {
char: char,
codepoint: u32,
},
MissingComponent {
component: MissingComponentKind,
after: Option<String>,
},
Custom {
message: String,
},
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum StringDelimiter {
DoubleQuote,
SingleQuote,
Backtick,
}
#[derive(Debug, Clone, PartialEq)]
pub enum NumberError {
MultipleDecimalPoints,
InvalidExponent,
TrailingDecimalPoint,
LeadingZeros,
InvalidDigit(char),
TooLarge,
Empty,
}
#[derive(Debug, Clone, PartialEq)]
pub enum MissingComponentKind {
Semicolon,
ClosingBrace,
ClosingBracket,
ClosingParen,
FunctionBody,
Expression,
TypeAnnotation,
Identifier,
Arrow,
Colon,
}
#[derive(Debug, Clone, PartialEq)]
pub enum IdentifierContext {
VariableName,
FunctionName,
ParameterName,
PatternName,
TypeName,
PropertyName,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ErrorSeverity {
#[default]
Error,
Warning,
Info,
Hint,
}