lexical.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. wchar_t *errsyntax;
  18. };
  19. struct LexMather{
  20. int len;
  21. wint_t string_type;
  22. wchar_t *str;
  23. wchar_t *second_str;
  24. int ascii;
  25. enum LexMatherStatus{
  26. LEXMATHER_START=1,
  27. LEXMATHER_ING_1,
  28. LEXMATHER_ING_2,
  29. LEXMATHER_ING_3,
  30. LEXMATHER_ING_4,
  31. LEXMATHER_ING_5,
  32. LEXMATHER_ING_6,
  33. LEXMATHER_END_1,
  34. LEXMATHER_END_2,
  35. LEXMATHER_MISTAKE,
  36. } status;
  37. };
  38. struct LexMathers{
  39. int size;
  40. struct LexMather **mathers;
  41. };
  42. typedef struct LexFile LexFile;
  43. typedef struct LexMather LexMather;
  44. typedef struct LexMathers LexMathers;
  45. wint_t readChar(LexFile *file);
  46. void backChar(LexFile *file);
  47. void clearLexFile(LexFile *file);
  48. LexFile *makeLexFile(char *dir);
  49. LexFile *makeLexStr(wchar_t *str);
  50. void freeLexFile(LexFile *file);
  51. void setupMather(LexMather *mather);
  52. LexMather *makeMather();
  53. void freeMather(LexMather *mather);
  54. LexMathers *makeMathers(int size);
  55. void freeMathers(LexMathers *mathers);
  56. void setupMathers(LexMathers *mathers);
  57. int checkoutMather(LexMathers *mathers, int max);
  58. #endif //VIRTUALMATH_LEXICAL_H