Coverage Report

Created: 2026-06-21 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Parser/pegen.h
Line
Count
Source
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
89.2k
#define PyPARSE_IGNORE_COOKIE 0x0010
23
3.39k
#define PyPARSE_BARRY_AS_BDFL 0x0020
24
107k
#define PyPARSE_TYPE_COMMENTS 0x0040
25
100k
#define PyPARSE_ALLOW_INCOMPLETE_INPUT 0x0100
26
27
393k
#define CURRENT_POS (-5)
28
29
6.42k
#define TOK_GET_MODE(tok) (&(tok->tok_mode_stack[tok->tok_mode_stack_index]))
30
21
#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
Py_ssize_t _PyPegen_byte_offset_to_character_offset_line(PyObject *line, Py_ssize_t col_offset, Py_ssize_t end_col_offset);
166
Py_ssize_t _PyPegen_byte_offset_to_character_offset(PyObject *line, Py_ssize_t col_offset);
167
Py_ssize_t _PyPegen_byte_offset_to_character_offset_raw(const char*, Py_ssize_t col_offset);
168
169
// Error handling functions and APIs
170
typedef enum {
171
    STAR_TARGETS,
172
    DEL_TARGETS,
173
    FOR_TARGETS
174
} TARGETS_TYPE;
175
176
int _Pypegen_raise_decode_error(Parser *p);
177
int _Pypegen_tokenizer_error(Parser *p);
178
void *_PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *errmsg, ...);
179
void *_PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
180
                                          Py_ssize_t lineno, Py_ssize_t col_offset,
181
                                          Py_ssize_t end_lineno, Py_ssize_t end_col_offset,
182
                                          const char *errmsg, va_list va);
183
void _Pypegen_set_syntax_error(Parser* p, Token* last_token);
184
void _Pypegen_stack_overflow(Parser *p);
185
186
static inline void *
187
RAISE_ERROR_KNOWN_LOCATION(Parser *p, PyObject *errtype,
188
                           Py_ssize_t lineno, Py_ssize_t col_offset,
189
                           Py_ssize_t end_lineno, Py_ssize_t end_col_offset,
190
                           const char *errmsg, ...)
