FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Parser/string_parser.h at 3.11 · python/cpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
cpython
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
35.3k
Star
74.9k
Code
Issues
5k+
Pull requests
2.6k
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Parser
/
string_parser.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (39 loc) · 1.77 KB
Breadcrumbs
cpython
/
Parser
/
string_parser.h
Copy path
File metadata and controls
46 lines (39 loc) · 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef
STRINGS_H
#define
STRINGS_H
#include
<Python.h>
#include
<pycore_ast.h>
#include
"pegen.h"
#define
EXPRLIST_N_CACHED
64
typedef
struct
{
/* Incrementally build an array of expr_ty, so be used in an
asdl_seq. Cache some small but reasonably sized number of
expr_ty's, and then after that start dynamically allocating,
doubling the number allocated each time. Note that the f-string
f'{0}a{1}' contains 3 expr_ty's: 2 FormattedValue's, and one
Constant for the literal 'a'. So you add expr_ty's about twice as
fast as you add expressions in an f-string. */
Py_ssize_t
allocated
;
/* Number we've allocated. */
Py_ssize_t
size
;
/* Number we've used. */
expr_ty
*
p
;
/* Pointer to the memory we're actually
using. Will point to 'data' until we
start dynamically allocating. */
expr_ty
data
[
EXPRLIST_N_CACHED
];
}
ExprList
;
/* The FstringParser is designed to add a mix of strings and
f-strings, and concat them together as needed. Ultimately, it
generates an expr_ty. */
typedef
struct
{
PyObject
*
last_str
;
ExprList
expr_list
;
int
fmode
;
}
FstringParser
;
void
_PyPegen_FstringParser_Init
(
FstringParser
*
);
int
_PyPegen_parsestr
(
Parser
*
,
int
*
,
int
*
,
PyObject
*
*
,
const
char
*
*
,
Py_ssize_t
*
,
Token
*
);
int
_PyPegen_FstringParser_ConcatFstring
(
Parser
*
,
FstringParser
*
,
const
char
*
*
,
const
char
*
,
int
,
int
,
Token
*
,
Token
*
,
Token
*
);
int
_PyPegen_FstringParser_ConcatAndDel
(
FstringParser
*
,
PyObject
*
);
expr_ty
_PyPegen_FstringParser_Finish
(
Parser
*
,
FstringParser
*
,
Token
*
,
Token
*
);
void
_PyPegen_FstringParser_Dealloc
(
FstringParser
*
);
#endif
Back
|
FazBrowse Home
|
New Git URL