diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-04-19 16:18:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 16:18:16 (GMT) |
commit | 1ef61cf71a218c71860ff6aecf0fd51edb8b65dc (patch) | |
tree | d0c4995cac9cb660b66498419d528254f26baf54 /Parser/string_parser.h | |
parent | a6b07b5a345f7f54ee9f6d75e81d2fb55971b35c (diff) | |
download | cpython-1ef61cf71a218c71860ff6aecf0fd51edb8b65dc.zip cpython-1ef61cf71a218c71860ff6aecf0fd51edb8b65dc.tar.gz cpython-1ef61cf71a218c71860ff6aecf0fd51edb8b65dc.tar.bz2 |
gh-102856: Initial implementation of PEP 701 (#102855)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Diffstat (limited to 'Parser/string_parser.h')
-rw-r--r-- | Parser/string_parser.h | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/Parser/string_parser.h b/Parser/string_parser.h index 4a22f3d..0b34de1 100644 --- a/Parser/string_parser.h +++ b/Parser/string_parser.h @@ -5,42 +5,7 @@ #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 *); +PyObject *_PyPegen_parse_string(Parser *, Token *); +PyObject *_PyPegen_decode_string(Parser *, int, const char *, size_t, Token *); #endif |