lexical.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef VIRTUALMATH_LEXICAL_H
  2. #define VIRTUALMATH_LEXICAL_H
  3. #include "__macro.h"
  4. struct LexFile{
  5. FILE *file;
  6. wchar_t *str;
  7. int status; // 0-stdin模式 1-文件模式 2-字符串模式
  8. size_t seek; // 字符串模式下需要使用
  9. struct LexFileBack{
  10. bool is_back;
  11. wint_t p;
  12. } back;
  13. struct {
  14. int enter; // 若计数为0则不忽略enter
  15. } filter_data;
  16. long int line;
  17. };
  18. struct LexMather{
  19. int len;
  20. wint_t string_type;
  21. wchar_t *str;
  22. wchar_t *second_str;
  23. int ascii;
  24. enum LexMatherStatus{
  25. LEXMATHER_START=1,
  26. LEXMATHER_ING_1,
  27. LEXMATHER_ING_2,
  28. LEXMATHER_ING_3,
  29. LEXMATHER_ING_4,
  30. LEXMATHER_ING_5,
  31. LEXMATHER_ING_6,
  32. LEXMATHER_END_1,
  33. LEXMATHER_END_2,
  34. LEXMATHER_MISTAKE,
  35. } status;
  36. };
  37. struct LexMathers{
  38. int size;
  39. struct LexMather **mathers;
  40. };
  41. typedef struct LexFile LexFile;
  42. typedef struct LexMather LexMather;
  43. typedef struct LexMathers LexMathers;
  44. wint_t readChar(LexFile *file);
  45. void backChar(LexFile *file);
  46. void clearLexFile(LexFile *file);
  47. LexFile *makeLexFile(char *dir);
  48. LexFile *makeLexStr(wchar_t *str);
  49. void freeLexFile(LexFile *file);
  50. void setupMather(LexMather *mather);
  51. LexMather *makeMather();
  52. void freeMather(LexMather *mather);
  53. LexMathers *makeMathers(int size);
  54. void freeMathers(LexMathers *mathers);
  55. void setupMathers(LexMathers *mathers);
  56. int checkoutMather(LexMathers *mathers, int max);
  57. #endif //VIRTUALMATH_LEXICAL_H