mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
Merge 850a2316d9825f47e65bab4f249cbae508969d3a into a494ce1c64a2637719a5c1339abf19ec7c48089c
This commit is contained in:
commit
22187c08a4
@ -155,6 +155,33 @@ syn region pythonRawString matchgroup=pythonTripleQuotes
|
||||
\ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
|
||||
\ contains=pythonSpaceError,pythonDoctest,@Spell
|
||||
|
||||
" F-strings (formatted string literals)
|
||||
" https://docs.python.org/3/reference/lexical_analysis.html#f-strings
|
||||
syn region pythonFString
|
||||
\ matchgroup=pythonQuotes
|
||||
\ start=/\cF\z(['"]\)/
|
||||
\ end=/\z1/
|
||||
\ skip=/\\\\\|\\\z1/
|
||||
\ contains=pythonFStringField,pythonEscape,@Spell
|
||||
syn region pythonFString
|
||||
\ matchgroup=pythonTripleQuotes
|
||||
\ start=/\cF\z('''\|"""\)/
|
||||
\ end=/\z1/
|
||||
\ contains=pythonFStringField,pythonEscape,pythonSpaceError,pythonDoctest,@Spell
|
||||
\ keepend
|
||||
syn region pythonRawFString
|
||||
\ matchgroup=pythonQuotes
|
||||
\ start=/\c\%(FR\|RF\)\z(['"]\)/
|
||||
\ end=/\z1/
|
||||
\ skip=/\\\\\|\\\z1/
|
||||
\ contains=pythonFStringField,@Spell
|
||||
syn region pythonRawFString
|
||||
\ matchgroup=pythonTripleQuotes
|
||||
\ start=/\c\%(FR\|RF\)\z('''\|"""\)/
|
||||
\ end=/\z1/
|
||||
\ contains=pythonFStringField,pythonSpaceError,pythonDoctest,@Spell
|
||||
\ keepend
|
||||
|
||||
syn match pythonEscape +\\[abfnrtv'"\\]+ contained
|
||||
syn match pythonEscape "\\\o\{1,3}" contained
|
||||
syn match pythonEscape "\\x\x\{2}" contained
|
||||
@ -163,6 +190,26 @@ syn match pythonEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained
|
||||
syn match pythonEscape "\\N{\a\+\%(\s\a\+\)*}" contained
|
||||
syn match pythonEscape "\\$"
|
||||
|
||||
" F-string replacement fields
|
||||
"
|
||||
" `skip` is complicated because:
|
||||
"
|
||||
" - Format specifications may include nested replacement fields
|
||||
"
|
||||
" { \_[^}]\+ }
|
||||
"
|
||||
" - Python 3.12 allows comments in f-string fields, but `#` is also a format
|
||||
" specification - https://docs.python.org/3/library/string.html#formatspec
|
||||
"
|
||||
" \%( : \%( .\= [<>=^] \)\= [-+ ]\= \)\@4<! #.* $
|
||||
"
|
||||
syn region pythonFStringField
|
||||
\ matchgroup=pythonFStringDelim
|
||||
\ start=/{\@1<!{{\@!/
|
||||
\ end=/}/
|
||||
\ skip=/{\_[^}]\+}\|\%(:\%(.\=[<>=^]\)\=[-+ ]\=\)\@4<!#.*$/
|
||||
\ contained
|
||||
|
||||
" It is very important to understand all details before changing the
|
||||
" regular expressions below or their order.
|
||||
" The word boundaries are *not* the floating-point number boundaries
|
||||
@ -312,9 +359,13 @@ hi def link pythonComment Comment
|
||||
hi def link pythonTodo Todo
|
||||
hi def link pythonString String
|
||||
hi def link pythonRawString String
|
||||
hi def link pythonFString String
|
||||
hi def link pythonRawFString String
|
||||
hi def link pythonQuotes String
|
||||
hi def link pythonTripleQuotes pythonQuotes
|
||||
hi def link pythonEscape Special
|
||||
hi def link pythonFStringField Identifier
|
||||
hi def link pythonFStringDelim Special
|
||||
if !exists("python_no_number_highlight")
|
||||
hi def link pythonNumber Number
|
||||
endif
|
||||
|
20
runtime/syntax/testdir/dumps/python3_fstrings_00.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_00.dump
Normal file
@ -0,0 +1,20 @@
|
||||
>#+0#0000e05#ffffff0| |F|-|s|t|r|i|n|g|s| |(|f|o|r|m|a|t@1|e|d| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s|)| +0#0000000&@35
|
||||
|#+0#0000e05&| |h|t@1|p|s|:|/@1|d|o|c|s|.|p|y|t|h|o|n|.|o|r|g|/|3|/|r|e|f|e|r|e|n|c|e|/|l|e|x|i|c|a|l|_|a|n|a|l|y|s|i|s|.|h|t|m|l|#|f|-|s|t|r|i|n|g|s| +0#0000000&@5
|
||||
@75
|
||||
|#+0#0000e05&| |S|t|r|i|n|g|s| +0#0000000&@65
|
||||
|t|e|s|t| |=| |'+0#e000002&|S|i|n|g|l|e|-|q|u|o|t|e|d| |s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|'| +0#e000002&|a|n|d| |\+0#e000e06&|0|4| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d| |{
|
||||
|t|w|o|}|'| +0#0000000&@69
|
||||
|t|e|s|t| |=| |"+0#e000002&|D|o|u|b|l|e|-|q|u|o|t|e|d| |s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|"| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d|
|
||||
|{|t|w|o|}|"| +0#0000000&@68
|
||||
|t|e|s|t| |=| |'+0#e000002&@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |s|t|r|i|n|g| +0#0000000&@44
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4| +0#0000000&@51
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d| |{|t|w|o|}|'@2| +0#0000000&@45
|
||||
|t|e|s|t| |=| |"+0#e000002&@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |s|t|r|i|n|g| +0#0000000&@44
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@50
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d| |{|t|w|o|}|"@2| +0#0000000&@45
|
||||
@75
|
||||
|#+0#0000e05&| |R|a|w| |s|t|r|i|n|g|s| +0#0000000&@61
|
||||
|t|e|s|t| |=| |r+0#e000002&|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|'| |a|n|d| |\|0|4| |a|n|d| |f|i|e|l|d|s| |{|o|n|@+0#4040ff13&@2
|
||||
| +0#0000000&@56|1|,|1| @10|T|o|p|
|
20
runtime/syntax/testdir/dumps/python3_fstrings_01.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_01.dump
Normal file
@ -0,0 +1,20 @@
|
||||
|w+0#e000002#ffffff0|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@50
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d| |{|t|w|o|}|"@2| +0#0000000&@45
|
||||
@75
|
||||
|#+0#0000e05&| |R|a|w| |s|t|r|i|n|g|s| +0#0000000&@61
|
||||
>t|e|s|t| |=| |r+0#e000002&|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|'| |a|n|d| |\|0|4| |a|n|d| |f|i|e|l|d|s| |{|o|n|e|}|
|
||||
|a|n|d| |{|t|w|o|}|'| +0#0000000&@64
|
||||
|t|e|s|t| |=| |R+0#e000002&|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |r|a|w| |s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|"| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{|o|n|e|}
|
||||
| |a|n|d| |{|t|w|o|}|"| +0#0000000&@63
|
||||
|t|e|s|t| |=| |r+0#e000002&|'@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |r|a|w| |s|t|r|i|n|g| +0#0000000&@39
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\|t| |a|n|d| |\|0|4| +0#0000000&@51
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d| |{|t|w|o|}|'@2| +0#0000000&@45
|
||||
|t|e|s|t| |=| |R+0#e000002&|"@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |r|a|w| |s|t|r|i|n|g| +0#0000000&@39
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\|t| |a|n|d| |\|x|F@1| +0#0000000&@50
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|o|n|e|}| |a|n|d| |{|t|w|o|}|"@2| +0#0000000&@45
|
||||
@75
|
||||
|#+0#0000e05&| |F|-|s|t|r|i|n|g|s| +0#0000000&@63
|
||||
@57|1|7|,|1| @9|1|5|%|
|
20
runtime/syntax/testdir/dumps/python3_fstrings_02.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_02.dump
Normal file
@ -0,0 +1,20 @@
|
||||
|#+0#0000e05#ffffff0| |F|-|s|t|r|i|n|g|s| +0#0000000&@63
|
||||
|t|e|s|t| |=| |f+0#e000002&|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |f|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|'| +0#e000002&|a|n|d| |\+0#e000e06&|0|4| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a|n
|
||||
|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@66
|
||||
|t|e|s|t| |=| |F+0#e000002&|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |f|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|"| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a
|
||||
|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|"+0#e000002&| +0#0000000&@65
|
||||
>t|e|s|t| |=| |f+0#e000002&|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&
|
||||
|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@64
|
||||
|t|e|s|t| |=| |F+0#e000002&|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&
|
||||
|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|"+0#e000002&| +0#0000000&@64
|
||||
|t|e|s|t| |=| |f+0#e000002&|'@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |f|-|s|t|r|i|n|g| +0#0000000&@41
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4| +0#0000000&@51
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#00e0e07&| +0#0000000&@44
|
||||
| +0#00e0e07&@3|+| +0#0000000&@69
|
||||
| +0#00e0e07&@3|2|}+0#e000e06&|'+0#e000002&@2| +0#0000000&@65
|
||||
|t|e|s|t| |=| |F+0#e000002&|"@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |f|-|s|t|r|i|n|g| +0#0000000&@41
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@50
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#00e0e07&| +0#0000000&@44
|
||||
@57|3|1|,|1| @9|3|6|%|
|
20
runtime/syntax/testdir/dumps/python3_fstrings_03.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_03.dump
Normal file
@ -0,0 +1,20 @@
|
||||
|a+0#e000002#ffffff0|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#00e0e07&| +0#0000000&@44
|
||||
| +0#00e0e07&@3|+| +0#0000000&@69
|
||||
| +0#00e0e07&@3|2|}+0#e000e06&|"+0#e000002&@2| +0#0000000&@65
|
||||
@75
|
||||
|#+0#0000e05&| |R|a|w| |f|-|s|t|r|i|n|g|s| +0#0000000&@59
|
||||
>t|e|s|t| |=| |r+0#e000002&|f|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|'| |a|n|d| |\|0|4| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n
|
||||
|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@61
|
||||
|t|e|s|t| |=| |r+0#e000002&|F|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|"| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&
|
||||
|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|"+0#e000002&| +0#0000000&@60
|
||||
|t|e|s|t| |=| |R+0#e000002&|f|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|'| |a|n|d| |\|0|4| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n
|
||||
|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@61
|
||||
|t|e|s|t| |=| |R+0#e000002&|F|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\|"| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&
|
||||
|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|"+0#e000002&| +0#0000000&@60
|
||||
|t|e|s|t| |=| |f+0#e000002&|r|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&
|
||||
|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@59
|
||||
|t|e|s|t| |=| |f+0#e000002&|R|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&
|
||||
|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|"+0#e000002&| +0#0000000&@59
|
||||
|t|e|s|t| |=| |F+0#e000002&|r|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&
|
||||
|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@59
|
||||
@57|4|7|,|1| @9|5|3|%|
|
20
runtime/syntax/testdir/dumps/python3_fstrings_04.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_04.dump
Normal file
@ -0,0 +1,20 @@
|
||||
|t+0&#ffffff0|e|s|t| |=| |F+0#e000002&|r|'|S|i|n|g|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&
|
||||
|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|'+0#e000002&| +0#0000000&@59
|
||||
|t|e|s|t| |=| |F+0#e000002&|R|"|D|o|u|b|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |a|n| |{@1|e|s|c|a|p|e|d|}@1| |f|i|e|l|d| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&
|
||||
|o+0#00e0e07&|n|e|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&|"+0#e000002&| +0#0000000&@59
|
||||
|t|e|s|t| |=| |r+0#e000002&|F|'@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| +0#0000000&@36
|
||||
>w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\|t| |a|n|d| |\|0|4| +0#0000000&@51
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#00e0e07&| +0#0000000&@44
|
||||
| +0#00e0e07&@3|+| +0#0000000&@69
|
||||
| +0#00e0e07&@3|2|}+0#e000e06&|'+0#e000002&@2| +0#0000000&@65
|
||||
|t|e|s|t| |=| |f+0#e000002&|R|"@2|T|r|i|p|l|e|-|q|u|o|t|e|d| |r|a|w| |f|-|s|t|r|i|n|g| +0#0000000&@36
|
||||
|w+0#e000002&|i|t|h| |e|s|c|a|p|e|s| |\|t| |a|n|d| |\|x|F@1| +0#0000000&@50
|
||||
|a+0#e000002&|n|d| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@56
|
||||
|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|o+0#00e0e07&|n|e|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|t+0#00e0e07&|w|o|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#00e0e07&| +0#0000000&@44
|
||||
| +0#00e0e07&@3|+| +0#0000000&@69
|
||||
| +0#00e0e07&@3|2|}+0#e000e06&|"+0#e000002&@2| +0#0000000&@65
|
||||
@75
|
||||
|#+0#0000e05&| |C|o|m@1|e|n|t|s|,| |n|e|s|t|e|d| |f|i|e|l|d|s| |a|n|d| |n|e|s|t|e|d| |q|u|o|t|e|s| +0#0000000&@31
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|a|b|c|{+0#e000e06&|a+0#00e0e07&| |#| |T|h|i|s| |i|s| |a| |c|o|m@1|e|n|t| |}|"| +0#0000000&@37
|
||||
@57|5|6|,|1| @9|7|3|%|
|
20
runtime/syntax/testdir/dumps/python3_fstrings_05.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_05.dump
Normal file
@ -0,0 +1,20 @@
|
||||
|t+0&#ffffff0|e|s|t| |=| |f+0#e000002&|"|a|b|c|{+0#e000e06&|a+0#00e0e07&| |#| |T|h|i|s| |i|s| |a| |c|o|m@1|e|n|t| |}|"| +0#0000000&@37
|
||||
| +0#00e0e07&@3|+| |3|}+0#e000e06&|"+0#e000002&| +0#0000000&@65
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|H|e| |s|a|i|d| |h|i|s| |n|a|m|e| |i|s| |{+0#e000e06&|n+0#00e0e07&|a|m|e|!|r|}+0#e000e06&|.+0#e000002&|"| +0#0000000&@35
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|H|e| |s|a|i|d| |h|i|s| |n|a|m|e| |i|s| |{+0#e000e06&|r+0#00e0e07&|e|p|r|(|n|a|m|e|)|}+0#e000e06&|.+0#e000002&|"| +0#0000000&@31
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|r|e|s|u|l|t|:| |{+0#e000e06&|v+0#00e0e07&|a|l|u|e|:|{|w|i|d|t|h|}|}+0#e000e06&|"+0#e000002&| +0#0000000&@41
|
||||
>t|e|s|t| |=| |f+0#e000002&|"|r|e|s|u|l|t|:| |{+0#e000e06&|v+0#00e0e07&|a|l|u|e|:|{|w|i|d|t|h|}|.|{|p|r|e|c|i|s|i|o|n|}|}+0#e000e06&|"+0#e000002&| +0#0000000&@29
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|t+0#00e0e07&|o|d|a|y|:|%|B| |%|d|,| |%|Y|}+0#e000e06&|"+0#e000002&| +0#0000000&@47
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|t+0#00e0e07&|o|d|a|y|=|:|%|B| |%|d|,| |%|Y|}+0#e000e06&|"+0#e000002&| +0#0000000&@46
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#00e0e07&|u|m|b|e|r|:|#|0|x|}+0#e000e06&|"+0#e000002&| +0#0000000&@52
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#00e0e07&|u|m|b|e|r|:|+|#|0|x|}+0#e000e06&|"+0#e000002&| +0#0000000&@51
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#00e0e07&|u|m|b|e|r|:|<|+|#|0|x|}+0#e000e06&|"+0#e000002&| +0#0000000&@50
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#00e0e07&|u|m|b|e|r|:| |<|+|#|0|x|}+0#e000e06&|"+0#e000002&| +0#0000000&@49
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#00e0e07&|u|m|b|e|r|:|<|#|0|x|}+0#e000e06&|"+0#e000002&| +0#0000000&@51
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#00e0e07&|u|m|b|e|r|:| |<|#|0|x|}+0#e000e06&|"+0#e000002&| +0#0000000&@50
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&| +0#00e0e07&|f|o@1| |=| |}+0#e000e06&|"+0#e000002&| +0#0000000&@55
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|l+0#00e0e07&|i|n|e| |=| |}+0#e000e06&|"+0#e000002&| +0#0000000&@55
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|l+0#00e0e07&|i|n|e| |=| |:|2|0|}+0#e000e06&|"+0#e000002&| +0#0000000&@52
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|l+0#00e0e07&|i|n|e| |=| |!|r|:|2|0|}+0#e000e06&|"+0#e000002&| +0#0000000&@50
|
||||
|t|e|s|t| |=| |f+0#e000002&|"|a|b|c| |{+0#e000e06&|a+0#00e0e07&|[|"|x|"|]|}+0#e000e06&| +0#e000002&|d|e|f|"| +0#0000000&@48
|
||||
@57|7|4|,|1| @9|9|8|%|
|
20
runtime/syntax/testdir/dumps/python3_fstrings_06.dump
Normal file
20
runtime/syntax/testdir/dumps/python3_fstrings_06.dump
Normal file
@ -0,0 +1,20 @@
|
||||
|t+0&#ffffff0|e|s|t| |=| |f+0#e000002&|"|a|b|c| |{+0#e000e06&|a+0#00e0e07&|[|"|x|"|]|}+0#e000e06&| +0#e000002&|d|e|f|"| +0#0000000&@48
|
||||
>t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |a| |c|o|n|t|a|i|n|s|:|\+0#e000e06&|n|{|"+0#00e0e07&|\|n|"|.|j|o|i|n|(|a|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@32
|
||||
|~+0#4040ff13&| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
| +0#0000000&@56|8@1|,|1| @9|B|o|t|
|
88
runtime/syntax/testdir/input/python3_fstrings.py
Normal file
88
runtime/syntax/testdir/input/python3_fstrings.py
Normal file
@ -0,0 +1,88 @@
|
||||
# F-strings (formatted string literals)
|
||||
# https://docs.python.org/3/reference/lexical_analysis.html#f-strings
|
||||
|
||||
# Strings
|
||||
test = 'Single-quoted string with escapes \' and \04 and fields {one} and {two}'
|
||||
test = "Double-quoted string with escapes \" and \xFF and fields {one} and {two}"
|
||||
test = '''Triple-quoted string
|
||||
with escapes \t and \04
|
||||
and quotes ' and "
|
||||
and fields {one} and {two}'''
|
||||
test = """Triple-quoted string
|
||||
with escapes \t and \xFF
|
||||
and quotes ' and "
|
||||
and fields {one} and {two}"""
|
||||
|
||||
# Raw strings
|
||||
test = r'Single-quoted raw string with escapes \' and \04 and fields {one} and {two}'
|
||||
test = R"Double-quoted raw string with escapes \" and \xFF and fields {one} and {two}"
|
||||
test = r'''Triple-quoted raw string
|
||||
with escapes \t and \04
|
||||
and quotes ' and "
|
||||
and fields {one} and {two}'''
|
||||
test = R"""Triple-quoted raw string
|
||||
with escapes \t and \xFF
|
||||
and quotes ' and "
|
||||
and fields {one} and {two}"""
|
||||
|
||||
# F-strings
|
||||
test = f'Single-quoted f-string with escapes \' and \04 and fields {one} and {two}'
|
||||
test = F"Double-quoted f-string with escapes \" and \xFF and fields {one} and {two}"
|
||||
test = f'Single-quoted f-string with an {{escaped}} field and fields {one} and {two}'
|
||||
test = F"Double-quoted f-string with an {{escaped}} field and fields {one} and {two}"
|
||||
test = f'''Triple-quoted f-string
|
||||
with escapes \t and \04
|
||||
and quotes ' and "
|
||||
and fields {one}, {two} and {1
|
||||
+
|
||||
2}'''
|
||||
test = F"""Triple-quoted f-string
|
||||
with escapes \t and \xFF
|
||||
and quotes ' and "
|
||||
and fields {one}, {two} and {1
|
||||
+
|
||||
2}"""
|
||||
|
||||
# Raw f-strings
|
||||
test = rf'Single-quoted raw f-string with escapes \' and \04 and fields {one} and {two}'
|
||||
test = rF"Double-quoted raw f-string with escapes \" and \xFF and fields {one} and {two}"
|
||||
test = Rf'Single-quoted raw f-string with escapes \' and \04 and fields {one} and {two}'
|
||||
test = RF"Double-quoted raw f-string with escapes \" and \xFF and fields {one} and {two}"
|
||||
test = fr'Single-quoted raw f-string with an {{escaped}} field and fields {one} and {two}'
|
||||
test = fR"Double-quoted raw f-string with an {{escaped}} field and fields {one} and {two}"
|
||||
test = Fr'Single-quoted raw f-string with an {{escaped}} field and fields {one} and {two}'
|
||||
test = FR"Double-quoted raw f-string with an {{escaped}} field and fields {one} and {two}"
|
||||
test = rF'''Triple-quoted raw f-string
|
||||
with escapes \t and \04
|
||||
and quotes ' and "
|
||||
and fields {one}, {two} and {1
|
||||
+
|
||||
2}'''
|
||||
test = fR"""Triple-quoted raw f-string
|
||||
with escapes \t and \xFF
|
||||
and quotes ' and "
|
||||
and fields {one}, {two} and {1
|
||||
+
|
||||
2}"""
|
||||
|
||||
# Comments, nested fields and nested quotes
|
||||
test = f"abc{a # This is a comment }"
|
||||
+ 3}"
|
||||
test = f"He said his name is {name!r}."
|
||||
test = f"He said his name is {repr(name)}."
|
||||
test = f"result: {value:{width}}"
|
||||
test = f"result: {value:{width}.{precision}}"
|
||||
test = f"{today:%B %d, %Y}"
|
||||
test = f"{today=:%B %d, %Y}"
|
||||
test = f"{number:#0x}"
|
||||
test = f"{number:+#0x}"
|
||||
test = f"{number:<+#0x}"
|
||||
test = f"{number: <+#0x}"
|
||||
test = f"{number:<#0x}"
|
||||
test = f"{number: <#0x}"
|
||||
test = f"{ foo = }"
|
||||
test = f"{line = }"
|
||||
test = f"{line = :20}"
|
||||
test = f"{line = !r:20}"
|
||||
test = f"abc {a["x"]} def"
|
||||
test = f"List a contains:\n{"\n".join(a)}"
|
Loading…
x
Reference in New Issue
Block a user