Coverage Report

Created: 2025-07-04 06:49

/src/cpython/Parser/pegen.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef PEGEN_H
2
#define PEGEN_H
3
4
#include <Python.h>
5
#include <pycore_ast.h>
6
#include <pycore_token.h>
7
8
#include "lexer/state.h"
9
10
#if 0
11
#define PyPARSE_YIELD_IS_KEYWORD        0x0001
12
#endif
13
14
0
#define PyPARSE_DONT_IMPLY_DEDENT       0x0002
15
16
#if 0
17
#define PyPARSE_WITH_IS_KEYWORD         0x0003
18
#define PyPARSE_PRINT_IS_FUNCTION       0x0004
19
#define PyPARSE_UNICODE_LITERALS        0x0008
20
#endif
21
22
43
#define PyPARSE_IGNORE_COOKIE 0x0010
23
4.26k
#define PyPARSE_BARRY_AS_BDFL 0x0020
24
21.5k
#define PyPARSE_TYPE_COMMENTS 0x0040
25
13.6k
#define PyPARSE_ALLOW_INCOMPLETE_INPUT 0x0100
26
27
47.0k
#define CURRENT_POS (-5)
28
29
12
#define TOK_GET_MODE(tok) (&(tok->tok_mode_stack[tok->tok_mode_stack_index]))
30
12
#define TOK_GET_STRING_PREFIX(tok) (TOK_GET_MODE(tok)->string_kind == TSTRING ? 't' : 'f')
31
32
typedef struct _memo {
33
    int type;
34
    void *node;
35
    int mark;
36
    struct _memo *next;
37
} Memo;
38
39
typedef struct {
40
    int type;
41
    PyObject *bytes;
42
    int level;
43
    int lineno, col_offset, end_lineno, end_col_offset;
44
    Memo *memo;
45
    PyObject *metadata;
46
} Token;
47
48
typedef struct {
49
    const char *str;
50
    int type;
51
} KeywordToken;
52
53
54
typedef struct {
55
    struct {
56
        int lineno;
57
        char *comment;  // The " <tag>" in "# type: ignore <tag>"
58
    } *items;
59
    size_t size;
60
    size_t num_items;
61
} growable_comment_array;
62
63
typedef struct {
64
    int lineno;
65
    int col_offset;
66
    int end_lineno;
67
    int end_col_offset;
68
} location;
69
70
typedef struct {
71
    struct tok_state *tok;
72
    Token **tokens;
73
    int mark;
74
    int fill, size;
75
    PyArena *arena;
76
    KeywordToken **keywords;
77
    char **soft_keywords;
78
    int n_keyword_lists;
79
    int start_rule;
80
    int *errcode;
81
    int parsing_started;
82
    PyObject* normalize;
83
    int starting_lineno;
84
    int starting_col_offset;
85
    int error_indicator;
86
    int flags;
87
    int feature_version;
88
    growable_comment_array type_ignore_comments;
89
    Token *known_err_token;
90
    int level;
91
    int call_invalid_rules;
92
    int debug;
93
    location last_stmt_location;
94
} Parser;
95
96
typedef struct {
97
    cmpop_ty cmpop;
98
    expr_ty expr;
99
} CmpopExprPair;
100
101
typedef struct {
102
    expr_ty key;
103
    expr_ty value;
104
} KeyValuePair;
105
106
typedef struct {
107
    expr_ty key;
108
    pattern_ty pattern;
109
} KeyPatternPair;
110
111
typedef struct {
112
    arg_ty arg;
113
    expr_ty value;
114
} NameDefaultPair;
115
116
typedef struct {
117
    asdl_arg_seq *plain_names;
118
    asdl_seq *names_with_defaults; // asdl_seq* of NameDefaultsPair's
119
} SlashWithDefault;
120
121
typedef struct {
122
    arg_ty vararg;
123
    asdl_seq *kwonlyargs; // asdl_seq* of NameDefaultsPair's
124
    arg_ty kwarg;
125
} StarEtc;
126
127
typedef struct { operator_ty kind; } AugOperator;
128
typedef struct {
129
    void *element;
130
    int is_keyword;
131
} KeywordOrStarred;
132
133
typedef struct {
134
    void *result;
135
    PyObject *metadata;
136
} ResultTokenWithMetadata;
137
138
// Internal parser functions
139
#if defined(Py_DEBUG)
140
void _PyPegen_clear_memo_statistics(void);
141
PyObject *_PyPegen_get_memo_statistics(void);
142
#endif
143
144
int _PyPegen_insert_memo(Parser *p, int mark, int type, void *node);
145
int _PyPegen_update_memo(Parser *p, int mark, int type, void *node);
146
int _PyPegen_is_memoized(Parser *p, int type, void *pres);
147
148
int _PyPegen_lookahead(int, void *(func)(Parser *), Parser *);
149
int _PyPegen_lookahead_for_expr(int, expr_ty (func)(Parser *), Parser *);
150
int _PyPegen_lookahead_for_stmt(int, stmt_ty (func)(Parser *), Parser *);
151
int _PyPegen_lookahead_with_int(int, Token *(func)(Parser *, int), Parser *, int);
152
int _PyPegen_lookahead_with_string(int, expr_ty (func)(Parser *, const char*), Parser *, const char*);
153
154
Token *_PyPegen_expect_token(Parser *p, int type);
155
void* _PyPegen_expect_forced_result(Parser *p, void* result, const char* expected);
156
Token *_PyPegen_expect_forced_token(Parser *p, int type, const char* expected);
157
expr_ty _PyPegen_expect_soft_keyword(Parser *p, const char *keyword);
158
expr_ty _PyPegen_soft_keyword_token(Parser *p);
159
expr_ty _PyPegen_fstring_middle_token(Parser* p);
160
Token *_PyPegen_get_last_nonnwhitespace_token(Parser *);
161
int _PyPegen_fill_token(Parser *p);
162
expr_ty _PyPegen_name_token(Parser *p);
163
expr_ty _PyPegen_number_token(Parser *p);
164
void *_PyPegen_string_token(Parser *p);
165
PyObject *_PyPegen_set_source_in_metadata(Parser *p, Token *t);
166
Py_ssize_t _PyPegen_byte_offset_to_character_offset_line(PyObject *line, Py_ssize_t col_offset, Py_ssize_t end_col_offset);
167
Py_ssize_t _PyPegen_byte_offset_to_character_offset(PyObject *line, Py_ssize_t col_offset);
168
Py_ssize_t _PyPegen_byte_offset_to_character_offset_raw(const char*, Py_ssize_t col_offset);
169
170
// Error handling functions and APIs
171
typedef enum {
172
    STAR_TARGETS,
173
    DEL_TARGETS,
174
    FOR_TARGETS
175
} TARGETS_TYPE;
176
177
int _Pypegen_raise_decode_error(Parser *p);
178
void _PyPegen_raise_tokenizer_init_error(PyObject *filename);
179
int _Pypegen_tokenizer_error(Parser *p);
180
void *_PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *errmsg, ...);
181
void *_PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
182
                                          Py_ssize_t lineno, Py_ssize_t col_offset,
