shape_ast/error/parse_error/
kinds.rs1use super::{ExpectedToken, TokenInfo};
4use crate::error::SourceLocation;
5
6#[derive(Debug, Clone, PartialEq)]
8pub enum ParseErrorKind {
9 UnexpectedToken {
11 found: TokenInfo,
13 expected: Vec<ExpectedToken>,
15 },
16
17 UnexpectedEof {
19 expected: Vec<ExpectedToken>,
21 },
22
23 UnterminatedString {
25 start_location: SourceLocation,
27 delimiter: StringDelimiter,
29 },
30
31 UnterminatedComment {
33 start_location: SourceLocation,
35 },
36
37 InvalidNumber {
39 text: String,
41 reason: NumberError,
43 },
44
45 UnbalancedDelimiter {
47 opener: char,
49 open_location: SourceLocation,
51 found: Option<char>,
53 },
54
55 ReservedKeyword {
57 keyword: String,
59 context: IdentifierContext,
61 },
62
63 InvalidEscape {
65 sequence: String,
67 valid_escapes: Vec<String>,
69 },
70
71 InvalidCharacter {
73 char: char,
75 codepoint: u32,
77 },
78
79 MissingComponent {
81 component: MissingComponentKind,
83 after: Option<String>,
85 },
86
87 Custom {
89 message: String,
91 },
92}
93
94#[derive(Debug, Clone, Copy, PartialEq)]
96pub enum StringDelimiter {
97 DoubleQuote,
98 SingleQuote,
99 Backtick,
100}
101
102#[derive(Debug, Clone, PartialEq)]
104pub enum NumberError {
105 MultipleDecimalPoints,
106 InvalidExponent,
107 TrailingDecimalPoint,
108 LeadingZeros,
109 InvalidDigit(char),
110 TooLarge,
111 Empty,
112}
113
114#[derive(Debug, Clone, PartialEq)]
116pub enum MissingComponentKind {
117 Semicolon,
118 ClosingBrace,
119 ClosingBracket,
120 ClosingParen,
121 FunctionBody,
122 Expression,
123 TypeAnnotation,
124 Identifier,
125 Arrow,
126 Colon,
127}
128
129#[derive(Debug, Clone, PartialEq)]
131pub enum IdentifierContext {
132 VariableName,
133 FunctionName,
134 ParameterName,
135 PatternName,
136 TypeName,
137 PropertyName,
138}
139
140#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
142pub enum ErrorSeverity {
143 #[default]
144 Error,
145 Warning,
146 Info,
147 Hint,
148}