parsetok.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Parser-tokenizer link interface */
  2. #ifndef Py_LIMITED_API
  3. #ifndef Py_PARSETOK_H
  4. #define Py_PARSETOK_H
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #include "grammar.h" /* grammar */
  9. #include "node.h" /* node */
  10. typedef struct {
  11. int error;
  12. PyObject *filename;
  13. int lineno;
  14. int offset;
  15. char *text; /* UTF-8-encoded string */
  16. int token;
  17. int expected;
  18. } perrdetail;
  19. #if 0
  20. #define PyPARSE_YIELD_IS_KEYWORD 0x0001
  21. #endif
  22. #define PyPARSE_DONT_IMPLY_DEDENT 0x0002
  23. #if 0
  24. #define PyPARSE_WITH_IS_KEYWORD 0x0003
  25. #define PyPARSE_PRINT_IS_FUNCTION 0x0004
  26. #define PyPARSE_UNICODE_LITERALS 0x0008
  27. #endif
  28. #define PyPARSE_IGNORE_COOKIE 0x0010
  29. #define PyPARSE_BARRY_AS_BDFL 0x0020
  30. #define PyPARSE_TYPE_COMMENTS 0x0040
  31. #define PyPARSE_ASYNC_HACKS 0x0080
  32. PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
  33. perrdetail *);
  34. PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
  35. const char *, const char *,
  36. perrdetail *);
  37. PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
  38. perrdetail *, int);
  39. PyAPI_FUNC(node *) PyParser_ParseFileFlags(
  40. FILE *fp,
  41. const char *filename, /* decoded from the filesystem encoding */
  42. const char *enc,
  43. grammar *g,
  44. int start,
  45. const char *ps1,
  46. const char *ps2,
  47. perrdetail *err_ret,
  48. int flags);
  49. PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
  50. FILE *fp,
  51. const char *filename, /* decoded from the filesystem encoding */
  52. const char *enc,
  53. grammar *g,
  54. int start,
  55. const char *ps1,
  56. const char *ps2,
  57. perrdetail *err_ret,
  58. int *flags);
  59. PyAPI_FUNC(node *) PyParser_ParseFileObject(
  60. FILE *fp,
  61. PyObject *filename,
  62. const char *enc,
  63. grammar *g,
  64. int start,
  65. const char *ps1,
  66. const char *ps2,
  67. perrdetail *err_ret,
  68. int *flags);
  69. PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(
  70. const char *s,
  71. const char *filename, /* decoded from the filesystem encoding */
  72. grammar *g,
  73. int start,
  74. perrdetail *err_ret,
  75. int flags);
  76. PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
  77. const char *s,
  78. const char *filename, /* decoded from the filesystem encoding */
  79. grammar *g,
  80. int start,
  81. perrdetail *err_ret,
  82. int *flags);
  83. PyAPI_FUNC(node *) PyParser_ParseStringObject(
  84. const char *s,
  85. PyObject *filename,
  86. grammar *g,
  87. int start,
  88. perrdetail *err_ret,
  89. int *flags);
  90. /* Note that the following functions are defined in pythonrun.c,
  91. not in parsetok.c */
  92. PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
  93. PyAPI_FUNC(void) PyParser_ClearError(perrdetail *);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif /* !Py_PARSETOK_H */
  98. #endif /* !Py_LIMITED_API */