__grammar.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef VIRTUALMATH___GRAMMAR_H
  2. #define VIRTUALMATH___GRAMMAR_H
  3. #include "__virtualmath.h"
  4. #define P_FUNC ParserMessage *pm, Inter *inter /*pasers函数的统一签名*/
  5. #define CP_FUNC pm, inter /*pasers函数调用的统一实参*/
  6. #define addStatementToken(type, st, pm) addBackToken(pm->tm->ts, makeStatementToken(type, st))
  7. #define delToken(pm) (freeToken(popNewToken(pm->tm), false))
  8. #define backToken_(pm, token) addBackToken(pm->tm->ts, (token))
  9. #define addLexToken(pm, type) backToken_(pm, makeLexToken(type, NULL, NULL, 0))
  10. #define addToken_ backToken_
  11. #define call_success(pm) (pm->status == success)
  12. typedef void (*PasersFunction)(P_FUNC);
  13. typedef int (*GetSymbolFunction)(P_FUNC, int, Statement **);
  14. typedef int (*ChecktLeftToken)(P_FUNC, Statement *);
  15. typedef Statement *(*MakeControlFunction)(Statement *, fline, char *);
  16. void parserCommand(P_FUNC);
  17. void parserControl(P_FUNC, MakeControlFunction callBack, int type, bool must_operation, char *message);
  18. void parserDef(P_FUNC);
  19. void parserDo(P_FUNC);
  20. void parserFor(P_FUNC);
  21. void parserWith(P_FUNC);
  22. void parserIf(P_FUNC);
  23. void parserWhile(P_FUNC);
  24. void parserTry(P_FUNC);
  25. void parserCode(P_FUNC);
  26. void parserOperation(P_FUNC);
  27. void parserPolynomial(P_FUNC);
  28. void parserBaseValue(P_FUNC);
  29. void parserCallBack(P_FUNC);
  30. void parserFactor(P_FUNC);
  31. void parserPow(P_FUNC);
  32. void parserNot(P_FUNC);
  33. void parserBitMove(P_FUNC);
  34. void parserCompare(P_FUNC);
  35. void parserCompare2(P_FUNC);
  36. void parserBand(P_FUNC);
  37. void parserBor(P_FUNC);
  38. void parserBxor(P_FUNC);
  39. void parserAnd(P_FUNC);
  40. void parserOr(P_FUNC);
  41. void parserAssignment(P_FUNC);
  42. void parserTuple(P_FUNC);
  43. void parserImport(P_FUNC);
  44. void parserLabel(P_FUNC);
  45. void parserGoto(P_FUNC);
  46. void parserDecoration(P_FUNC);
  47. void parserVarControl(P_FUNC);
  48. void syntaxError(ParserMessage *pm, int status,long int line , int num, ...);
  49. int readBackToken(ParserMessage *pm);
  50. bool checkToken(ParserMessage *pm, int type);
  51. bool commandCallControl_(P_FUNC, MakeControlFunction callBack, int type, Statement **st, bool must_operation, char *error_message);
  52. bool callParserCode(P_FUNC, Statement **st, char *message, long int line);
  53. bool callParserAs(P_FUNC, Statement **st, char *message);
  54. bool callChildStatement(P_FUNC, PasersFunction callBack, int type, Statement **st, char *message);
  55. bool callChildToken(P_FUNC, PasersFunction callBack, int type, Token **tmp, char *message,
  56. int error_type);
  57. bool parserParameter(P_FUNC, Parameter **pt, bool enter, bool is_formal, bool is_list, bool is_dict,
  58. int sep, int ass, int n_sep);
  59. void twoOperation(P_FUNC, PasersFunction callBack, GetSymbolFunction getSymbol, ChecktLeftToken checkleft,
  60. int call_type, int self_type, char *call_name, char *self_name, bool is_right);
  61. void lexEnter(ParserMessage *pm, bool lock);
  62. #endif //VIRTUALMATH___GRAMMAR_H