-
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.
- Created `Error` type for describing errors. - Maybe changed to Either
- Loading branch information
1 parent
5966519
commit 4d2da25
Showing
9 changed files
with
103 additions
and
66 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Copyright (c) 2020 Vorotynsky Maxim | ||
|
||
module HLasm.Error where | ||
|
||
import HLasm.Ast | ||
import qualified Text.Parsec | ||
|
||
data Error = | ||
StringError String | ||
| ParseError Text.Parsec.ParseError | ||
| VariableNotFound VariableName | ||
| LabelNotFound Label | ||
| IncompatibleTypes (HLValue, HLValue) | ||
deriving (Eq) | ||
|
||
type Result a = Either Error a | ||
|
||
instance Show Error where | ||
show (StringError msg) = "error: " ++ msg ++ ".\n" | ||
show (VariableNotFound name) = "scope error: variable \'" ++ name ++ "\' not found.\n" | ||
show (LabelNotFound label) = "scope error: label \'" ++ label ++ "\' not found.\n" | ||
show (IncompatibleTypes (left, right)) = | ||
"type error: incompatible types between \'" ++ show left ++ "\' and \'" ++ show right ++ "\'.\n" | ||
show (ParseError err) = "parser error, " ++ show err |
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