@@ -114,7 +114,7 @@ set_ftstring_expr(struct tok_state* tok, struct token *token, char c) {
114
114
assert (c == '}' || c == ':' || c == '!' );
115
115
tokenizer_mode * tok_mode = TOK_GET_MODE (tok );
116
116
117
- if (!(tok_mode -> f_string_debug || tok_mode -> string_kind == TSTRING ) || token -> metadata ) {
117
+ if (!(tok_mode -> in_debug || tok_mode -> string_kind == TSTRING ) || token -> metadata ) {
118
118
return 0 ;
119
119
}
120
120
PyObject * res = NULL ;
@@ -981,33 +981,33 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
981
981
}
982
982
tokenizer_mode * the_current_tok = TOK_NEXT_MODE (tok );
983
983
the_current_tok -> kind = TOK_FSTRING_MODE ;
984
- the_current_tok -> f_string_quote = quote ;
985
- the_current_tok -> f_string_quote_size = quote_size ;
986
- the_current_tok -> f_string_start = tok -> start ;
987
- the_current_tok -> f_string_multi_line_start = tok -> line_start ;
988
- the_current_tok -> f_string_line_start = tok -> lineno ;
989
- the_current_tok -> f_string_start_offset = -1 ;
990
- the_current_tok -> f_string_multi_line_start_offset = -1 ;
984
+ the_current_tok -> quote = quote ;
985
+ the_current_tok -> quote_size = quote_size ;
986
+ the_current_tok -> start = tok -> start ;
987
+ the_current_tok -> multi_line_start = tok -> line_start ;
988
+ the_current_tok -> first_line = tok -> lineno ;
989
+ the_current_tok -> start_offset = -1 ;
990
+ the_current_tok -> multi_line_start_offset = -1 ;
991
991
the_current_tok -> last_expr_buffer = NULL ;
992
992
the_current_tok -> last_expr_size = 0 ;
993
993
the_current_tok -> last_expr_end = -1 ;
994
994
the_current_tok -> in_format_spec = 0 ;
995
- the_current_tok -> f_string_debug = 0 ;
995
+ the_current_tok -> in_debug = 0 ;
996
996
997
997
enum string_kind_t string_kind = FSTRING ;
998
998
switch (* tok -> start ) {
999
999
case 'T' :
1000
1000
case 't' :
1001
- the_current_tok -> f_string_raw = Py_TOLOWER (* (tok -> start + 1 )) == 'r' ;
1001
+ the_current_tok -> raw = Py_TOLOWER (* (tok -> start + 1 )) == 'r' ;
1002
1002
string_kind = TSTRING ;
1003
1003
break ;
1004
1004
case 'F' :
1005
1005
case 'f' :
1006
- the_current_tok -> f_string_raw = Py_TOLOWER (* (tok -> start + 1 )) == 'r' ;
1006
+ the_current_tok -> raw = Py_TOLOWER (* (tok -> start + 1 )) == 'r' ;
1007
1007
break ;
1008
1008
case 'R' :
1009
1009
case 'r' :
1010
- the_current_tok -> f_string_raw = 1 ;
1010
+ the_current_tok -> raw = 1 ;
1011
1011
if (Py_TOLOWER (* (tok -> start + 1 )) == 't' ) {
1012
1012
string_kind = TSTRING ;
1013
1013
}
@@ -1079,8 +1079,8 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
1079
1079
* and if it is, then this must be a missing '}' token
1080
1080
* so raise the proper error */
1081
1081
tokenizer_mode * the_current_tok = TOK_GET_MODE (tok );
1082
- if (the_current_tok -> f_string_quote == quote &&
1083
- the_current_tok -> f_string_quote_size == quote_size ) {
1082
+ if (the_current_tok -> quote == quote &&
1083
+ the_current_tok -> quote_size == quote_size ) {
1084
1084
return MAKE_TOKEN (_PyTokenizer_syntaxerror (tok ,
1085
1085
"%c-string: expecting '}'" , TOK_GET_STRING_PREFIX (tok )));
1086
1086
}
@@ -1153,7 +1153,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
1153
1153
int cursor = current_tok -> curly_bracket_depth - (c != '{' );
1154
1154
int in_format_spec = current_tok -> in_format_spec ;
1155
1155
int cursor_in_format_with_debug =
1156
- cursor == 1 && (current_tok -> f_string_debug || in_format_spec );
1156
+ cursor == 1 && (current_tok -> in_debug || in_format_spec );
1157
1157
int cursor_valid = cursor == 0 || cursor_in_format_with_debug ;
1158
1158
if ((cursor_valid ) && !_PyLexer_update_ftstring_expr (tok , c )) {
1159
1159
return MAKE_TOKEN (ENDMARKER );
@@ -1261,7 +1261,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
1261
1261
current_tok -> curly_bracket_expr_start_depth -- ;
1262
1262
current_tok -> kind = TOK_FSTRING_MODE ;
1263
1263
current_tok -> in_format_spec = 0 ;
1264
- current_tok -> f_string_debug = 0 ;
1264
+ current_tok -> in_debug = 0 ;
1265
1265
}
1266
1266
}
1267
1267
break ;
@@ -1274,7 +1274,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
1274
1274
}
1275
1275
1276
1276
if ( c == '=' && INSIDE_FSTRING_EXPR (current_tok )) {
1277
- current_tok -> f_string_debug = 1 ;
1277
+ current_tok -> in_debug = 1 ;
1278
1278
}
1279
1279
1280
1280
/* Punctuation character */
@@ -1317,9 +1317,9 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1317
1317
}
1318
1318
1319
1319
// Check if we are at the end of the string
1320
- for (int i = 0 ; i < current_tok -> f_string_quote_size ; i ++ ) {
1320
+ for (int i = 0 ; i < current_tok -> quote_size ; i ++ ) {
1321
1321
int quote = tok_nextc (tok );
1322
- if (quote != current_tok -> f_string_quote ) {
1322
+ if (quote != current_tok -> quote ) {
1323
1323
tok_backup (tok , quote );
1324
1324
goto f_string_middle ;
1325
1325
}
@@ -1342,7 +1342,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1342
1342
// TODO: This is a bit of a hack, but it works for now. We need to find a better way to handle
1343
1343
// this.
1344
1344
tok -> multi_line_start = tok -> line_start ;
1345
- while (end_quote_size != current_tok -> f_string_quote_size ) {
1345
+ while (end_quote_size != current_tok -> quote_size ) {
1346
1346
int c = tok_nextc (tok );
1347
1347
if (tok -> done == E_ERROR || tok -> done == E_DECODE ) {
1348
1348
return MAKE_TOKEN (ERRORTOKEN );
@@ -1353,7 +1353,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1353
1353
INSIDE_FSTRING_EXPR (current_tok )
1354
1354
);
1355
1355
1356
- if (c == EOF || (current_tok -> f_string_quote_size == 1 && c == '\n' )) {
1356
+ if (c == EOF || (current_tok -> quote_size == 1 && c == '\n' )) {
1357
1357
if (tok -> decoding_erred ) {
1358
1358
return MAKE_TOKEN (ERRORTOKEN );
1359
1359
}
@@ -1362,7 +1362,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1362
1362
// it means that the format spec ends here and we should
1363
1363
// return to the regular mode.
1364
1364
if (in_format_spec && c == '\n' ) {
1365
- if (current_tok -> f_string_quote_size == 1 ) {
1365
+ if (current_tok -> quote_size == 1 ) {
1366
1366
return MAKE_TOKEN (
1367
1367
_PyTokenizer_syntaxerror (
1368
1368
tok ,
@@ -1382,15 +1382,15 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1382
1382
// shift the tok_state's location into
1383
1383
// the start of string, and report the error
1384
1384
// from the initial quote character
1385
- tok -> cur = (char * )current_tok -> f_string_start ;
1385
+ tok -> cur = (char * )current_tok -> start ;
1386
1386
tok -> cur ++ ;
1387
- tok -> line_start = current_tok -> f_string_multi_line_start ;
1387
+ tok -> line_start = current_tok -> multi_line_start ;
1388
1388
int start = tok -> lineno ;
1389
1389
1390
1390
tokenizer_mode * the_current_tok = TOK_GET_MODE (tok );
1391
- tok -> lineno = the_current_tok -> f_string_line_start ;
1391
+ tok -> lineno = the_current_tok -> first_line ;
1392
1392
1393
- if (current_tok -> f_string_quote_size == 3 ) {
1393
+ if (current_tok -> quote_size == 3 ) {
1394
1394
_PyTokenizer_syntaxerror (tok ,
1395
1395
"unterminated triple-quoted %c-string literal"
1396
1396
" (detected at line %d)" ,
@@ -1407,7 +1407,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1407
1407
}
1408
1408
}
1409
1409
1410
- if (c == current_tok -> f_string_quote ) {
1410
+ if (c == current_tok -> quote ) {
1411
1411
end_quote_size += 1 ;
1412
1412
continue ;
1413
1413
} else {
@@ -1470,7 +1470,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1470
1470
// brace. We have to restore and return the control back
1471
1471
// to the loop for the next iteration.
1472
1472
if (peek == '{' || peek == '}' ) {
1473
- if (!current_tok -> f_string_raw ) {
1473
+ if (!current_tok -> raw ) {
1474
1474
if (_PyTokenizer_warn_invalid_escape_sequence (tok , peek )) {
1475
1475
return MAKE_TOKEN (ERRORTOKEN );
1476
1476
}
@@ -1479,7 +1479,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1479
1479
continue ;
1480
1480
}
1481
1481
1482
- if (!current_tok -> f_string_raw ) {
1482
+ if (!current_tok -> raw ) {
1483
1483
if (peek == 'N' ) {
1484
1484
/* Handle named unicode escapes (\N{BULLET}) */
1485
1485
peek = tok_nextc (tok );
@@ -1497,8 +1497,8 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
1497
1497
1498
1498
// Backup the f-string quotes to emit a final FSTRING_MIDDLE and
1499
1499
// add the quotes to the FSTRING_END in the next tokenizer iteration.
1500
- for (int i = 0 ; i < current_tok -> f_string_quote_size ; i ++ ) {
1501
- tok_backup (tok , current_tok -> f_string_quote );
1500
+ for (int i = 0 ; i < current_tok -> quote_size ; i ++ ) {
1501
+ tok_backup (tok , current_tok -> quote );
1502
1502
}
1503
1503
p_start = tok -> start ;
1504
1504
p_end = tok -> cur ;
0 commit comments