blob: 911dfc10e400eee4f82fe33d3a1ce6fb2b07b564 [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
Tim Petersfe2127d2001-07-16 05:37:24 +000024#define PyPARSE_YIELD_IS_KEYWORD 0x0001
Neil Schemenauerc24ea082002-03-22 23:53:36 +000025#endif
Tim Petersfe2127d2001-07-16 05:37:24 +000026
Guido van Rossum4b499dd32003-02-13 22:07:59 +000027#define PyPARSE_DONT_IMPLY_DEDENT 0x0002
28
Guido van Rossum45aecf42006-03-15 04:58:47 +000029#if 0
Thomas Wouters34aa7ba2006-02-28 19:02:24 +000030#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,
Fred Drake5eb6d4e2000-07-08 23:37:28 +000041 char *, char *, perrdetail *);
Guido van Rossuma3309961993-07-28 09:05:47 +000042
Martin v. Löwis95292d62002-12-11 14:04:59 +000043PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
Tim Petersfe2127d2001-07-16 05:37:24 +000044 perrdetail *, int);
Victor Stinner00676d12010-12-27 01:49:31 +000045PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *,
Martin v. Löwis85bcc662007-09-04 09:18:06 +000046 const char*, grammar *,
Tim Petersfe2127d2001-07-16 05:37:24 +000047 int, char *, char *,
48 perrdetail *, int);
Victor Stinner00676d12010-12-27 01:49:31 +000049PyAPI_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 char *ps1,
56 char *ps2,
57 perrdetail *err_ret,
58 int *flags);
Tim Petersfe2127d2001-07-16 05:37:24 +000059
Martin v. Löwis95292d62002-12-11 14:04:59 +000060PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *,
61 const char *,
Thomas Heller6b17abf2002-07-09 09:23:27 +000062 grammar *, int,
63 perrdetail *, int);
Victor Stinner00676d12010-12-27 01:49:31 +000064PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
65 const char *s,
66 const char *filename, /* decoded from the filesystem encoding */
67 grammar *g,
68 int start,
69 perrdetail *err_ret,
70 int *flags);
Guido van Rossumd3ab37f2003-04-17 14:55:42 +000071
Victor Stinner7f2fee32011-04-05 00:39:01 +020072/* Note that the following functions are defined in pythonrun.c,
73 not in parsetok.c */
Guido van Rossumd3ab37f2003-04-17 14:55:42 +000074PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
Victor Stinner7f2fee32011-04-05 00:39:01 +020075PyAPI_FUNC(void) PyParser_ClearError(perrdetail *);
Guido van Rossumd3ab37f2003-04-17 14:55:42 +000076
Guido van Rossuma3309961993-07-28 09:05:47 +000077#ifdef __cplusplus
78}
79#endif
80#endif /* !Py_PARSETOK_H */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000081#endif /* !Py_LIMITED_API */