183
                                          Py_ssize_t end_lineno, Py_ssize_t end_col_offset,
184
                                          const char *errmsg, va_list va);
185
void _Pypegen_set_syntax_error(Parser* p, Token* last_token);
186
void _Pypegen_stack_overflow(Parser *p);
187
188
static inline void *
189
RAISE_ERROR_KNOWN_LOCATION(Parser *p, PyObject *errtype,
190
                           Py_ssize_t lineno, Py_ssize_t col_offset,
191
                           Py_ssize_t end_lineno, Py_ssize_t end_col_offset,
192
                           const char *errmsg, ...)
193
10.8k
{
194
10.8k
    va_list va;
195
10.8k
    va_start(va, errmsg);
196
10.8k
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
197
10.8k
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
198
10.8k
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
199
10.8k
    va_end(va);
200
10.8k
    return NULL;
201
10.8k
}
Unexecuted instantiation: peg_api.c:RAISE_ERROR_KNOWN_LOCATION
Unexecuted instantiation: Python-tokenize.c:RAISE_ERROR_KNOWN_LOCATION
pegen.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
193
154
{
194
154
    va_list va;
195
154
    va_start(va, errmsg);
196
154
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
197
154
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
198
154
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
199
154
    va_end(va);
200
154
    return NULL;
201
154
}
pegen_errors.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
193
8.66k
{
194
8.66k
    va_list va;
195
8.66k
    va_start(va, errmsg);
196
8.66k
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
197
8.66k
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
198
8.66k
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
199
8.66k
    va_end(va);
200
8.66k
    return NULL;
201
8.66k
}
parser.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
193
1.95k
{
194
1.95k
    va_list va;
195
1.95k
    va_start(va, errmsg);
196
1.95k
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
197
1.95k
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
198
1.95k
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
199
1.95k
    va_end(va);
200
1.95k
    return NULL;
201
1.95k
}
action_helpers.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
193
23
{
194
23
    va_list va;
195
23
    va_start(va, errmsg);
196
23
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
197
23
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
198
23
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
199
23
    va_end(va);
200
23
    return NULL;
201
23
}
string_parser.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
193
12
{
194
12
    va_list va;
195
12
    va_start(va, errmsg);
196
12
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
197
12
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
198
12
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
199
12
    va_end(va);
200
12
    return NULL;
201
12
}
202
1.54k
#define RAISE_SYNTAX_ERROR(msg, ...) _PyPegen_raise_error(p, PyExc_SyntaxError, 0, msg, ##__VA_ARGS__)
203
302
#define RAISE_INDENTATION_ERROR(msg, ...) _PyPegen_raise_error(p, PyExc_IndentationError, 0, msg, ##__VA_ARGS__)
204
863
#define RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN(msg, ...) _PyPegen_raise_error(p, PyExc_SyntaxError, 1, msg, ##__VA_ARGS__)
205
#define RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, msg, ...) \
206
6.03k
    RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, (a)->lineno, (a)->col_offset, (b)->end_lineno, (b)->end_col_offset, msg, ##__VA_ARGS__)