191
97.8k
{
192
97.8k
    va_list va;
193
97.8k
    va_start(va, errmsg);
194
97.8k
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
195
97.8k
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
196
97.8k
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
197
97.8k
    va_end(va);
198
97.8k
    return NULL;
199
97.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
191
113
{
192
113
    va_list va;
193
113
    va_start(va, errmsg);
194
113
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
195
113
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
196
113
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
197
113
    va_end(va);
198
    return NULL;
199
113
}
pegen_errors.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
191
96.3k
{
192
96.3k
    va_list va;
193
96.3k
    va_start(va, errmsg);
194
96.3k
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
195
96.3k
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
196
96.3k
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
197
96.3k
    va_end(va);
198
    return NULL;
199
96.3k
}
parser.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
191
1.18k
{
192
1.18k
    va_list va;
193
1.18k
    va_start(va, errmsg);
194
1.18k
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
195
1.18k
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
196
1.18k
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
197
1.18k
    va_end(va);
198
    return NULL;
199
1.18k
}
action_helpers.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
191
200
{
192
200
    va_list va;
193
200
    va_start(va, errmsg);
194
200
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
195
200
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
196
200
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
197
200
    va_end(va);
198
    return NULL;
199
200
}
string_parser.c:RAISE_ERROR_KNOWN_LOCATION
Line
Count
Source
191
2
{
192
2
    va_list va;
193
2
    va_start(va, errmsg);
194
2
    Py_ssize_t _col_offset = (col_offset == CURRENT_POS ? CURRENT_POS : col_offset + 1);
195
2
    Py_ssize_t _end_col_offset = (end_col_offset == CURRENT_POS ? CURRENT_POS : end_col_offset + 1);
196
2
    _PyPegen_raise_error_known_location(p, errtype, lineno, _col_offset, end_lineno, _end_col_offset, errmsg, va);
197
2
    va_end(va);
198
    return NULL;
199
2
}
200
436
#define RAISE_SYNTAX_ERROR(msg, ...) _PyPegen_raise_error(p, PyExc_SyntaxError, 0, msg, ##__VA_ARGS__)
201
181
#define RAISE_INDENTATION_ERROR(msg, ...) _PyPegen_raise_error(p, PyExc_IndentationError, 0, msg, ##__VA_ARGS__)
202
650
#define RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN(msg, ...) _PyPegen_raise_error(p, PyExc_SyntaxError, 1, msg, ##__VA_ARGS__)
203
#define RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, msg, ...) \
204
162
    RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, (a)->lineno, (a)->col_offset, (b)->end_lineno, (b)->end_col_offset, msg, ##__VA_ARGS__)
205
#define RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, msg, ...) \
206
95.1k
    RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, (a)->lineno, (a)->col_offset, (a)->end_lineno, (a)->end_col_offset, msg, ##__VA_ARGS__)
207
#define RAISE_SYNTAX_ERROR_STARTING_FROM(a, msg, ...) \
208
491
    RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, (a)->lineno, (a)->col_offset, CURRENT_POS, CURRENT_POS, msg, ##__VA_ARGS__)
209
1.63k
#define RAISE_SYNTAX_ERROR_INVALID_TARGET(type, e) _RAISE_SYNTAX_ERROR_INVALID_TARGET(p, type, e)
210
211
Py_LOCAL_INLINE(void *)
212
CHECK_CALL(Parser *p, void *result)
213
99.5k
{
214
99.5k
    if (result == NULL) {
215
0
        assert(PyErr_Occurred());
216
0
        p->error_indicator = 1;
217
0
    }
218
99.5k
    return result;
219
99.5k
}
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
213
99.5k
{
214
99.5k
    if (result == NULL) {
215
        assert(PyErr_Occurred());
216
0
        p->error_indicator = 1;
217
0
    }
218
99.5k
    return result;
219
99.5k
}
Unexecuted instantiation: action_helpers.c:CHECK_CALL
Unexecuted instantiation: string_parser.c:CHECK_CALL
220
221
/* This is needed for helper functions that are allowed to
222
   return NULL without an error. Example: _PyPegen_seq_extract_starred_exprs */
223
Py_LOCAL_INLINE(void *)
224
CHECK_CALL_NULL_ALLOWED(Parser *p, void *result)
225
15.7k
{
226
15.7k
    if (result == NULL && PyErr_Occurred()) {
227
304
        p->error_indicator = 1;
228
304
    }
229
15.7k
    return result;
230
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
225
15.7k
{
226
15.7k
    if (result == NULL && PyErr_Occurred()) {
227
304
        p->error_indicator = 1;
228
304
    }
229
15.7k
    return result;
230
15.7k
}
Unexecuted instantiation: action_helpers.c:CHECK_CALL_NULL_ALLOWED
Unexecuted instantiation: string_parser.c:CHECK_CALL_NULL_ALLOWED
231
232
102k
#define CHECK(type, result) ((type) CHECK_CALL(p, result))
233
15.7k
#define CHECK_NULL_ALLOWED(type, result) ((type) CHECK_CALL_NULL_ALLOWED(p, result))
234
235
expr_ty _PyPegen_get_invalid_target(expr_ty e, TARGETS_TYPE targets_type);
236
const char *_PyPegen_get_expr_name(expr_ty);
237
Py_LOCAL_INLINE(void *)
238
_RAISE_SYNTAX_ERROR_INVALID_TARGET(Parser *p, TARGETS_TYPE type, void *e)
239
1.63k
{
240
1.63k
    expr_ty invalid_target = CHECK_NULL_ALLOWED(expr_ty, _PyPegen_get_invalid_target(e, type));
241
1.63k
    if (invalid_target != NULL) {
242
148
        const char *msg;
243
148
        if (type == STAR_TARGETS || type == FOR_TARGETS) {
244
133
            msg = "cannot assign to %s";
245
133
        }
246
15
        else {
247
15
            msg = "cannot delete %s";
248
15
        }
249
148
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
250
148
            invalid_target,
251
148
            msg,
252
148
            _PyPegen_get_expr_name(invalid_target)
253
148
        );
254
0
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(invalid_target, "invalid syntax");
255
148
    }
256
1.48k
    return NULL;
257
1.63k
}
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
239
1.63k
{
240
1.63k
    expr_ty invalid_target = CHECK_NULL_ALLOWED(expr_ty, _PyPegen_get_invalid_target(e, type));
241
1.63k
    if (invalid_target != NULL) {
242
148
        const char *msg;
243
148
        if (type == STAR_TARGETS || type == FOR_TARGETS) {
244
133
            msg = "cannot assign to %s";
245
133
        }
246
15
        else {
247
15
            msg = "cannot delete %s";
248
15
        }
249
148
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
250
148
            invalid_target,
251
148
            msg,
252
148
            _PyPegen_get_expr_name(invalid_target)
253
148
        );
254
0
        return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(invalid_target, "invalid syntax");
255
148
    }
256
1.48k
    return NULL;
257
1.63k
}
Unexecuted instantiation: action_helpers.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
Unexecuted instantiation: string_parser.c:_RAISE_SYNTAX_ERROR_INVALID_TARGET
258
259
// Action utility functions
260
261
void *_PyPegen_dummy_name(Parser *p, ...);
262
void * _PyPegen_seq_last_item(asdl_seq *seq);
263
7
#define PyPegen_last_item(seq, type) ((type)_PyPegen_seq_last_item((asdl_seq*)seq))
264
void * _PyPegen_seq_first_item(asdl_seq *seq);
265
#define PyPegen_first_item(seq, type) ((type)_PyPegen_seq_first_item((asdl_seq*)seq))
266
149M
#define UNUSED(expr) do { (void)(expr); } while (0)
267
192k
#define EXTRA_EXPR(head, tail) head->lineno, (head)->col_offset, (tail)->end_lineno, (tail)->end_col_offset, p->arena
268
12.1M
#define EXTRA _start_lineno, _start_col_offset, _end_lineno, _end_col_offset, p->arena
269
PyObject *_PyPegen_new_type_comment(Parser *, const char *);
270
271
Py_LOCAL_INLINE(PyObject *)
272
NEW_TYPE_COMMENT(Parser *p, Token *tc)
273
15.0k
{
274
15.0k
    if (tc == NULL) {
275
15.0k
        return NULL;
276
15.0k
    }
277
0
    const char *bytes = PyBytes_AsString(tc->bytes);
278
0
    if (bytes == NULL) {
279
0
        goto error;
280
0
    }
281
0
    PyObject *tco = _PyPegen_new_type_comment(p, bytes);
282
0
    if (tco == NULL) {
283
0
        goto error;
284
0
    }
285
0
    return tco;
286
0
 error:
287
0
    p->error_indicator = 1;  // Inline CHECK_CALL
288
0
    return NULL;
289
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
273
15.0k
{
274
15.0k
    if (tc == NULL) {
275
15.0k
        return NULL;
276
15.0k
    }
277
0
    const char *bytes = PyBytes_AsString(tc->bytes);
278
0
    if (bytes == NULL) {
279
0
        goto error;
280
0
    }
281
0
    PyObject *tco = _PyPegen_new_type_comment(p, bytes);
282
0
    if (tco == NULL) {
283
0
        goto error;
284
0
    }
285
0
    return tco;
286
0
 error:
287
0
    p->error_indicator = 1;  // Inline CHECK_CALL
288
    return NULL;
289
0
}
Unexecuted instantiation: action_helpers.c:NEW_TYPE_COMMENT
Unexecuted instantiation: string_parser.c:NEW_TYPE_COMMENT
290
291
Py_LOCAL_INLINE(void *)
292
INVALID_VERSION_CHECK(Parser *p, int version, char *msg, void *node)
293
25.1k
{
294
25.1k
    if (node == NULL) {
295
12
        p->error_indicator = 1;  // Inline CHECK_CALL
296
12
        return NULL;
297
12
    }
298
25.1k
    if (p->feature_version < version) {
299
0
        p->error_indicator = 1;
300
0
        return RAISE_SYNTAX_ERROR("%s only supported in Python 3.%i and greater",
301
0
                                  msg, version);
302
0
    }
303
25.1k
    return node;
304
25.1k
}
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
293
25.1k
{
294
25.1k
    if (node == NULL) {
295
12
        p->error_indicator = 1;  // Inline CHECK_CALL
296
12
        return NULL;
297
12
    }
298
25.1k
    if (p->feature_version < version) {
299
0
        p->error_indicator = 1;
300
0
        return RAISE_SYNTAX_ERROR("%s only supported in Python 3.%i and greater",
301
0
                                  msg, version);
302
0
    }
303
25.1k
    return node;
304
25.1k
}
Unexecuted instantiation: action_helpers.c:INVALID_VERSION_CHECK
Unexecuted instantiation: string_parser.c:INVALID_VERSION_CHECK
305
306
25.1k
#define CHECK_VERSION(type, version, msg, node) ((type) INVALID_VERSION_CHECK(p, version, msg, node))
307
308
arg_ty _PyPegen_add_type_comment_to_arg(Parser *, arg_ty, Token *);
309
PyObject *_PyPegen_new_identifier(Parser *, const char *);
310
asdl_seq *_PyPegen_singleton_seq(Parser *, void *);
311
asdl_seq *_PyPegen_seq_insert_in_front(Parser *, void *, asdl_seq *);
312
asdl_seq *_PyPegen_seq_append_to_end(Parser *, asdl_seq *, void *);
313
asdl_seq *_PyPegen_seq_flatten(Parser *, asdl_seq *);
314
expr_ty _PyPegen_join_names_with_dot(Parser *, expr_ty, expr_ty);
315
int _PyPegen_seq_count_dots(asdl_seq *);
316
alias_ty _PyPegen_alias_for_star(Parser *, int, int, int, int, PyArena *);
317
asdl_identifier_seq *_PyPegen_map_names_to_ids(Parser *, asdl_expr_seq *);
318
CmpopExprPair *_PyPegen_cmpop_expr_pair(Parser *, cmpop_ty, expr_ty);
319
asdl_int_seq *_PyPegen_get_cmpops(Parser *p, asdl_seq *);
320
asdl_expr_seq *_PyPegen_get_exprs(Parser *, asdl_seq *);
321
expr_ty _PyPegen_set_expr_context(Parser *, expr_ty, expr_context_ty);
322
KeyValuePair *_PyPegen_key_value_pair(Parser *, expr_ty, expr_ty);
323
asdl_expr_seq *_PyPegen_get_keys(Parser *, asdl_seq *);
324
asdl_expr_seq *_PyPegen_get_values(Parser *, asdl_seq *);
325
KeyPatternPair *_PyPegen_key_pattern_pair(Parser *, expr_ty, pattern_ty);
326
asdl_expr_seq *_PyPegen_get_pattern_keys(Parser *, asdl_seq *);
327
asdl_pattern_seq *_PyPegen_get_patterns(Parser *, asdl_seq *);
328
NameDefaultPair *_PyPegen_name_default_pair(Parser *, arg_ty, expr_ty, Token *);
329
SlashWithDefault *_PyPegen_slash_with_default(Parser *, asdl_arg_seq *, asdl_seq *);
330
StarEtc *_PyPegen_star_etc(Parser *, arg_ty, asdl_seq *, arg_ty);
331
arguments_ty _PyPegen_make_arguments(Parser *, asdl_arg_seq *, SlashWithDefault *,
332
                                     asdl_arg_seq *, asdl_seq *, StarEtc *);
333
arguments_ty _PyPegen_empty_arguments(Parser *);
334
expr_ty _PyPegen_template_str(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b);
335
expr_ty _PyPegen_joined_str(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b);
336
expr_ty _PyPegen_interpolation(Parser *, expr_ty, Token *, ResultTokenWithMetadata *, ResultTokenWithMetadata *, Token *,
337
                                 int, int, int, int, PyArena *);
338
expr_ty _PyPegen_formatted_value(Parser *, expr_ty, Token *, ResultTokenWithMetadata *, ResultTokenWithMetadata *, Token *,
339
                                 int, int, int, int, PyArena *);
340
AugOperator *_PyPegen_augoperator(Parser*, operator_ty type);
341
stmt_ty _PyPegen_function_def_decorators(Parser *, asdl_expr_seq *, stmt_ty);
342
stmt_ty _PyPegen_class_def_decorators(Parser *, asdl_expr_seq *, stmt_ty);
343
KeywordOrStarred *_PyPegen_keyword_or_starred(Parser *, void *, int);
344
asdl_expr_seq *_PyPegen_seq_extract_starred_exprs(Parser *, asdl_seq *);
345
asdl_keyword_seq *_PyPegen_seq_delete_starred_exprs(Parser *, asdl_seq *);
346
expr_ty _PyPegen_collect_call_seqs(Parser *, asdl_expr_seq *, asdl_seq *,
347
                     int lineno, int col_offset, int end_lineno,
348
                     int end_col_offset, PyArena *arena);
349
expr_ty _PyPegen_constant_from_token(Parser* p, Token* tok);
350
expr_ty _PyPegen_decoded_constant_from_token(Parser* p, Token* tok);
351
expr_ty _PyPegen_constant_from_string(Parser* p, Token* tok);
352
expr_ty _PyPegen_concatenate_tstrings(Parser *p, asdl_expr_seq *, int, int, int, int, PyArena *);
353
expr_ty _PyPegen_concatenate_strings(Parser *p, asdl_expr_seq *, int, int, int, int, PyArena *);
354
expr_ty _PyPegen_FetchRawForm(Parser *p, int, int, int, int);
355
expr_ty _PyPegen_ensure_imaginary(Parser *p, expr_ty);
356
expr_ty _PyPegen_ensure_real(Parser *p, expr_ty);
357
asdl_seq *_PyPegen_join_sequences(Parser *, asdl_seq *, asdl_seq *);
358
int _PyPegen_check_barry_as_flufl(Parser *, Token *);
359
int _PyPegen_check_legacy_stmt(Parser *p, expr_ty t);
360
void *_PyPegen_raise_error_for_missing_comma(Parser *p, expr_ty a, expr_ty b);
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, expr_ty, 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 *, PyObject *);
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