lexical.h 1.3 KB

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