Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

58 строки
2.2 KiB

  1. typedef enum {
  2. Error_Type_Ill_Formed_List,
  3. Error_Type_Ill_Formed_Arguments,
  4. Error_Type_Ill_Formed_Lambda_List,
  5. Error_Type_Wrong_Number_Of_Arguments,
  6. Error_Type_Unknown_Keyword_Argument,
  7. Error_Type_Type_Missmatch,
  8. Error_Type_Symbol_Not_Defined,
  9. Error_Type_Not_A_Function,
  10. Error_Type_Not_Yet_Implemented,
  11. Error_Type_Syntax_Error,
  12. Error_Type_Unexpected_Eof,
  13. Error_Type_Unbalanced_Parenthesis,
  14. Error_Type_Trailing_Garbage,
  15. Error_Type_Unknown_Error,
  16. } Error_Type;
  17. typedef struct {
  18. Error_Type type;
  19. Ast_Node* location;
  20. } Error;
  21. Error* error;
  22. void delete_error() {
  23. if (error) {
  24. free(error);
  25. error = nullptr;
  26. }
  27. }
  28. void create_error(Error_Type type, Ast_Node* location) {
  29. delete_error();
  30. error = new(Error);
  31. error->type = type;
  32. error->location = location;
  33. }
  34. char* Error_Type_to_string(Error_Type type) {
  35. switch (type) {
  36. case Error_Type_Ill_Formed_List: return "Evaluation-error: Ill formed list";
  37. case Error_Type_Ill_Formed_Arguments: return "Evaluation-error: Ill formed arguments";
  38. case Error_Type_Ill_Formed_Lambda_List: return "Evaluation-error: Ill formed lambda list";
  39. case Error_Type_Unknown_Keyword_Argument: return "Evaluation-error: Unknown keyword argument";
  40. case Error_Type_Not_A_Function: return "Evaluation-error: Not a function";
  41. case Error_Type_Symbol_Not_Defined: return "Evaluation-error: Symbol not defined";
  42. case Error_Type_Wrong_Number_Of_Arguments: return "Evaluation-error: Wrong number of arguments";
  43. case Error_Type_Type_Missmatch: return "Evaluation-error: Type Missmatch";
  44. case Error_Type_Not_Yet_Implemented: return "Evaluation-error: Not yet implemented";
  45. case Error_Type_Trailing_Garbage: return "Evaluation-error: Trailing garbage following expression";
  46. case Error_Type_Syntax_Error: return "Syntax Error";
  47. case Error_Type_Unexpected_Eof: return "Parsing-error: Unexpected EOF";
  48. case Error_Type_Unbalanced_Parenthesis: return "Parsing-error: Unbalanced parenthesis";
  49. default: return "Unknown Error";
  50. }
  51. }