aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/ast/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/ast/error.rs')
-rw-r--r--compiler/src/ast/error.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/compiler/src/ast/error.rs b/compiler/src/ast/error.rs
index 11f552d..ced2231 100644
--- a/compiler/src/ast/error.rs
+++ b/compiler/src/ast/error.rs
@@ -1,7 +1,37 @@
1use std::{error, fmt}; 1use std::{
2 error, fmt,
3 num::{ParseFloatError, ParseIntError},
4 rc::Rc,
5};
2 6
3#[derive(Debug)] 7#[derive(Debug)]
4pub enum Error {} 8pub enum Error {
9 // Number
10 InvalidFloatLiteral(ParseFloatError),
11 InvalidIntegerLiteral(ParseIntError),
12
13 // String
14 UnclosedString(Rc<str>),
15 UnexpectedEscapeChar(char),
16
17 // Par
18 UnexpectedRightPar,
19 UnclosedLeftPar,
20
21 UnexpectedEof,
22}
23
24impl From<ParseFloatError> for Error {
25 fn from(value: ParseFloatError) -> Self {
26 Self::InvalidFloatLiteral(value)
27 }
28}
29
30impl From<ParseIntError> for Error {
31 fn from(value: ParseIntError) -> Self {
32 Self::InvalidIntegerLiteral(value)
33 }
34}
5 35
6impl fmt::Display for Error { 36impl fmt::Display for Error {
7 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { 37 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {