__grammar.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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), 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 int (*ChecktLeftToken)(PASERSSIGNATURE, Statement *);
  15. typedef Statement *(*MakeControlFunction)(Statement *, long int, char *);
  16. typedef int (*TailFunction)(PASERSSIGNATURE, Token *, Statement **);
  17. void parserCommand(PASERSSIGNATURE);
  18. void parserControl(PASERSSIGNATURE, MakeControlFunction callBack, int type, bool must_operation, char *message);
  19. void parserDef(PASERSSIGNATURE);
  20. void parserDo(PASERSSIGNATURE);
  21. void parserWith(PASERSSIGNATURE);
  22. void parserIf(PASERSSIGNATURE);
  23. void parserWhile(PASERSSIGNATURE);
  24. void parserTry(PASERSSIGNATURE);
  25. void parserCode(PASERSSIGNATURE);
  26. void parserOperation(PASERSSIGNATURE);
  27. void parserPolynomial(PASERSSIGNATURE);
  28. void parserBaseValue(PASERSSIGNATURE);
  29. void parserCallBack(PASERSSIGNATURE);
  30. void parserPoint(PASERSSIGNATURE);
  31. void parserFactor(PASERSSIGNATURE);
  32. void parserAssignment(PASERSSIGNATURE);
  33. void parserTuple(PASERSSIGNATURE);
  34. void parserImport(PASERSSIGNATURE);
  35. void parserLabel(PASERSSIGNATURE);
  36. void parserGoto(PASERSSIGNATURE);
  37. void parserDecoration(PASERSSIGNATURE);
  38. void parserVarControl(PASERSSIGNATURE);
  39. void syntaxError(ParserMessage *pm, int status,long int line , int num, ...);
  40. int readBackToken(ParserMessage *pm);
  41. bool checkToken(ParserMessage *pm, int type);
  42. bool commandCallControl_(PASERSSIGNATURE, MakeControlFunction callBack, int type, Statement **st,
  43. char *log_message, bool must_operation, char *error_message);
  44. bool commandCallBack_(PASERSSIGNATURE, PasersFunction callBack, int type, Statement **st, char *message);
  45. bool callParserCode(PASERSSIGNATURE, Statement **st, char *message, long int line);
  46. bool callParserAs(PASERSSIGNATURE, Statement **st,char *message);
  47. bool callChildStatement(PASERSSIGNATURE, PasersFunction callBack, int type, Statement **st, char *message);
  48. bool callChildToken(PASERSSIGNATURE, PasersFunction callBack, int type, Token **tmp, char *message,
  49. int error_type);
  50. bool parserParameter(PASERSSIGNATURE, Parameter **pt, bool is_formal, bool is_list, bool is_dict,
  51. int sep,int ass);
  52. void twoOperation(PASERSSIGNATURE, PasersFunction callBack, GetSymbolFunction getSymbol, ChecktLeftToken checkleft,
  53. int call_type, int self_type, char *call_name, char *self_name, bool is_right);
  54. void tailOperation(PASERSSIGNATURE, PasersFunction callBack, TailFunction tailFunction, int call_type, int self_type,
  55. char *call_name, char *self_name);
  56. void lexEnter(ParserMessage *pm, bool lock);
  57. #endif //VIRTUALMATH___GRAMMAR_H