FileTokens.h 755 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef FILE_READER_H
  2. #define FILE_READER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "Error.h"
  7. typedef enum {
  8. FT_PATH,
  9. FT_NEWLINE,
  10. FT_LITERAL,
  11. FT_SINGLE,
  12. FT_SPACE,
  13. FT_END
  14. } FileToken;
  15. typedef struct {
  16. unsigned char* data;
  17. int capacity;
  18. int writeIndex;
  19. int readIndex;
  20. } FileTokens;
  21. typedef struct {
  22. unsigned char* data;
  23. const char* path;
  24. int length;
  25. int readIndex;
  26. int line;
  27. } FileReader;
  28. void ftInit(const char* path, FileTokens* ft, Error* e);
  29. void ftDelete(FileTokens* ft);
  30. FileToken ftRead(FileTokens* ft);
  31. bool ftReadSingleIf(FileTokens* ft, char c);
  32. char ftReadSingle(FileTokens* ft);
  33. const char* ftReadString(FileTokens* ft, int* length);
  34. #ifdef __cplusplus
  35. }
  36. #endif
  37. #endif