blob: 4b7694f90f1abd5eb1d41f4913843b2732df67af [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 Stinner00676d12010-12-27 01:49:31 +000012 const char *filename; /* decoded from the filesystem encoding */
Fred Drake5eb6d4e2000-07-08 23:37:28 +000013 int lineno;
14 int offset;
Victor Stinner00676d12010-12-27 01:49:31 +000015 char *text; /* UTF-8-encoded string */
Fred Drake85f36392000-07-11 17:53:00 +000016 int token;
17 int expected;
Guido van Rossumb6775db1994-08-01 11:34:53 +000018} perrdetail;
19
Neil Schemenauerc24ea082002-03-22 23:53:36 +000020#if 0
Tim Petersfe2127d2001-07-16 05:37:24 +000021#define PyPARSE_YIELD_IS_KEYWORD 0x0001
Neil Schemenauerc24ea082002-03-22 23:53:36 +000022#endif
Tim Petersfe2127d2001-07-16 05:37:24 +000023
Guido van Rossum4b499dd32003-02-13 22:07:59 +000024#define PyPARSE_DONT_IMPLY_DEDENT 0x0002
25
Guido van Rossum45aecf42006-03-15 04:58:47 +000026#if 0
Thomas Wouters34aa7ba2006-02-28 19:02:24 +000027#define PyPARSE_WITH_IS_KEYWORD 0x0003
Christian Heimes4d6ec852008-03-26 22:34:47 +000028#define PyPARSE_PRINT_IS_FUNCTION 0x0004
29#define PyPARSE_UNICODE_LITERALS 0x0008
Guido van Rossum45aecf42006-03-15 04:58:47 +000030#endif
Thomas Wouters34aa7ba2006-02-28 19:02:24 +000031
Benjamin Petersonf5b52242009-03-02 23:31:26 +000032#define PyPARSE_IGNORE_COOKIE 0x0010
Brett Cannone3944a52009-04-01 05:08:41 +000033#define PyPARSE_BARRY_AS_BDFL 0x0020
Benjamin Petersonf5b52242009-03-02 23:31:26 +000034
Martin v. Löwis95292d62002-12-11 14:04:59 +000035PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
Fred Drake5eb6d4e2000-07-08 23:37:28 +000036 perrdetail *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000037PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
Fred Drake5eb6d4e2000-07-08 23:37:28 +000038 char *, char *, perrdetail *);
Guido van Rossuma3309961993-07-28 09:05:47 +000039
Martin v. Löwis95292d62002-12-11 14:04:59 +000040PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
Tim Petersfe2127d2001-07-16 05:37:24 +000041 perrdetail *, int);
Victor Stinner00676d12010-12-27 01:49:31 +000042PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *,
Martin v. Löwis85bcc662007-09-04 09:18:06 +000043 const char*, grammar *,
Tim Petersfe2127d2001-07-16 05:37:24 +000044 int, char *, char *,
45 perrdetail *, int);
Victor Stinner00676d12010-12-27 01:49:31 +000046PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
47 FILE *fp,
48 const char *filename, /* decoded from the filesystem encoding */
49 const char *enc,
50 grammar *g,
51 int start,
52 char *ps1,
53 char *ps2,
54 perrdetail *err_ret,
55 int *flags);
Tim Petersfe2127d2001-07-16 05:37:24 +000056
Martin v. Löwis95292d62002-12-11 14:04:59 +000057PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *,
58 const char *,
Thomas Heller6b17abf2002-07-09 09:23:27 +000059 grammar *, int,
60 perrdetail *, int);
Victor Stinner00676d12010-12-27 01:49:31 +000061PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
62 const char *s,
63 const char *filename, /* decoded from the filesystem encoding */
64 grammar *g,
65 int start,
66 perrdetail *err_ret,
67 int *flags);
Guido van Rossumd3ab37f2003-04-17 14:55:42 +000068
69/* Note that he following function is defined in pythonrun.c not parsetok.c. */
70PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
71
Guido van Rossuma3309961993-07-28 09:05:47 +000072#ifdef __cplusplus
73}
74#endif
75#endif /* !Py_PARSETOK_H */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000076#endif /* !Py_LIMITED_API */