Coverage Report

Created: 2025-10-10 06:33

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