Tokenizer.h 992 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef TOKENIZER_H
  2. #define TOKENIZER_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. typedef enum Token {
  6. T_INT,
  7. T_FLOAT,
  8. T_NULL,
  9. T_TRUE,
  10. T_FALSE,
  11. T_ADD,
  12. T_SUB,
  13. T_MUL,
  14. T_DIV,
  15. T_MOD,
  16. T_LESS,
  17. T_LESS_EQUAL,
  18. T_GREATER,
  19. T_GREATER_EQUAL,
  20. T_EQUAL,
  21. T_NOT_EQUAL,
  22. T_NOT,
  23. T_AND,
  24. T_OR,
  25. T_BIT_AND,
  26. T_BIT_OR,
  27. T_SET,
  28. T_LITERAL,
  29. T_PRINT,
  30. T_IF,
  31. T_ELSE,
  32. T_WHILE,
  33. T_FUNCTION,
  34. T_RETURN,
  35. T_COMMA,
  36. T_SEMICOLON,
  37. T_OPEN_BRACKET,
  38. T_CLOSE_BRACKET,
  39. T_OPEN_CURVED_BRACKET,
  40. T_CLOSE_CURVED_BRACKET,
  41. T_END
  42. } Token;
  43. typedef int16_t int16;
  44. bool tTokenize(const char* path);
  45. const char* tGetError();
  46. void tResetReader();
  47. Token tPeekToken();
  48. Token tReadToken();
  49. bool tReadInt(int* i);
  50. bool tReadInt16(int16* i);
  51. bool tReadFloat(float* f);
  52. const char* tReadString();
  53. int tGetMarker();
  54. void tResetToMarker(int marker);
  55. const char* tGetTokenName(Token token);
  56. void tPrint();
  57. #endif