You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 line
1.2 KiB

  1. typedef enum {
  2. Error_Type_Ill_Formed_List,
  3. Error_Type_Wrong_Number_Of_Arguments,
  4. Error_Type_Type_Missmatch,
  5. Error_Type_Symbol_Not_Defined,
  6. Error_Type_Not_A_Function,
  7. Error_Type_Not_Yet_Implemented,
  8. Error_Type_Unknown_Error,
  9. } Error_Type;
  10. typedef struct {
  11. Error_Type type;
  12. Ast_Node* location;
  13. } Error;
  14. Error* error;
  15. void delete_error() {
  16. if (error) {
  17. free(error);
  18. error = NULL;
  19. }
  20. }
  21. void create_error(Error_Type type, Ast_Node* location) {
  22. delete_error();
  23. error = new(Error);
  24. error->type = type;
  25. error->location = location;
  26. }
  27. char* Error_Type_to_string(Error_Type type) {
  28. switch (type) {
  29. case Error_Type_Ill_Formed_List: return "Ill formed list";
  30. case Error_Type_Not_A_Function: return "Not a function";
  31. case Error_Type_Symbol_Not_Defined: return "Symbol not defined";
  32. case Error_Type_Wrong_Number_Of_Arguments: return "Wrong number of arguments";
  33. case Error_Type_Type_Missmatch: return "Type Missmatch";
  34. case Error_Type_Not_Yet_Implemented: return "Not yet implemented";
  35. case Error_Type_Unknown_Error: return "Unknown Error";
  36. }
  37. }