207
#define RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, msg, ...) \
208
7.38k
    RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, (a)->lineno, (a)->col_offset, (a)->end_lineno, (a)->end_col_offset, msg, ##__VA_ARGS__)
209
#define RAISE_SYNTAX_ERROR_STARTING_FROM(a, msg, ...) \
210
613
    RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, (a)->lineno, (a)->col_offset, CURRENT_POS, CURRENT_POS, msg, ##__VA_ARGS__)
211
1.74k
#define RAISE_SYNTAX_ERROR_INVALID_TARGET(type, e) _RAISE_SYNTAX_ERROR_INVALID_TARGET(p, type, e)
212
213
Py_LOCAL_INLINE(void *)
214
CHECK_CALL(Parser *p, void *result)
215
123k
{
216
123k
    if (result == NULL) {
217
0
        assert(PyErr_Occurred());
218
0
        p->error_indicator = 1;
219
0
    }
220
123k
    return result;
221
123k
}
Unexecuted instantiation: peg_api.c:CHECK_CALL
Unexecuted instantiation: Python-tokenize.c:CHECK_CALL
Unexecuted instantiation: pegen.c:CHECK_CALL
Unexecuted instantiation: pegen_errors.c:CHECK_CALL
parser.c:CHECK_CALL
Line
Count
Source
215
123k
{
216
123k
    if (result == NULL) {
217
0
        assert(PyErr_Occurred());
218
0
        p->error_indicator = 1;
219
0
    }
220
123k
    return result;
221
123k
}
Unexecuted instantiation: action_helpers.c:CHECK_CALL
Unexecuted instantiation: string_parser.c:CHECK_CALL
222
223
/* This is needed for helper functions that are allowed to
224
   return NULL without an error. Example: _PyPegen_seq_extract_starred_exprs */
