parsetok.h 2.8 KB

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