PY-31442 Better handling of single backslashes (e.g. before braces) in literal parts

There is actually no need to match them together with braces and then return
the second character back to the stream. The longest match rule will ensure
that all allowed escape sequences will be recognised as one unit, so it seems
safe to match backslash individually for all remaining cases.
This commit is contained in:
Mikhail Golubev
2018-10-01 12:46:45 +03:00
parent 2e8b9f7a9f
commit 6c49b63b11
4 changed files with 399 additions and 409 deletions
@@ -5,7 +5,7 @@ PyFile:UnterminatedFStringWithTrailingBackslashInFormatPart.py
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyStringLiteralExpression: {42:
PyStringLiteralExpression: {42:\
PyFormattedStringNode
PsiElement(Py:FSTRING_START)('f'')
PyFStringFragment
@@ -14,8 +14,8 @@ PyFile:UnterminatedFStringWithTrailingBackslashInFormatPart.py
PsiElement(Py:INTEGER_LITERAL)('42')
PyFStringFragmentFormatPart
PsiElement(Py:FSTRING_FRAGMENT_FORMAT_START)(':')
PsiElement(Py:FSTRING_TEXT)('\')
PsiErrorElement:} expected
<empty list>
PsiElement(BAD_CHARACTER)('\')
PsiErrorElement:Statement expected, found BAD_CHARACTER
<empty list>
PsiErrorElement:' expected
<empty list>
@@ -5,11 +5,9 @@ PyFile:UnterminatedFStringWithTrailingBackslashInLiteralPart.py
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyStringLiteralExpression:
PyStringLiteralExpression: \
PyFormattedStringNode
PsiElement(Py:FSTRING_START)('f'')
PsiErrorElement:unexpected f-string token
<empty list>
PsiElement(BAD_CHARACTER)('\')
PsiErrorElement:Statement expected, found BAD_CHARACTER
<empty list>
PsiElement(Py:FSTRING_TEXT)('\')
PsiErrorElement:' expected
<empty list>