225
Py_LOCAL_INLINE(void *)
226
CHECK_CALL_NULL_ALLOWED(Parser *p, void *result)
227
15.7k
{
228
15.7k
    if (result == NULL && PyErr_Occurred()) {
229
408
        p->error_indicator = 1;
230
408
    }
231
15.7k
    return result;
232
15.7k
}
Unexecuted instantiation: peg_api.c:CHECK_CALL_NULL_ALLOWED
Unexecuted instantiation: Python-tokenize.c:CHECK_CALL_NULL_ALLOWED
Unexecuted instantiation: pegen.c:CHECK_CALL_NULL_ALLOWED
Unexecuted instantiation: pegen_errors.c:CHECK_CALL_NULL_ALLOWED
parser.c:CHECK_CALL_NULL_ALLOWED
Line
Count
Source
227
15.7k
{
228
15.7k
    if (result == NULL && PyErr_Occurred()) {
229
408
        p->error_indicator = 1;
230
408
    }
231
15.7k
    return result;
232
15.7k
}
Unexecuted instantiation: action_helpers.c:CHECK_CALL_NULL_ALLOWED
Unexecuted instantiation: string_parser.c:CHECK_CALL_NULL_ALLOWED
233
234
129k
#define CHECK(type, result) ((type) CHECK_CALL(p, result))
235
15.7k
#define CHECK_NULL_ALLOWED(type, result) ((type) CHECK_CALL_NULL_ALLOWED(p, result))
236
237
expr_ty _PyPegen_get_invalid_target(expr_ty e, TARGETS_TYPE targets_type);
238
const char *_PyPegen_get_expr_name(expr_ty);
239
Py_LOCAL_INLINE(void *)
240
_RAISE_SYNTAX_ERROR_INVALID_TARGET(Parser *p, TARGETS_TYPE type, void *e)
241
1.74k
{
242
1.74k
    expr_ty invalid_target = CHECK_NULL_ALLOWED(expr_ty, _PyPegen_get_invalid_target(e, type));
243
1.74k
    if (invalid_target != NULL) {
244
145
        const char *msg;
245
145
        if (type == STAR_TARGETS || type == FOR_TARGETS) {
246
132
            msg = "cannot assign to %s";
247
132
        }
248
13
        else {
249
13
            msg = "cannot delete %s";
250
13
        }
251
145
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
252
145
            invalid_target,
253
145
            msg,
254
145
            _PyPegen_get_expr_name(invalid_target)
255
145
        );
256
0
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(invalid_target, "invalid syntax");
257
145
    }
258
1.60k
    return NULL;
259
1.74k
}
Unexecuted instantiation: peg_api.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
Unexecuted instantiation: Python-tokenize.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
Unexecuted instantiation: pegen.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
Unexecuted instantiation: pegen_errors.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
parser.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
Line
Count
Source
241
1.74k
{
242
1.74k
    expr_ty invalid_target = CHECK_NULL_ALLOWED(expr_ty, _PyPegen_get_invalid_target(e, type));
243
1.74k
    if (invalid_target != NULL) {
244
145
        const char *msg;
245
145
        if (type == STAR_TARGETS || type == FOR_TARGETS) {
246
132
            msg = "cannot assign to %s";
247
132
        }
248
13
        else {
249
13
            msg = "cannot delete %s";
250
13
        }
251
145
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
252
145
            invalid_target,
253
145
            msg,
254
145
            _PyPegen_get_expr_name(invalid_target)
255
145
        );
256
0
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(invalid_target, "invalid syntax");
257
145
    }
258
1.60k
    return NULL;
