__grammar.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef VIRTUALMATH___GRAMMAR_H
  2. #define VIRTUALMATH___GRAMMAR_H
  3. #include "__virtualmath.h"
  4. #define PASERSSIGNATURE ParserMessage *pm, Inter *inter /*pasers函数的统一签名*/
  5. #define CALLPASERSSIGNATURE pm, inter /*pasers函数调用的统一实参*/
  6. #define addStatementToken(type, st, pm) addBackToken(pm->tm->ts, makeStatementToken(type, st))
  7. #define delToken(pm) (freeToken(popNewToken(pm->tm), true, 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)(PASERSSIGNATURE);
  13. typedef int (*GetSymbolFunction)(PASERSSIGNATURE, int, Statement **);
  14. typedef Statement *(*MakeControlFunction)(Statement *, long int, char *);
  15. typedef int (*TailFunction)(PASERSSIGNATURE, Token *, Statement **);
  16. void parserCommand(PASERSSIGNATURE);
  17. void parserControl(PASERSSIGNATURE, MakeControlFunction callBack, int type, bool must_operation, char *message);
  18. void parserDef(PASERSSIGNATURE);
  19. void parserIf(PASERSSIGNATURE);
  20. void parserWhile(PASERSSIGNATURE);
  21. void parserTry(PASERSSIGNATURE);
  22. void parserCode(PASERSSIGNATURE);
  23. void parserOperation(PASERSSIGNATURE);
  24. void parserPolynomial(PASERSSIGNATURE);
  25. void parserBaseValue(PASERSSIGNATURE);
  26. void parserCallBack(PASERSSIGNATURE);
  27. void parserPoint(PASERSSIGNATURE);
  28. void parserFactor(PASERSSIGNATURE);
  29. void parserAssignment(PASERSSIGNATURE);
  30. void parserTuple(PASERSSIGNATURE);
  31. void parserImport(PASERSSIGNATURE);
  32. void parserVarControl(PASERSSIGNATURE);
  33. void syntaxError(ParserMessage *pm, int status,long int line , int num, ...);
  34. int readBackToken(ParserMessage *pm);
  35. bool checkToken(ParserMessage *pm, int type);
  36. bool commandCallControl_(PASERSSIGNATURE, MakeControlFunction callBack, int type, Statement **st,
  37. char *log_message, bool must_operation, char *error_message);
  38. bool commandCallBack_(PASERSSIGNATURE, PasersFunction callBack, int type, Statement **st, char *message);
  39. bool callParserCode(PASERSSIGNATURE, Statement **st, char *message, long int line);
  40. bool callParserAs(PASERSSIGNATURE, Statement **st,char *message);
  41. bool callChildStatement(PASERSSIGNATURE, PasersFunction callBack, int type, Statement **st, char *message);
  42. bool callChildToken(PASERSSIGNATURE, PasersFunction callBack, int type, Token **tmp, char *message,
  43. int error_type);
  44. bool parserParameter(PASERSSIGNATURE, Parameter **pt, bool is_formal, bool is_list, bool is_dict,
  45. int sep,int ass);
  46. void twoOperation(PASERSSIGNATURE, PasersFunction callBack, GetSymbolFunction getSymbol,
  47. int call_type, int self_type, char *call_name, char *self_name, bool is_right);
  48. void tailOperation(PASERSSIGNATURE, PasersFunction callBack, TailFunction tailFunction, int call_type, int self_type,
  49. char *call_name, char *self_name);
  50. #endif //VIRTUALMATH___GRAMMAR_H