|
- typedef enum {
- Error_Type_Ill_Formed_List,
- Error_Type_Ill_Formed_Arguments,
- Error_Type_Ill_Formed_Lambda_List,
- Error_Type_Wrong_Number_Of_Arguments,
- Error_Type_Unknown_Keyword_Argument,
- Error_Type_Type_Missmatch,
- Error_Type_Symbol_Not_Defined,
- Error_Type_Not_A_Function,
- Error_Type_Not_Yet_Implemented,
- Error_Type_Syntax_Error,
- Error_Type_Unexpected_Eof,
- Error_Type_Unbalanced_Parenthesis,
- Error_Type_Trailing_Garbage,
- Error_Type_Unknown_Error,
- } Error_Type;
-
- typedef struct {
- Error_Type type;
- Ast_Node* location;
- } Error;
-
- Error* error;
-
- void delete_error() {
- if (error) {
- free(error);
- error = nullptr;
- }
- }
-
- void create_error(Error_Type type, Ast_Node* location) {
- delete_error();
-
- error = new(Error);
- error->type = type;
- error->location = location;
- }
-
- char* Error_Type_to_string(Error_Type type) {
- switch (type) {
- case Error_Type_Ill_Formed_List: return "Evaluation-error: Ill formed list";
- case Error_Type_Ill_Formed_Arguments: return "Evaluation-error: Ill formed arguments";
- case Error_Type_Ill_Formed_Lambda_List: return "Evaluation-error: Ill formed lambda list";
- case Error_Type_Unknown_Keyword_Argument: return "Evaluation-error: Unknown keyword argument";
- case Error_Type_Not_A_Function: return "Evaluation-error: Not a function";
- case Error_Type_Symbol_Not_Defined: return "Evaluation-error: Symbol not defined";
- case Error_Type_Wrong_Number_Of_Arguments: return "Evaluation-error: Wrong number of arguments";
- case Error_Type_Type_Missmatch: return "Evaluation-error: Type Missmatch";
- case Error_Type_Not_Yet_Implemented: return "Evaluation-error: Not yet implemented";
- case Error_Type_Trailing_Garbage: return "Evaluation-error: Trailing garbage following expression";
- case Error_Type_Syntax_Error: return "Syntax Error";
- case Error_Type_Unexpected_Eof: return "Parsing-error: Unexpected EOF";
- case Error_Type_Unbalanced_Parenthesis: return "Parsing-error: Unbalanced parenthesis";
- default: return "Unknown Error";
- }
- }
|