259
1.74k
}
Unexecuted instantiation: action_helpers.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
Unexecuted instantiation: string_parser.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
260
261
// Action utility functions
262
263
void *_PyPegen_dummy_name(Parser *p, ...);
264
void * _PyPegen_seq_last_item(asdl_seq *seq);
265
6
#define PyPegen_last_item(seq, type) ((type)_PyPegen_seq_last_item((asdl_seq*)seq))
266
void * _PyPegen_seq_first_item(asdl_seq *seq);
267
#define PyPegen_first_item(seq, type) ((type)_PyPegen_seq_first_item((asdl_seq*)seq))
268
57.2M
#define UNUSED(expr) do { (void)(expr); } while (0)
269
237k
#define EXTRA_EXPR(head, tail) head->lineno, (head)->col_offset, (tail)->end_lineno, (tail)->end_col_offset, p->arena
270
1.56M
#define EXTRA _start_lineno, _start_col_offset, _end_lineno, _end_col_offset, p->arena
271
PyObject *_PyPegen_new_type_comment(Parser *, const char *);
272
273
Py_LOCAL_INLINE(PyObject *)
274
NEW_TYPE_COMMENT(Parser *p, Token *tc)
275
28.0k
{
276
28.0k
    if (tc == NULL) {
277
28.0k
        return NULL;
278
28.0k
    }
279
0
    const char *bytes = PyBytes_AsString(tc->bytes);
280
0
    if (bytes == NULL) {
281
0
        goto error;
282
0
    }
283
0
    PyObject *tco = _PyPegen_new_type_comment(p, bytes);
284
0
    if (tco == NULL) {
285
0
        goto error;
286
0
    }
287
0
    return tco;
288
0
 error:
289
0
    p->error_indicator = 1;  // Inline CHECK_CALL
290
0
    return NULL;
291
0
}
Unexecuted instantiation: peg_api.c:NEW_TYPE_COMMENT
Unexecuted instantiation: Python-tokenize.c:NEW_TYPE_COMMENT
Unexecuted instantiation: pegen.c:NEW_TYPE_COMMENT
Unexecuted instantiation: pegen_errors.c:NEW_TYPE_COMMENT
parser.c:NEW_TYPE_COMMENT
Line
Count
Source
275
28.0k
{
276
28.0k
    if (tc == NULL) {
277
28.0k
        return NULL;
278
28.0k
    }
279
0
    const char *bytes = PyBytes_AsString(tc->bytes);
280
0
    if (bytes == NULL) {
281
0
        goto error;
282
0
    }
283
0
    PyObject *tco = _PyPegen_new_type_comment(p, bytes);
284
0
    if (tco == NULL) {
285
0
        goto error;
286
0
    }
287
0
    return tco;
288
0
 error:
289
0
    p->error_indicator = 1;  // Inline CHECK_CALL
290
0
    return NULL;
291
0
}
Unexecuted instantiation: action_helpers.c:NEW_TYPE_COMMENT
Unexecuted instantiation: string_parser.c:NEW_TYPE_COMMENT
292
293
Py_LOCAL_INLINE(void *)
294
INVALID_VERSION_CHECK(Parser *p, int version, char *msg, void *node)
295
25.2k
{
296
25.2k
    if (node == NULL) {
297
10
        p->error_indicator = 1;  // Inline CHECK_CALL
298
10
        return NULL;
299
10
    }
300
25.2k
    if (p->feature_version < version) {
301
0
        p->error_indicator = 1;
302
0
        return RAISE_SYNTAX_ERROR("%s only supported in Python 3.%i and greater",
303
0
                                  msg, version);
304
0
    }
305
25.2k
    return node;
306
25.2k
}
Unexecuted instantiation: peg_api.c:INVALID_VERSION_CHECK
Unexecuted instantiation: Python-tokenize.c:INVALID_VERSION_CHECK
Unexecuted instantiation: pegen.c:INVALID_VERSION_CHECK
Unexecuted instantiation: pegen_errors.c:INVALID_VERSION_CHECK
parser.c:INVALID_VERSION_CHECK
Line
Count
Source
295
25.2k
{
296
25.2k
    if (node == NULL) {
297
10
        p->error_indicator = 1;  // Inline CHECK_CALL
298
10
        return NULL;
299
10
    }
300
25.2k
    if (p->feature_version < version) {
301
0
        p->error_indicator = 1;
302
0
        return RAISE_SYNTAX_ERROR("%s only supported in Python 3.%i and greater",
303
0
                                  msg, version);
304
0
    }
305
25.2k
    return node;
306
25.2k
}
Unexecuted instantiation: action_helpers.c:INVALID_VERSION_CHECK
Unexecuted instantiation: string_parser.c:INVALID_VERSION_CHECK
307
308
25.2k
#define CHECK_VERSION(type, version, msg, node) ((type) INVALID_VERSION_CHECK(p, version, msg, node))
309
310
arg_ty _PyPegen_add_type_comment_to_arg(Parser *, arg_ty, Token *);
311
PyObject *_PyPegen_new_identifier(Parser *, const char *);
312
asdl_seq *_PyPegen_singleton_seq(Parser *, void *);
313
asdl_seq *_PyPegen_seq_insert_in_front(Parser *, void *, asdl_seq *);
314
asdl_seq *_PyPegen_seq_append_to_end(Parser *, asdl_seq *, void *);
315
asdl_seq *_PyPegen_seq_flatten(Parser *, asdl_seq *);
316
expr_ty _PyPegen_join_names_with_dot(Parser *, expr_ty, expr_ty);
317
int _PyPegen_seq_count_dots(asdl_seq *);
318
alias_ty _PyPegen_alias_for_star(Parser *, int, int, int, int, PyArena *);
319
asdl_identifier_seq *_PyPegen_map_names_to_ids(Parser *, asdl_expr_seq *);
320
CmpopExprPair *_PyPegen_cmpop_expr_pair(Parser *, cmpop_ty, expr_ty);
321
asdl_int_seq *_PyPegen_get_cmpops(Parser *p, asdl_seq *);
322
asdl_expr_seq *_PyPegen_get_exprs(Parser *, asdl_seq *);
323
expr_ty _PyPegen_set_expr_context(Parser *, expr_ty, expr_context_ty);
324
KeyValuePair *_PyPegen_key_value_pair(Parser *, expr_ty, expr_ty);
325
asdl_expr_seq *_PyPegen_get_keys(Parser *, asdl_seq *);
326
asdl_expr_seq *_PyPegen_get_values(Parser *, asdl_seq *);
327
KeyPatternPair *_PyPegen_key_pattern_pair(Parser *, expr_ty, pattern_ty);
328
asdl_expr_seq *_PyPegen_get_pattern_keys(Parser *, asdl_seq *);
329
asdl_pattern_seq *_PyPegen_get_patterns(Parser *, asdl_seq *);
330
NameDefaultPair *_PyPegen_name_default_pair(Parser *, arg_ty, expr_ty, Token *);
331
SlashWithDefault *_PyPegen_slash_with_default(Parser *, asdl_arg_seq *, asdl_seq *);
332
StarEtc *_PyPegen_star_etc(Parser *, arg_ty, asdl_seq *, arg_ty);
333
arguments_ty _PyPegen_make_arguments(Parser *, asdl_arg_seq *, SlashWithDefault *,
334
                                     asdl_arg_seq *, asdl_seq *, StarEtc *);
