blob: c9407a3f7020fe73549ec0e943307c652c505a4e [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002/* Parser-tokenizer link interface */
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
Guido van Rossumb6775db1994-08-01 11:34:53 +000010typedef struct {
Fred Drake5eb6d4e2000-07-08 23:37:28 +000011 int error;
Victor Stinner7f2fee32011-04-05 00:39:01 +020012#ifndef PGEN
13 /* The filename is useless for pgen, see comment in tok_state structure */
14 PyObject *filename;
15#endif
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
Benjamin Petersonf5b52242009-03-02 23:31:26 +000037
Martin v. Löwis95292d62002-12-11 14:04:59 +000038PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
Fred Drake5eb6d4e2000-07-08 23:37:28 +000039 perrdetail *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000040PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
Serhiy Storchakac6792272013-10-19 21:03:34 +030041 const char *, const char *,
42 perrdetail *);
Guido van Rossuma3309961993-07-28 09:05:47 +000043
Martin v. Löwis95292d62002-12-11 14:04:59 +000044PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
Tim Petersfe2127d2001-07-16 05:37:24 +000045 perrdetail *, int);
Victor Stinner14e461d2013-08-26 22:28:21 +020046PyAPI_FUNC(node *) PyParser_ParseFileFlags(
47 FILE *fp,
48 const char *filename, /* decoded from the filesystem encoding */
49 const char *enc,
50 grammar *g,
51 int start,
Serhiy Storchakac6792272013-10-19 21:03:34 +030052 const char *ps1,
53 const char *ps2,
Victor Stinner14e461d2013-08-26 22:28:21 +020054 perrdetail *err_ret,
55 int flags);
Victor Stinner00676d12010-12-27 01:49:31 +000056PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
57 FILE *fp,
58 const char *filename, /* decoded from the filesystem encoding */
59 const char *enc,
60 grammar *g,
61 int start,
Serhiy Storchakac6792272013-10-19 21:03:34 +030062 const char *ps1,
63 const char *ps2,
Victor Stinner00676d12010-12-27 01:49:31 +000064 perrdetail *err_ret,
65 int *flags);
Victor Stinner14e461d2013-08-26 22:28:21 +020066PyAPI_FUNC(node *) PyParser_ParseFileObject(
67 FILE *fp,
68 PyObject *filename,
69 const char *enc,
70 grammar *g,
71 int start,
Serhiy Storchakac6792272013-10-19 21:03:34 +030072 const char *ps1,
73 const char *ps2,
Victor Stinner14e461d2013-08-26 22:28:21 +020074 perrdetail *err_ret,
75 int *flags);
Tim Petersfe2127d2001-07-16 05:37:24 +000076
Victor Stinner14e461d2013-08-26 22:28:21 +020077PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(
78 const char *s,
79 const char *filename, /* decoded from the filesystem encoding */
80 grammar *g,
81 int start,
82 perrdetail *err_ret,
83 int flags);
Victor Stinner00676d12010-12-27 01:49:31 +000084PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
85 const char *s,
86 const char *filename, /* decoded from the filesystem encoding */
87 grammar *g,
88 int start,
89 perrdetail *err_ret,
90 int *flags);
Victor Stinner14e461d2013-08-26 22:28:21 +020091PyAPI_FUNC(node *) PyParser_ParseStringObject(
92 const char *s,
93 PyObject *filename,
94 grammar *g,
95 int start,
96 perrdetail *err_ret,
97 int *flags);
Guido van Rossumd3ab37f2003-04-17 14:55:42 +000098
Victor Stinner7f2fee32011-04-05 00:39:01 +020099/* Note that the following functions are defined in pythonrun.c,
100 not in parsetok.c */
Guido van Rossumd3ab37f2003-04-17 14:55:42 +0000101PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
Victor Stinner7f2fee32011-04-05 00:39:01 +0200102PyAPI_FUNC(void) PyParser_ClearError(perrdetail *);
Guido van Rossumd3ab37f2003-04-17 14:55:42 +0000103
Guido van Rossuma3309961993-07-28 09:05:47 +0000104#ifdef __cplusplus
105}
106#endif
107#endif /* !Py_PARSETOK_H */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000108#endif /* !Py_LIMITED_API */