Skip to content

Commit 860f81d

Browse files
committed
Simplify grammar
1 parent 860caea commit 860f81d

File tree

2 files changed

+182
-184
lines changed

2 files changed

+182
-184
lines changed

Grammar/python.gram

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,10 +1557,8 @@ invalid_tstring_conversion_character:
15571557
| '!' !NAME { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("t-string: invalid conversion character") }
15581558

15591559
invalid_string_tstring_concat:
1560-
| (fstring|string)+ a=tstring+ {
1561-
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(PyPegen_first_item(a, expr_ty), "cannot mix t-strings with strings or f-strings") }
1562-
| tstring+ a=(fstring|string)+ {
1563-
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(PyPegen_first_item(a, expr_ty), "cannot mix t-strings with strings or f-strings") }
1560+
| (fstring|string)+ a[expr_ty]=tstring { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot mix t-strings with strings or f-strings") }
1561+
| tstring+ a[expr_ty]=(fstring|string) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot mix t-strings with strings or f-strings") }
15641562

15651563
invalid_arithmetic:
15661564
| sum ('+'|'-'|'*'|'/'|'%'|'//'|'@') a='not' b=inversion { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }

0 commit comments

Comments
 (0)