__grammar.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 parserNegate(P_FUNC);
  42. void parserAssignment(P_FUNC);
  43. void parserTuple(P_FUNC);
  44. void parserImport(P_FUNC);
  45. void parserLabel(P_FUNC);
  46. void parserGoto(P_FUNC);
  47. void parserDecoration(P_FUNC);
  48. void parserVarControl(P_FUNC);
  49. void syntaxError(ParserMessage *pm, int status,fline line , int num, ...);
  50. int readBackToken(ParserMessage *pm);
  51. bool checkToken(ParserMessage *pm, int type, fline *line);
  52. bool commandCallControl_(P_FUNC, MakeControlFunction callBack, int type, Statement **st, bool must_operation, char *error_message);
  53. bool callParserCode(P_FUNC, Statement **st, char *message, fline line);
  54. bool callParserAs(P_FUNC, Statement **st, char *message);
  55. bool callChildStatement(P_FUNC, PasersFunction callBack, int type, Statement **st, char *message);
  56. bool callChildToken(P_FUNC, PasersFunction callBack, int type, Token **tmp, char *message, int error_type);
  57. bool
  58. parserParameter(ParserMessage *pm, Inter *inter, Parameter **pt, bool enter, bool is_formal, bool is_list, int n_sep,
  59. bool is_dict, int sep, int ass, bool space);
  60. void twoOperation(P_FUNC, PasersFunction callBack, GetSymbolFunction getSymbol, ChecktLeftToken checkleft,
  61. int call_type, int self_type, char *call_name, char *self_name, bool is_right);
  62. void lexEnter(ParserMessage *pm, bool lock);
  63. #endif //VIRTUALMATH___GRAMMAR_H