blob: 935d733e90a5afed7fadbda7596337b169d5fd50 [file] [log] [blame]
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00001/* Parser-tokenizer link interface */
Victor Stinner5f2df882018-11-12 00:56:19 +01002
Martin v. Löwis4d0d4712010-12-03 20:14:31 +00003#ifndef Py_LIMITED_API
Fred Drake5eb6d4e2000-07-08 23:37:28 +00004#ifndef Py_PARSETOK_H
5#define Py_PARSETOK_H
6#ifdef __cplusplus
7extern "C" {
8#endif
9
Victor Stinner5f2df882018-11-12 00:56:19 +010010#include "grammar.h" /* grammar */
11#include "node.h" /* node */
12
Guido van Rossumb6775db1994-08-01 11:34:53 +000013typedef struct {
Fred Drake5eb6d4e2000-07-08 23:37:28 +000014 int error;
Victor Stinner7f2fee32011-04-05 00:39:01 +020015 PyObject *filename;
Fred Drake5eb6d4e2000-07-08 23:37:28 +000016 int lineno;
17 int offset;
Victor Stinner00676d12010-12-27 01:49:31 +000018 char *text; /* UTF-8-encoded string */
Fred Drake85f36392000-07-11 17:53:00 +000019 int token;
20 int expected;
Guido van Rossumb6775db1994-08-01 11:34:53 +000021} perrdetail;
22
Neil Schemenauerc24ea082002-03-22 23:53:36 +000023#if 0
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020024#define PyPARSE_YIELD_IS_KEYWORD 0x0001
Neil Schemenauerc24ea082002-03-22 23:53:36 +000025#endif
Tim Petersfe2127d2001-07-16 05:37:24 +000026
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020027#define PyPARSE_DONT_IMPLY_DEDENT 0x0002
Guido van Rossum4b499dd32003-02-13 22:07:59 +000028
Guido van Rossum45aecf42006-03-15 04:58:47 +000029#if 0
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020030#define PyPARSE_WITH_IS_KEYWORD 0x0003
Christian Heimes4d6ec852008-03-26 22:34:47 +000031#define PyPARSE_PRINT_IS_FUNCTION 0x0004
32#define PyPARSE_UNICODE_LITERALS 0x0008
Guido van Rossum45aecf42006-03-15 04:58:47 +000033#endif
Thomas Wouters34aa7ba2006-02-28 19:02:24 +000034
Benjamin Petersonf5b52242009-03-02 23:31:26 +000035#define PyPARSE_IGNORE_COOKIE 0x0010
Brett Cannone3944a52009-04-01 05:08:41 +000036#define PyPARSE_BARRY_AS_BDFL 0x0020
Guido van Rossumdcfcd142019-01-31 03:40:27 -080037#define PyPARSE_TYPE_COMMENTS 0x0040
Guido van Rossum495da292019-03-07 12:38:08 -080038#define PyPARSE_ASYNC_HACKS 0x0080
Benjamin Petersonf5b52242009-03-02 23:31:26 +000039
Martin v. Löwis95292d62002-12-11 14:04:59 +000040PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
Fred Drake5eb6d4e2000-07-08 23:37:28 +000041 perrdetail *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000042PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
Serhiy Storchakac6792272013-10-19 21:03:34 +030043 const char *, const char *,
44 perrdetail *);
Guido van Rossuma3309961993-07-28 09:05:47 +000045
Martin v. Löwis95292d62002-12-11 14:04:59 +000046PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
Tim Petersfe2127d2001-07-16 05:37:24 +000047 perrdetail *, int);
Victor Stinner14e461d2013-08-26 22:28:21 +020048PyAPI_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 Storchakac6792272013-10-19 21:03:34 +030054 const char *ps1,
55 const char *ps2,
Victor Stinner14e461d2013-08-26 22:28:21 +020056 perrdetail *err_ret,
57 int flags);
Victor Stinner00676d12010-12-27 01:49:31 +000058PyAPI_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 Storchakac6792272013-10-19 21:03:34 +030064 const char *ps1,
65 const char *ps2,
Victor Stinner00676d12010-12-27 01:49:31 +000066 perrdetail *err_ret,
67 int *flags);
Victor Stinner14e461d2013-08-26 22:28:21 +020068PyAPI_FUNC(node *) PyParser_ParseFileObject(
69 FILE *fp,
70 PyObject *filename,
71 const char *enc,
72 grammar *g,
73 int start,
Serhiy Storchakac6792272013-10-19 21:03:34 +030074 const char *ps1,
75 const char *ps2,
Victor Stinner14e461d2013-08-26 22:28:21 +020076 perrdetail *err_ret,
77 int *flags);
Tim Petersfe2127d2001-07-16 05:37:24 +000078
Victor Stinner14e461d2013-08-26 22:28:21 +020079PyAPI_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 Stinner00676d12010-12-27 01:49:31 +000086PyAPI_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 Stinner14e461d2013-08-26 22:28:21 +020093PyAPI_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 Rossumd3ab37f2003-04-17 14:55:42 +0000100
Victor Stinner7f2fee32011-04-05 00:39:01 +0200101/* Note that the following functions are defined in pythonrun.c,
102 not in parsetok.c */
Guido van Rossumd3ab37f2003-04-17 14:55:42 +0000103PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
Victor Stinner7f2fee32011-04-05 00:39:01 +0200104PyAPI_FUNC(void) PyParser_ClearError(perrdetail *);
Guido van Rossumd3ab37f2003-04-17 14:55:42 +0000105
Guido van Rossuma3309961993-07-28 09:05:47 +0000106#ifdef __cplusplus
107}
108#endif
109#endif /* !Py_PARSETOK_H */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000110#endif /* !Py_LIMITED_API */