335
arguments_ty _PyPegen_empty_arguments(Parser *);
336
expr_ty _PyPegen_template_str(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b);
337
expr_ty _PyPegen_joined_str(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b);
338
expr_ty _PyPegen_interpolation(Parser *, expr_ty, Token *, ResultTokenWithMetadata *, ResultTokenWithMetadata *, Token *,
339
                                 int, int, int, int, PyArena *);
340
expr_ty _PyPegen_formatted_value(Parser *, expr_ty, Token *, ResultTokenWithMetadata *, ResultTokenWithMetadata *, Token *,
341
                                 int, int, int, int, PyArena *);
342
AugOperator *_PyPegen_augoperator(Parser*, operator_ty type);
343
stmt_ty _PyPegen_function_def_decorators(Parser *, asdl_expr_seq *, stmt_ty);
344
stmt_ty _PyPegen_class_def_decorators(Parser *, asdl_expr_seq *, stmt_ty);
345
KeywordOrStarred *_PyPegen_keyword_or_starred(Parser *, void *, int);
346
asdl_expr_seq *_PyPegen_seq_extract_starred_exprs(Parser *, asdl_seq *);
347
asdl_keyword_seq *_PyPegen_seq_delete_starred_exprs(Parser *, asdl_seq *);
348
expr_ty _PyPegen_collect_call_seqs(Parser *, asdl_expr_seq *, asdl_seq *,
349
                     int lineno, int col_offset, int end_lineno,
350
                     int end_col_offset, PyArena *arena);
