-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d23a43a
commit 9e89fc4
Showing
6 changed files
with
95 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::ast::ParserError; | ||
use crate::codegen::CodegenError; | ||
use crate::lexer::LexerError; | ||
use crate::semantic::SemanticError; | ||
use crate::typecheck::TypeCheckError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum ErrorKind { | ||
#[error("Lexer Failed\n{0}")] | ||
LexerError(LexerError), | ||
#[error("AST Parsing Failed\n{0}")] | ||
ParserError(ParserError), | ||
#[error("Semantic Analysis Failed\n{0}")] | ||
SemanticError(SemanticError), | ||
#[error("Type Checking Failed\n{0}")] | ||
TypeCheckError(TypeCheckError), | ||
#[error("Codegen Failed\n{0}")] | ||
CodegenError(CodegenError), | ||
#[error("IO Error\n{0}")] | ||
IOError(std::io::Error), | ||
} | ||
|
||
impl From<LexerError> for ErrorKind { | ||
fn from(error: LexerError) -> Self { | ||
Self::LexerError(error) | ||
} | ||
} | ||
|
||
impl From<ParserError> for ErrorKind { | ||
fn from(error: ParserError) -> Self { | ||
Self::ParserError(error) | ||
} | ||
} | ||
|
||
impl From<SemanticError> for ErrorKind { | ||
fn from(error: SemanticError) -> Self { | ||
Self::SemanticError(error) | ||
} | ||
} | ||
|
||
impl From<TypeCheckError> for ErrorKind { | ||
fn from(error: TypeCheckError) -> Self { | ||
Self::TypeCheckError(error) | ||
} | ||
} | ||
|
||
impl From<CodegenError> for ErrorKind { | ||
fn from(error: CodegenError) -> Self { | ||
Self::CodegenError(error) | ||
} | ||
} | ||
|
||
impl From<std::io::Error> for ErrorKind { | ||
fn from(error: std::io::Error) -> Self { | ||
Self::IOError(error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters