pycore_parser.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef Py_INTERNAL_PARSER_H
  2. #define Py_INTERNAL_PARSER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ifndef Py_BUILD_CORE
  7. # error "this header requires Py_BUILD_CORE define"
  8. #endif
  9. #include "pycore_ast.h" // struct _expr
  10. #include "pycore_global_strings.h" // _Py_DECLARE_STR()
  11. #include "pycore_pyarena.h" // PyArena
  12. #ifdef Py_DEBUG
  13. #define _PYPEGEN_NSTATISTICS 2000
  14. #endif
  15. struct _parser_runtime_state {
  16. #ifdef Py_DEBUG
  17. long memo_statistics[_PYPEGEN_NSTATISTICS];
  18. #else
  19. int _not_used;
  20. #endif
  21. struct _expr dummy_name;
  22. };
  23. _Py_DECLARE_STR(empty, "")
  24. #define _parser_runtime_state_INIT \
  25. { \
  26. .dummy_name = { \
  27. .kind = Name_kind, \
  28. .v.Name.id = &_Py_STR(empty), \
  29. .v.Name.ctx = Load, \
  30. .lineno = 1, \
  31. .col_offset = 0, \
  32. .end_lineno = 1, \
  33. .end_col_offset = 0, \
  34. }, \
  35. }
  36. extern struct _mod* _PyParser_ASTFromString(
  37. const char *str,
  38. PyObject* filename,
  39. int mode,
  40. PyCompilerFlags *flags,
  41. PyArena *arena);
  42. extern struct _mod* _PyParser_ASTFromFile(
  43. FILE *fp,
  44. PyObject *filename_ob,
  45. const char *enc,
  46. int mode,
  47. const char *ps1,
  48. const char *ps2,
  49. PyCompilerFlags *flags,
  50. int *errcode,
  51. PyArena *arena);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* !Py_INTERNAL_PARSER_H */