lexical.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef VIRTUALMATH_LEXICAL_H
  2. #define VIRTUALMATH_LEXICAL_H
  3. #include "__macro.h"
  4. struct LexFile{
  5. FILE *file;
  6. struct LexFileBack{
  7. bool is_back;
  8. int p;
  9. } back;
  10. struct {
  11. int enter; // 若计数为0则不忽略enter
  12. } filter_data;
  13. long int line;
  14. };
  15. struct LexMather{
  16. int len;
  17. int string_type;
  18. char *str;
  19. char *second_str;
  20. enum LexMatherStatus{
  21. LEXMATHER_START=1,
  22. LEXMATHER_ING,
  23. LEXMATHER_INGPOINT,
  24. LEXMATHER_INGSECOND,
  25. LEXMATHER_INGPASS,
  26. LEXMATHER_END,
  27. LEXMATHER_END_SECOND,
  28. LEXMATHER_MISTAKE,
  29. } status;
  30. };
  31. struct LexMathers{
  32. int size;
  33. struct LexMather **mathers;
  34. };
  35. typedef struct LexFile LexFile;
  36. typedef struct LexMather LexMather;
  37. typedef struct LexMathers LexMathers;
  38. int readChar(LexFile *file);
  39. void backChar(LexFile *file);
  40. LexFile *makeLexFile(char *dir);
  41. void freeLexFile(LexFile *file);
  42. void setupMather(LexMather *mather);
  43. LexMather *makeMather();
  44. void freeMather(LexMather *mather);
  45. LexMathers *makeMathers(int size);
  46. void freeMathers(LexMathers *mathers);
  47. void setupMathers(LexMathers *mathers);
  48. int checkoutMather(LexMathers *mathers, int max);
  49. #endif //VIRTUALMATH_LEXICAL_H