lexical.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_1,
  23. LEXMATHER_ING_2,
  24. LEXMATHER_ING_3,
  25. LEXMATHER_ING_4,
  26. LEXMATHER_ING_5,
  27. LEXMATHER_END_1,
  28. LEXMATHER_END_2,
  29. LEXMATHER_MISTAKE,
  30. } status;
  31. };
  32. struct LexMathers{
  33. int size;
  34. struct LexMather **mathers;
  35. };
  36. typedef struct LexFile LexFile;
  37. typedef struct LexMather LexMather;
  38. typedef struct LexMathers LexMathers;
  39. int readChar(LexFile *file);
  40. void backChar(LexFile *file);
  41. LexFile *makeLexFile(char *dir);
  42. void freeLexFile(LexFile *file);
  43. void setupMather(LexMather *mather);
  44. LexMather *makeMather();
  45. void freeMather(LexMather *mather);
  46. LexMathers *makeMathers(int size);
  47. void freeMathers(LexMathers *mathers);
  48. void setupMathers(LexMathers *mathers);
  49. int checkoutMather(LexMathers *mathers, int max);
  50. #endif //VIRTUALMATH_LEXICAL_H