lexical.h 1.3 KB

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