mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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>
This commit is contained in:
parent
a6b07b5a34
commit
1ef61cf71a
27 changed files with 8859 additions and 6573 deletions
|
@ -33,6 +33,31 @@ struct token {
|
|||
const char *start, *end;
|
||||
};
|
||||
|
||||
enum tokenizer_mode_kind_t {
|
||||
TOK_REGULAR_MODE,
|
||||
TOK_FSTRING_MODE,
|
||||
};
|
||||
|
||||
#define MAX_EXPR_NESTING 3
|
||||
|
||||
typedef struct _tokenizer_mode {
|
||||
enum tokenizer_mode_kind_t kind;
|
||||
|
||||
int bracket_stack;
|
||||
int bracket_mark[MAX_EXPR_NESTING];
|
||||
int bracket_mark_index;
|
||||
|
||||
char f_string_quote;
|
||||
int f_string_quote_size;
|
||||
int f_string_raw;
|
||||
const char* f_string_start;
|
||||
const char* f_string_multi_line_start;
|
||||
|
||||
Py_ssize_t last_expr_size;
|
||||
Py_ssize_t last_expr_end;
|
||||
char* last_expr_buffer;
|
||||
} tokenizer_mode;
|
||||
|
||||
/* Tokenizer state */
|
||||
struct tok_state {
|
||||
/* Input state; buf <= cur <= inp <= end */
|
||||
|
@ -93,6 +118,10 @@ struct tok_state {
|
|||
/* How to proceed when asked for a new token in interactive mode */
|
||||
enum interactive_underflow_t interactive_underflow;
|
||||
int report_warnings;
|
||||
// TODO: Factor this into its own thing
|
||||
tokenizer_mode tok_mode_stack[MAXLEVEL];
|
||||
int tok_mode_stack_index;
|
||||
int tok_report_warnings;
|
||||
#ifdef Py_DEBUG
|
||||
int debug;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue