Tokenizer.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_INCREMENT,
  29. T_DECREMENT,
  30. T_LITERAL,
  31. T_PRINT,
  32. T_IF,
  33. T_ELSE,
  34. T_WHILE,
  35. T_FUNCTION,
  36. T_RETURN,
  37. T_COMMA,
  38. T_SEMICOLON,
  39. T_OPEN_BRACKET,
  40. T_CLOSE_BRACKET,
  41. T_OPEN_CURVED_BRACKET,
  42. T_CLOSE_CURVED_BRACKET,
  43. T_END
  44. } Token;
  45. typedef int16_t int16;
  46. bool tTokenize(const char* path);
  47. const char* tGetError();
  48. void tResetReader();
  49. Token tPeekToken();
  50. Token tReadToken();
  51. bool tReadInt(int* i);
  52. bool tReadInt16(int16* i);
  53. bool tReadFloat(float* f);
  54. const char* tReadString();
  55. int tGetMarker();
  56. void tResetToMarker(int marker);
  57. const char* tGetTokenName(Token token);
  58. void tPrint();
  59. #endif