parsetok.h 2.89 KB
Newer Older
Guido van Rossum's avatar
Guido van Rossum committed
1
/* Parser-tokenizer link interface */
2

3
#ifndef Py_LIMITED_API
4 5 6 7 8 9
#ifndef Py_PARSETOK_H
#define Py_PARSETOK_H
#ifdef __cplusplus
extern "C" {
#endif

10 11 12
#include "grammar.h"      /* grammar */
#include "node.h"         /* node */

13
typedef struct {
14
    int error;
15
    PyObject *filename;
16 17
    int lineno;
    int offset;
18
    char *text;                 /* UTF-8-encoded string */
19 20
    int token;
    int expected;
21 22
} perrdetail;

23
#if 0
24
#define PyPARSE_YIELD_IS_KEYWORD        0x0001
25
#endif
26

27
#define PyPARSE_DONT_IMPLY_DEDENT       0x0002
28

29
#if 0
30
#define PyPARSE_WITH_IS_KEYWORD         0x0003
31 32
#define PyPARSE_PRINT_IS_FUNCTION       0x0004
#define PyPARSE_UNICODE_LITERALS        0x0008
33
#endif
34

35
#define PyPARSE_IGNORE_COOKIE 0x0010
36
#define PyPARSE_BARRY_AS_BDFL 0x0020
37
#define PyPARSE_TYPE_COMMENTS 0x0040
38
#define PyPARSE_ASYNC_HACKS   0x0080
39

40
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
41
                                              perrdetail *);
42
PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
43 44
                                             const char *, const char *,
                                             perrdetail *);
45

46
PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
47
                                              perrdetail *, int);
48 49 50 51 52 53
PyAPI_FUNC(node *) PyParser_ParseFileFlags(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    const char *enc,
    grammar *g,
    int start,
54 55
    const char *ps1,
    const char *ps2,
56 57
    perrdetail *err_ret,
    int flags);
58 59 60 61 62 63
PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    const char *enc,
    grammar *g,
    int start,
64 65
    const char *ps1,
    const char *ps2,
66 67
    perrdetail *err_ret,
    int *flags);
68 69 70 71 72 73
PyAPI_FUNC(node *) PyParser_ParseFileObject(
    FILE *fp,
    PyObject *filename,
    const char *enc,
    grammar *g,
    int start,
74 75
    const char *ps1,
    const char *ps2,
76 77
    perrdetail *err_ret,
    int *flags);
78

79 80 81 82 83 84 85
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(
    const char *s,
    const char *filename,       /* decoded from the filesystem encoding */
    grammar *g,
    int start,
    perrdetail *err_ret,
    int flags);
86 87 88 89 90 91 92
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
    const char *s,
    const char *filename,       /* decoded from the filesystem encoding */
    grammar *g,
    int start,
    perrdetail *err_ret,
    int *flags);
93 94 95 96 97 98 99
PyAPI_FUNC(node *) PyParser_ParseStringObject(
    const char *s,
    PyObject *filename,
    grammar *g,
    int start,
    perrdetail *err_ret,
    int *flags);
100

101 102
/* Note that the following functions are defined in pythonrun.c,
   not in parsetok.c */
103
PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
104
PyAPI_FUNC(void) PyParser_ClearError(perrdetail *);
105

106 107 108 109
#ifdef __cplusplus
}
#endif
#endif /* !Py_PARSETOK_H */
110
#endif /* !Py_LIMITED_API */