|
- typedef enum {
- Error_Type_Ill_Formed_List,
- Error_Type_Wrong_Number_Of_Arguments,
- Error_Type_Type_Missmatch,
- Error_Type_Symbol_Not_Defined,
- Error_Type_Not_A_Function,
- Error_Type_Not_Yet_Implemented,
- 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 "Ill formed list";
- case Error_Type_Not_A_Function: return "Not a function";
- case Error_Type_Symbol_Not_Defined: return "Symbol not defined";
- case Error_Type_Wrong_Number_Of_Arguments: return "Wrong number of arguments";
- case Error_Type_Type_Missmatch: return "Type Missmatch";
- case Error_Type_Not_Yet_Implemented: return "Not yet implemented";
- default: return "Unknown Error";
- }
- }
|