@@ -4499,6 +4499,30 @@ compiler_joined_str(struct compiler *c, expr_ty e)
4499
4499
return SUCCESS ;
4500
4500
}
4501
4501
4502
+ /* Used to implement tag strings */
4503
+ static int
4504
+ compiler_tag_string (struct compiler * c , expr_ty e )
4505
+ {
4506
+ location loc = LOC (e );
4507
+ if (e -> kind == TagString_kind ) {
4508
+ expr_ty tag = e -> v .TagString .tag ;
4509
+ expr_ty str = e -> v .TagString .str ;
4510
+ if (tag -> kind == Name_kind ) {
4511
+ if (str -> kind == JoinedStr_kind ) {
4512
+ // Generate code for tag(str1, str2, ...)
4513
+ asdl_keyword_seq * keywords =
4514
+ _Py_asdl_keyword_seq_new (0 , c -> c_arena );
4515
+ if (keywords == NULL )
4516
+ return 0 ;
4517
+ ADDOP (c , loc , PUSH_NULL );
4518
+ VISIT (c , expr , tag );
4519
+ return compiler_call_helper (c , loc , 0 , str -> v .JoinedStr .values , keywords );
4520
+ }
4521
+ }
4522
+ }
4523
+ return compiler_error (c , loc , "More complicated tag-string not yet supported" );
4524
+ }
4525
+
4502
4526
/* Used to implement f-strings. Format a single value. */
4503
4527
static int
4504
4528
compiler_formatted_value (struct compiler * c , expr_ty e )
@@ -5420,6 +5444,8 @@ compiler_visit_expr1(struct compiler *c, expr_ty e)
5420
5444
break ;
5421
5445
case JoinedStr_kind :
5422
5446
return compiler_joined_str (c , e );
5447
+ case TagString_kind :
5448
+ return compiler_tag_string (c , e );
5423
5449
case FormattedValue_kind :
5424
5450
return compiler_formatted_value (c , e );
5425
5451
/* The following exprs can be assignment targets. */
0 commit comments