Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1 | /* Parser-tokenizer link interface */ |
Victor Stinner | 5f2df88 | 2018-11-12 00:56:19 +0100 | [diff] [blame] | 2 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 3 | #ifndef Py_LIMITED_API |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 4 | #ifndef Py_PARSETOK_H |
| 5 | #define Py_PARSETOK_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Victor Stinner | 5f2df88 | 2018-11-12 00:56:19 +0100 | [diff] [blame] | 10 | #include "grammar.h" /* grammar */ |
| 11 | #include "node.h" /* node */ |
| 12 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 13 | typedef struct { |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 14 | int error; |
Victor Stinner | 7f2fee3 | 2011-04-05 00:39:01 +0200 | [diff] [blame] | 15 | PyObject *filename; |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 16 | int lineno; |
| 17 | int offset; |
Victor Stinner | 00676d1 | 2010-12-27 01:49:31 +0000 | [diff] [blame] | 18 | char *text; /* UTF-8-encoded string */ |
Fred Drake | 85f3639 | 2000-07-11 17:53:00 +0000 | [diff] [blame] | 19 | int token; |
| 20 | int expected; |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 21 | } perrdetail; |
| 22 | |
Neil Schemenauer | c24ea08 | 2002-03-22 23:53:36 +0000 | [diff] [blame] | 23 | #if 0 |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 24 | #define PyPARSE_YIELD_IS_KEYWORD 0x0001 |
Neil Schemenauer | c24ea08 | 2002-03-22 23:53:36 +0000 | [diff] [blame] | 25 | #endif |
Tim Peters | fe2127d | 2001-07-16 05:37:24 +0000 | [diff] [blame] | 26 | |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 27 | #define PyPARSE_DONT_IMPLY_DEDENT 0x0002 |
Guido van Rossum | 4b499dd3 | 2003-02-13 22:07:59 +0000 | [diff] [blame] | 28 | |
Guido van Rossum | 45aecf4 | 2006-03-15 04:58:47 +0000 | [diff] [blame] | 29 | #if 0 |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 30 | #define PyPARSE_WITH_IS_KEYWORD 0x0003 |
Christian Heimes | 4d6ec85 | 2008-03-26 22:34:47 +0000 | [diff] [blame] | 31 | #define PyPARSE_PRINT_IS_FUNCTION 0x0004 |
| 32 | #define PyPARSE_UNICODE_LITERALS 0x0008 |
Guido van Rossum | 45aecf4 | 2006-03-15 04:58:47 +0000 | [diff] [blame] | 33 | #endif |
Thomas Wouters | 34aa7ba | 2006-02-28 19:02:24 +0000 | [diff] [blame] | 34 | |
Benjamin Peterson | f5b5224 | 2009-03-02 23:31:26 +0000 | [diff] [blame] | 35 | #define PyPARSE_IGNORE_COOKIE 0x0010 |
Brett Cannon | e3944a5 | 2009-04-01 05:08:41 +0000 | [diff] [blame] | 36 | #define PyPARSE_BARRY_AS_BDFL 0x0020 |
Guido van Rossum | dcfcd14 | 2019-01-31 03:40:27 -0800 | [diff] [blame] | 37 | #define PyPARSE_TYPE_COMMENTS 0x0040 |
Guido van Rossum | 495da29 | 2019-03-07 12:38:08 -0800 | [diff] [blame] | 38 | #define PyPARSE_ASYNC_HACKS 0x0080 |
Benjamin Peterson | f5b5224 | 2009-03-02 23:31:26 +0000 | [diff] [blame] | 39 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 40 | PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 41 | perrdetail *); |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 42 | PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, |
Serhiy Storchaka | c679227 | 2013-10-19 21:03:34 +0300 | [diff] [blame] | 43 | const char *, const char *, |
| 44 | perrdetail *); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 45 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 46 | PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, |
Tim Peters | fe2127d | 2001-07-16 05:37:24 +0000 | [diff] [blame] | 47 | perrdetail *, int); |
Victor Stinner | 14e461d | 2013-08-26 22:28:21 +0200 | [diff] [blame] | 48 | PyAPI_FUNC(node *) PyParser_ParseFileFlags( |
| 49 | FILE *fp, |
| 50 | const char *filename, /* decoded from the filesystem encoding */ |
| 51 | const char *enc, |
| 52 | grammar *g, |
| 53 | int start, |
Serhiy Storchaka | c679227 | 2013-10-19 21:03:34 +0300 | [diff] [blame] | 54 | const char *ps1, |
| 55 | const char *ps2, |
Victor Stinner | 14e461d | 2013-08-26 22:28:21 +0200 | [diff] [blame] | 56 | perrdetail *err_ret, |
| 57 | int flags); |
Victor Stinner | 00676d1 | 2010-12-27 01:49:31 +0000 | [diff] [blame] | 58 | PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx( |
| 59 | FILE *fp, |
| 60 | const char *filename, /* decoded from the filesystem encoding */ |
| 61 | const char *enc, |
| 62 | grammar *g, |
| 63 | int start, |
Serhiy Storchaka | c679227 | 2013-10-19 21:03:34 +0300 | [diff] [blame] | 64 | const char *ps1, |
| 65 | const char *ps2, |
Victor Stinner | 00676d1 | 2010-12-27 01:49:31 +0000 | [diff] [blame] | 66 | perrdetail *err_ret, |
| 67 | int *flags); |
Victor Stinner | 14e461d | 2013-08-26 22:28:21 +0200 | [diff] [blame] | 68 | PyAPI_FUNC(node *) PyParser_ParseFileObject( |
| 69 | FILE *fp, |
| 70 | PyObject *filename, |
| 71 | const char *enc, |
| 72 | grammar *g, |
| 73 | int start, |
Serhiy Storchaka | c679227 | 2013-10-19 21:03:34 +0300 | [diff] [blame] | 74 | const char *ps1, |
| 75 | const char *ps2, |
Victor Stinner | 14e461d | 2013-08-26 22:28:21 +0200 | [diff] [blame] | 76 | perrdetail *err_ret, |
| 77 | int *flags); |
Tim Peters | fe2127d | 2001-07-16 05:37:24 +0000 | [diff] [blame] | 78 | |
Victor Stinner | 14e461d | 2013-08-26 22:28:21 +0200 | [diff] [blame] | 79 | PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename( |
| 80 | const char *s, |
| 81 | const char *filename, /* decoded from the filesystem encoding */ |
| 82 | grammar *g, |
| 83 | int start, |
| 84 | perrdetail *err_ret, |
| 85 | int flags); |
Victor Stinner | 00676d1 | 2010-12-27 01:49:31 +0000 | [diff] [blame] | 86 | PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx( |
| 87 | const char *s, |
| 88 | const char *filename, /* decoded from the filesystem encoding */ |
| 89 | grammar *g, |
| 90 | int start, |
| 91 | perrdetail *err_ret, |
| 92 | int *flags); |
Victor Stinner | 14e461d | 2013-08-26 22:28:21 +0200 | [diff] [blame] | 93 | PyAPI_FUNC(node *) PyParser_ParseStringObject( |
| 94 | const char *s, |
| 95 | PyObject *filename, |
| 96 | grammar *g, |
| 97 | int start, |
| 98 | perrdetail *err_ret, |
| 99 | int *flags); |
Guido van Rossum | d3ab37f | 2003-04-17 14:55:42 +0000 | [diff] [blame] | 100 | |
Victor Stinner | 7f2fee3 | 2011-04-05 00:39:01 +0200 | [diff] [blame] | 101 | /* Note that the following functions are defined in pythonrun.c, |
| 102 | not in parsetok.c */ |
Guido van Rossum | d3ab37f | 2003-04-17 14:55:42 +0000 | [diff] [blame] | 103 | PyAPI_FUNC(void) PyParser_SetError(perrdetail *); |
Victor Stinner | 7f2fee3 | 2011-04-05 00:39:01 +0200 | [diff] [blame] | 104 | PyAPI_FUNC(void) PyParser_ClearError(perrdetail *); |
Guido van Rossum | d3ab37f | 2003-04-17 14:55:42 +0000 | [diff] [blame] | 105 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 106 | #ifdef __cplusplus |
| 107 | } |
| 108 | #endif |
| 109 | #endif /* !Py_PARSETOK_H */ |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 110 | #endif /* !Py_LIMITED_API */ |