mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31442 Parse simplest possible f-strings together with other expressions
- no nested f-strings - no formatting parts after colon - no illegal escapes detection - no quote mismatch detection
This commit is contained in:
@@ -0,0 +1 @@
|
||||
s = f'{{}} {{{42}}} }} {{'
|
||||
@@ -0,0 +1,18 @@
|
||||
PyFile:FStringEscapedBraces.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PsiElement(Py:FSTRING_TEXT)('{{}} {{')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_TEXT)('}} }} {{')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -0,0 +1 @@
|
||||
s = f'{ {1, 2} }'
|
||||
@@ -0,0 +1,25 @@
|
||||
PyFile:FStringExpressionContainBraces.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PySetLiteralExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('1')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('2')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -0,0 +1,3 @@
|
||||
s = ('foo'
|
||||
f'{42} {True}'
|
||||
ur'bar')
|
||||
@@ -0,0 +1,29 @@
|
||||
PyFile:FStringGluedWithLiteralStringNodes.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParenthesizedExpression
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyStringLiteralExpression: foobar
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''foo'')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiWhiteSpace(' ')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyBoolLiteralExpression
|
||||
PsiElement(Py:TRUE_KEYWORD)('True')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('ur'bar'')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
@@ -0,0 +1 @@
|
||||
s = f'foo{42}bar'
|
||||
@@ -0,0 +1,18 @@
|
||||
PyFile:FStringWithSimpleFragment.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PsiElement(Py:FSTRING_TEXT)('foo')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_TEXT)('bar')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -6,7 +6,9 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('f''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace(' \n')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s2
|
||||
@@ -15,7 +17,9 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('fr''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('fr'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace('\n')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s3
|
||||
@@ -24,7 +28,9 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('rf''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('rf'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace('\n')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s4
|
||||
@@ -33,7 +39,9 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('F''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('F'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace('\n')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s5
|
||||
@@ -42,7 +50,9 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('bf''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('bf'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace('\n')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s6
|
||||
@@ -51,7 +61,9 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('uf''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('uf'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiWhiteSpace('\n')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s7
|
||||
@@ -60,4 +72,6 @@ PyFile:FStrings.py
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('ufr''')
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('ufr'')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
Reference in New Issue
Block a user