351
expr_ty _PyPegen_constant_from_token(Parser* p, Token* tok);
352
expr_ty _PyPegen_decoded_constant_from_token(Parser* p, Token* tok);
353
expr_ty _PyPegen_constant_from_string(Parser* p, Token* tok);
354
expr_ty _PyPegen_concatenate_strings(Parser *p, asdl_expr_seq *, int, int, int, int, PyArena *);
355
expr_ty _PyPegen_FetchRawForm(Parser *p, int, int, int, int);
356
expr_ty _PyPegen_ensure_imaginary(Parser *p, expr_ty);
357
expr_ty _PyPegen_ensure_real(Parser *p, expr_ty);
358
asdl_seq *_PyPegen_join_sequences(Parser *, asdl_seq *, asdl_seq *);
359
int _PyPegen_check_barry_as_flufl(Parser *, Token *);
360
int _PyPegen_check_legacy_stmt(Parser *p, expr_ty t);
361
ResultTokenWithMetadata *_PyPegen_check_fstring_conversion(Parser *p, Token *, expr_ty t);
362
ResultTokenWithMetadata *_PyPegen_setup_full_format_spec(Parser *, Token *, asdl_expr_seq *, int, int,
363
                                                         int, int, PyArena *);
364
mod_ty _PyPegen_make_module(Parser *, asdl_stmt_seq *);
365
void *_PyPegen_arguments_parsing_error(Parser *, expr_ty);
366
expr_ty _PyPegen_get_last_comprehension_item(comprehension_ty comprehension);
367
void *_PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args, asdl_comprehension_seq *comprehensions);
368
stmt_ty _PyPegen_checked_future_import(Parser *p, identifier module, asdl_alias_seq *,
369
                                       int , int, int , int , int , PyArena *);
370
asdl_stmt_seq* _PyPegen_register_stmts(Parser *p, asdl_stmt_seq* stmts);
371
stmt_ty _PyPegen_register_stmt(Parser *p, stmt_ty s);
372
373
// Parser API
374
375
Parser *_PyPegen_Parser_New(struct tok_state *, int, int, int, int *, const char*, PyArena *);
376
void _PyPegen_Parser_Free(Parser *);
377
mod_ty _PyPegen_run_parser_from_file_pointer(FILE *, int, PyObject *, const char *,
378
                                    const char *, const char *, PyCompilerFlags *, int *, PyObject **,
379
                                    PyArena *);
380
void *_PyPegen_run_parser(Parser *);
381
mod_ty _PyPegen_run_parser_from_string(const char *, int, PyObject *, PyCompilerFlags *, PyArena *);
382
asdl_stmt_seq *_PyPegen_interactive_exit(Parser *);
383
384
// Generated function in parse.c - function definition in python.gram
385
void *_PyPegen_parse(Parser *);
386
387
#endif