From a94a0555d911da0d3bcd7e91d76c8e8ef03d9b0e Mon Sep 17 00:00:00 2001 From: Rob B Date: Sun, 10 Aug 2025 10:35:31 +0200 Subject: [PATCH] runtime(python): Highlight f-string replacement fields in Python Highlight f-string replacement fields, including - Comments - Debugging flags - Conversion fields - Format specifications - Delimiters Syntax inside fields will be addressed in a separate commit. related: #10734 related: #14033 closes: #17784 Signed-off-by: Rob B Signed-off-by: Zvezdan Petkovic Signed-off-by: Christian Brabandt --- runtime/syntax/python.vim | 29 +++++++-- .../dumps/python_strings_bytes_01.dump | 2 +- .../dumps/python_strings_bytes_02.dump | 2 +- .../dumps/python_strings_bytes_03.dump | 2 +- .../dumps/python_strings_bytes_04.dump | 22 +++---- .../dumps/python_strings_bytes_05.dump | 28 ++++----- .../dumps/python_strings_bytes_06.dump | 28 ++++----- .../dumps/python_strings_bytes_07.dump | 40 ++++++------ .../dumps/python_strings_bytes_08.dump | 40 ++++++------ .../dumps/python_strings_bytes_09.dump | 20 ++++++ .../dumps/python_strings_bytes_10.dump | 20 ++++++ .../dumps/python_strings_bytes_11.dump | 20 ++++++ .../dumps/python_strings_bytes_12.dump | 20 ++++++ .../testdir/input/python_strings_bytes.py | 63 +++++++++++++++++++ 14 files changed, 249 insertions(+), 87 deletions(-) create mode 100644 runtime/syntax/testdir/dumps/python_strings_bytes_09.dump create mode 100644 runtime/syntax/testdir/dumps/python_strings_bytes_10.dump create mode 100644 runtime/syntax/testdir/dumps/python_strings_bytes_11.dump create mode 100644 runtime/syntax/testdir/dumps/python_strings_bytes_12.dump diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index 2881cad464..d123ba4f84 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Python " Maintainer: Zvezdan Petkovic -" Last Change: 2025 Jul 26 +" Last Change: 2025 Aug 10 " Credits: Neil Schemenauer " Dmitry Vasiliev " Rob B @@ -165,25 +165,25 @@ syn region pythonFString \ start=+\cF\z(['"]\)+ \ end="\z1" \ skip="\\\\\|\\\z1" - \ contains=pythonEscape,pythonUnicodeEscape,@Spell + \ contains=pythonFStringField,pythonFStringSkip,pythonEscape,pythonUnicodeEscape,@Spell syn region pythonFString \ matchgroup=pythonTripleQuotes \ start=+\cF\z('''\|"""\)+ \ end="\z1" \ keepend - \ contains=pythonEscape,pythonUnicodeEscape,pythonSpaceError,pythonDoctest,@Spell + \ contains=pythonFStringField,pythonFStringSkip,pythonEscape,pythonUnicodeEscape,pythonSpaceError,pythonDoctest,@Spell syn region pythonRawFString \ matchgroup=pythonQuotes \ start=+\c\%(FR\|RF\)\z(['"]\)+ \ end="\z1" \ skip="\\\\\|\\\z1" - \ contains=@Spell + \ contains=pythonFStringField,pythonFStringSkip,@Spell syn region pythonRawFString \ matchgroup=pythonTripleQuotes \ start=+\c\%(FR\|RF\)\z('''\|"""\)+ \ end="\z1" \ keepend - \ contains=pythonSpaceError,pythonDoctest,@Spell + \ contains=pythonFStringField,pythonFStringSkip,pythonSpaceError,pythonDoctest,@Spell " Bytes syn region pythonBytes @@ -209,6 +209,24 @@ syn region pythonRawBytes \ end="\z1" \ keepend +" F-string replacement fields +" +" - Matched parentheses, brackets and braces are ignored +" - A bare # is ignored to end of line +" - A bare = (surrounded by optional whitespace) enables debugging +" - A bare ! prefixes a conversion field +" - A bare : begins a format specification +" - Matched braces inside a format specification are ignored +" +syn region pythonFStringField + \ matchgroup=pythonFStringDelimiter + \ start=/{/ + \ skip=/([^)]*)\|\[[^]]*]\|{[^}]*}\|#.*$/ + \ end=/\%(\s*=\s*\)\=\%(!\a\)\=\%(:\%({[^}]*}\|[^}]*\)\+\)\=}/ + \ contained +" Doubled braces and Unicode escapes are not replacement fields +syn match pythonFStringSkip /{{\|\\N{/ transparent contained contains=NONE + syn match pythonEscape +\\[abfnrtv'"\\]+ contained syn match pythonEscape "\\\o\{1,3}" contained syn match pythonEscape "\\x\x\{2}" contained @@ -376,6 +394,7 @@ hi def link pythonQuotes String hi def link pythonTripleQuotes pythonQuotes hi def link pythonEscape Special hi def link pythonUnicodeEscape pythonEscape +hi def link pythonFStringDelimiter Special if !exists("python_no_number_highlight") hi def link pythonNumber Number endif diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_01.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_01.dump index f0ce66eba8..f8ea6801ad 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_01.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_01.dump @@ -17,4 +17,4 @@ |a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 |a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|"@2| +0#0000000&@38 @75 -@57|1|7|,|1| @10|9|%| +@57|1|7|,|1| @10|6|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_02.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_02.dump index b5e152830b..704cbe3485 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_02.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_02.dump @@ -17,4 +17,4 @@ |#+0#0000e05&| |R|a|w| |U|n|i|c|o|d|e| |l|i|t|e|r|a|l|s| |a|r|e| |n|o|t| |a|l@1|o|w|e|d| +0#0000000&@36 |t|e|s|t| |=| |u|r+0#e000002&|'|I|n|v|a|l|i|d| |s|t|r|i|n|g| |w|i|t|h| |\|'| |a|n|d| |\|"| |a|n|d| |\|t|'| +0#0000000&@27 |t|e|s|t| |=| |u|R+0#e000002&|"|I|n|v|a|l|i|d| |s|t|r|i|n|g| |w|i|t|h| |\|0|4|0| |a|n|d| |\|x|F@1|"| +0#0000000&@30 -@57|3@1|,|1| @9|2|4|%| +@57|3@1|,|1| @9|1|5|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_03.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_03.dump index b3c8d63d20..610311dac9 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_03.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_03.dump @@ -17,4 +17,4 @@ |a+0#e000002&|n|d| |\+0#e000e06&|u|0@1|A|1| +0#e000002&|a|n|d| |\+0#e000e06&|U|0@2|1|0|6|0|5|"+0#e000002&@2| +0#0000000&@46 @75 |#+0#0000e05&| |F|o|r|m|a|t@1|e|d| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s| |(|f|-|s|t|r|i|n|g|s|)| +0#0000000&@35 -@57|4|9|,|1| @9|3|8|%| +@57|4|9|,|1| @9|2|4|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_04.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_04.dump index 35eb62bfc6..ba0de991da 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_04.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_04.dump @@ -1,20 +1,20 @@ |#+0#0000e05#ffffff0| |F|o|r|m|a|t@1|e|d| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s| |(|f|-|s|t|r|i|n|g|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 -|t|e|s|t| |=| |f+0#e000002&|'|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#e000002&|a|n|d| |\+0#e000e06&|t| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|' -|t+0#0000000&|e|s|t| |=| |F+0#e000002&|"|F|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|"| +0#0000000&@2 +|t|e|s|t| |=| |f+0#e000002&|'|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#e000002&|a|n|d| |\+0#e000e06&|t| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|'+0#e000002& +|t+0#0000000&|e|s|t| |=| |F+0#e000002&|"|F|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|"+0#e000002&| +0#0000000&@2 |t|e|s|t| |=| |f+0#e000002&|'|F|-|s|t|r|i|n|g| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|u|0@1|A|1| +0#e000002&|a|n|d| |\+0#e000e06&|U|0@2|1|0|6|0|5| +0#e000002&|a|n|d| |\+0#e000e06&|N|{|I|N|V|E|R|T|E|D| |E|X|C|L|A|M -|A|T|I|O|N| |M|A|R|K|}| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|'| +0#0000000&@35 ->t|e|s|t| |=| |F+0#e000002&|"|F|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |{@1|f|i|e|l|d|}@1| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|"| +0#0000000&@6 +|A|T|I|O|N| |M|A|R|K|}| +0#e000002&|a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|'+0#e000002&| +0#0000000&@35 +>t|e|s|t| |=| |F+0#e000002&|"|F|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |{@1|f|i|e|l|d|}@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|"+0#e000002&| +0#0000000&@6 |t|e|s|t| |=| |f+0#e000002&|'@2|F|-|s|t|r|i|n|g| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@35 |a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@42 |a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|u|0@1|A|1| +0#e000002&|a|n|d| |\+0#e000e06&|U|0@2|1|0|6|0|5| +0#0000000&@41 -|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|1|}|,| |{|2|}| |a|n|d| |{|1| +0#0000000&@48 -| +0#e000002&@3|+| +0#0000000&@69 -| +0#e000002&@3|2|}|'@2| +0#0000000&@65 +|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|1+0#0000000&|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|2+0#0000000&|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#0000000&| @48 +@4|+| @69 +@4|2|}+0#e000e06&|'+0#e000002&@2| +0#0000000&@65 |t|e|s|t| |=| |F+0#e000002&|"@2|F|-|s|t|r|i|n|g| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@35 |a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@42 |a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|u|0@1|A|1| +0#e000002&|a|n|d| |\+0#e000e06&|U|0@2|1|0|6|0|5| +0#0000000&@41 -|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|1|}|,| |{|2|}| |a|n|d| |{|1| +0#0000000&@48 -| +0#e000002&@3|+| +0#0000000&@69 -| +0#e000002&@3|2|}|"@2| +0#0000000&@65 -@57|6@1|,|1| @9|5|3|%| +|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|1+0#0000000&|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|2+0#0000000&|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#0000000&| @48 +@4|+| @69 +@4|2|}+0#e000e06&|"+0#e000002&@2| +0#0000000&@65 +@57|6@1|,|1| @9|3|4|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_05.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_05.dump index d4e8f1b615..2c3f5c0372 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_05.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_05.dump @@ -1,20 +1,20 @@ -| +0#e000002#ffffff0@3|2|}|"@2| +0#0000000&@65 +| +0&#ffffff0@3|2|}+0#e000e06&|"+0#e000002&@2| +0#0000000&@65 @75 |#+0#0000e05&| |R|a|w| |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&@43 -|t|e|s|t| |=| |f+0#e000002&|r|'|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{ -|b|a|r|}|'| +0#0000000&@69 ->t|e|s|t| |=| |f+0#e000002&|R|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r -|}|"| +0#0000000&@72 +|t|e|s|t| |=| |f+0#e000002&|r|'|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06& +|b+0#0000000&|a|r|}+0#e000e06&|'+0#e000002&| +0#0000000&@69 +>t|e|s|t| |=| |f+0#e000002&|R|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r +|}+0#e000e06&|"+0#e000002&| +0#0000000&@72 |t|e|s|t| |=| |F+0#e000002&|r|'|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E -|X|C|L|A|M|A|T|I|O|N| |M|A|R|K|}| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|'| +0#0000000&@30 -|t|e|s|t| |=| |F+0#e000002&|R|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |{@1|f|i|e|l|d|}@1| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|"| +0#0000000&@1 -|t|e|s|t| |=| |r+0#e000002&|f|'|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{ -|b|a|r|}|'| +0#0000000&@69 -|t|e|s|t| |=| |r+0#e000002&|F|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r -|}|"| +0#0000000&@72 +|X|C|L|A|M|A|T|I|O|N| |M|A|R|K|}| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|'+0#e000002&| +0#0000000&@30 +|t|e|s|t| |=| |F+0#e000002&|R|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |{@1|f|i|e|l|d|}@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|"+0#e000002&| +0#0000000&@1 +|t|e|s|t| |=| |r+0#e000002&|f|'|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06& +|b+0#0000000&|a|r|}+0#e000e06&|'+0#e000002&| +0#0000000&@69 +|t|e|s|t| |=| |r+0#e000002&|F|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r +|}+0#e000e06&|"+0#e000002&| +0#0000000&@72 |t|e|s|t| |=| |R+0#e000002&|f|'|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E -|X|C|L|A|M|A|T|I|O|N| |M|A|R|K|}| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|'| +0#0000000&@30 -|t|e|s|t| |=| |R+0#e000002&|F|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |{@1|f|i|e|l|d|}@1| |a|n|d| |f|i|e|l|d|s| |{|f|o@1|}| |a|n|d| |{|b|a|r|}|"| +0#0000000&@1 +|X|C|L|A|M|A|T|I|O|N| |M|A|R|K|}| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|'+0#e000002&| +0#0000000&@30 +|t|e|s|t| |=| |R+0#e000002&|F|"|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |l|i|t|e|r|a|l| |{@1|f|i|e|l|d|}@1| |a|n|d| |f|i|e|l|d|s| |{+0#e000e06&|f+0#0000000&|o@1|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|b+0#0000000&|a|r|}+0#e000e06&|"+0#e000002&| +0#0000000&@1 |t|e|s|t| |=| |f+0#e000002&|r|'@2|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@30 |a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 -@57|8|2|,|1| @9|6|5|%| +@57|8|2|,|1| @9|4|2|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_06.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_06.dump index 27dc71ce96..a9ac329dfc 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_06.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_06.dump @@ -1,20 +1,20 @@ |a+0#e000002#ffffff0|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 |a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| +0#0000000&@41 -|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|1|}|,| |{|2|}| |a|n|d| |{|1| +0#0000000&@48 -| +0#e000002&@3|+| +0#0000000&@69 -| +0#e000002&@3|2|}|'@2| +0#0000000&@65 +|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|1+0#0000000&|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|2+0#0000000&|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#0000000&| @48 +@4|+| @69 +@4|2|}+0#e000e06&|'+0#e000002&@2| +0#0000000&@65 >t|e|s|t| |=| |R+0#e000002&|F|"@2|R|a|w| |f|-|s|t|r|i|n|g| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@30 |a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 |a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| +0#0000000&@41 -|a+0#e000002&|n|d| |f|i|e|l|d|s| |{|1|}|,| |{|2|}| |a|n|d| |{|1| +0#0000000&@48 -| +0#e000002&@3|+| +0#0000000&@69 -| +0#e000002&@3|2|}|"@2| +0#0000000&@65 +|a+0#e000002&|n|d| |f|i|e|l|d|s| |{+0#e000e06&|1+0#0000000&|}+0#e000e06&|,+0#e000002&| |{+0#e000e06&|2+0#0000000&|}+0#e000e06&| +0#e000002&|a|n|d| |{+0#e000e06&|1+0#0000000&| @48 +@4|+| @69 +@4|2|}+0#e000e06&|"+0#e000002&@2| +0#0000000&@65 @75 -|#+0#0000e05&| |B|y|t|e|s| +0#0000000&@67 -|t|e|s|t| |=| |b+0#e000002&|'|B|y|t|e|s| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|'| +0#e000002&|a|n|d| |\+0#e000e06&|"| +0#e000002&|a|n|d| |\+0#e000e06&|t|'+0#e000002&| +0#0000000&@29 -|t|e|s|t| |=| |B+0#e000002&|"|B|y|t|e|s| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1|"+0#e000002&| +0#0000000&@32 -|t|e|s|t| |=| |b+0#e000002&|'|B|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L|A|M|A|T|I -|O|N| |M|A|R|K|}|'| +0#0000000&@65 -|t|e|s|t| |=| |B+0#e000002&|"|B|y|t|e|s| |w|i|t|h| |e|s|c|a|p|e|d| |\+0#e000e06&@1| +0#e000002&|b|a|c|k|s|l|a|s|h| |a|n|d| |i|g|n|o|r|e|d| |\+0#e000e06&| +0#0000000&@20 -|n+0#e000002&|e|w|l|i|n|e|"| +0#0000000&@66 -@57|9|5|,|1| @9|7|8|%| +|#+0#0000e05&| |F|-|s|t|r|i|n|g| |r|e|p|l|a|c|e|m|e|n|t| |f|i|e|l|d|s| +0#0000000&@45 +|t|e|s|t| |=| |f+0#e000002&|"|S|t|r|i|n|g| |i|s| |{+0#e000e06&| +0#0000000&@54 +@4|"|o|n|e| |p|l|u|s| |"| @59 +@4|"|t|w|o| |p|l|u|s| |"| @59 +@4|"|t|h|r|e@1|"|}+0#e000e06&|"+0#e000002&| +0#0000000&@61 +|t|e|s|t| |=| |f+0#e000002&|"|N|u|m|b|e|r| |i|s| |{+0#e000e06&| +0#0000000&@54 +@4|1| |+| @67 +@57|9|5|,|1| @9|5|0|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_07.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_07.dump index c51fbaeedf..7ada66081a 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_07.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_07.dump @@ -1,20 +1,20 @@ -|n+0#e000002#ffffff0|e|w|l|i|n|e|"| +0#0000000&@66 -|t|e|s|t| |=| |b+0#e000002&|'@2|B|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@38 -|a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@42 -|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|'@2| +0#0000000&@38 -|t|e|s|t| |=| |B+0#e000002&|"@2|B|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@38 ->a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@42 -|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|"@2| +0#0000000&@38 -@75 -|#+0#0000e05&| |R|a|w| |b|y|t|e|s| +0#0000000&@63 -|t|e|s|t| |=| |b+0#e000002&|r|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t|'| +0#0000000&@24 -|t|e|s|t| |=| |b+0#e000002&|R|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1|"| +0#0000000&@27 -|t|e|s|t| |=| |B+0#e000002&|r|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L -|A|M|A|T|I|O|N| |M|A|R|K|}|'| +0#0000000&@60 -|t|e|s|t| |=| |B+0#e000002&|R|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\@1| |b|a|c|k|s|l|a|s|h|e|s| |a|n|d| |l|i|t|e|r|a|l| |\| +0#0000000&@13 -|n+0#e000002&|e|w|l|i|n|e|"| +0#0000000&@66 -|t|e|s|t| |=| |r+0#e000002&|b|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t|'| +0#0000000&@24 -|t|e|s|t| |=| |r+0#e000002&|B|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1|"| +0#0000000&@27 -|t|e|s|t| |=| |R+0#e000002&|b|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L -|A|M|A|T|I|O|N| |M|A|R|K|}|'| +0#0000000&@60 -@57|1@1|2|,|1| @8|9|2|%| +| +0&#ffffff0@3|1| |+| @67 +@4|2| |+| @67 +@4|3|}+0#e000e06&|"+0#e000002&| +0#0000000&@67 +|t|e|s|t| |=| |f+0#e000002&|"|a|b|c|{+0#e000e06&|a+0#0000000&| |#| |T|h|i|s| |i|s| |a| |c|o|m@1|e|n|t| |}| @38 +@4|+| |1|}+0#e000e06&|"+0#e000002&| +0#0000000&@65 +>t|e|s|t| |=| |f+0#e000002&|"|d|e|f|{+0#e000e06&|a+0#0000000&| |#| |S|o| |i|s| |t|h|i|s| |:| @45 +@4|+| |2|}+0#e000e06&|"+0#e000002&| +0#0000000&@65 +|t|e|s|t| |=| |f+0#e000002&|"|g|h|i|{+0#e000e06&|a+0#0000000&| |#| |A|n|d| |t|h|i|s| |"| @47 +@4|+| |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#0000000&|a|m|e|!+0#e000e06&|r|}|.+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#0000000&|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#0000000&|a|l|u|e|:+0#e000e06&|{|w|i|d|t|h|}@1|"+0#e000002&| +0#0000000&@41 +|t|e|s|t| |=| |f+0#e000002&|"|r|e|s|u|l|t|:| |{+0#e000e06&|v+0#0000000&|a|l|u|e|:+0#e000e06&|{|w|i|d|t|h|}|.|{|p|r|e|c|i|s|i|o|n|}|}+0#e000002&|"| +0#0000000&@29 +|t|e|s|t| |=| |f+0#e000002&|"|r|e|s|u|l|t|:| |{+0#e000e06&|v+0#0000000&|a|l|u|e|:+0#e000e06&|{|w|i|d|t|h|:|d|}|.|{|p|r|e|c|i|s|i|o|n|!|s|}|}+0#e000002&|"| +0#0000000&@25 +|t|e|s|t| |=| |f+0#e000002&|"|r|e|s|u|l|t|:| |{+0#e000e06&|v+0#0000000&|a|l|u|e|:+0#e000e06&|{|o|p|t|i|o|n|s|}|{|w|i|d|t|h|}|{|g|r|o|u|p|i|n|g|}|{|p|r|e|c|i|s|i|o|n|}|{|t|y|p|e|}@1|"+0#e000002&| +0#0000000&@5 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&|#|0|x|}|"+0#e000002&| +0#0000000&@52 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&|+|#|0|x|}|"+0#e000002&| +0#0000000&@51 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&|<|+|#|0|x|}|"+0#e000002&| +0#0000000&@50 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&| |<|+|#|0|x|}|"+0#e000002&| +0#0000000&@49 +@57|1@1|3|,|1| @8|6|1|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_08.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_08.dump index 82fb1ccb52..40ef0ecdc2 100644 --- a/runtime/syntax/testdir/dumps/python_strings_bytes_08.dump +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_08.dump @@ -1,20 +1,20 @@ -|t+0&#ffffff0|e|s|t| |=| |R+0#e000002&|b|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L -|A|M|A|T|I|O|N| |M|A|R|K|}|'| +0#0000000&@60 -|t|e|s|t| |=| |R+0#e000002&|B|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\@1| |b|a|c|k|s|l|a|s|h|e|s| |a|n|d| |l|i|t|e|r|a|l| |\| +0#0000000&@13 -|n+0#e000002&|e|w|l|i|n|e|"| +0#0000000&@66 -|t|e|s|t| |=| |b+0#e000002&|r|'@2|R|a|w| |b|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@33 ->a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 -|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|'@2| +0#0000000&@38 -|t|e|s|t| |=| |R+0#e000002&|B|"@2|R|a|w| |b|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@33 -|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 -|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|"@2| +0#0000000&@38 -|~+0#4040ff13&| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -| +0#0000000&@56|1|2|7|,|1| @8|B|o|t| +|t+0&#ffffff0|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&| |<|+|#|0|x|}|"+0#e000002&| +0#0000000&@49 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&|<|#|0|x|}|"+0#e000002&| +0#0000000&@51 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|n+0#0000000&|u|m|b|e|r|:+0#e000e06&| |<|#|0|x|}|"+0#e000002&| +0#0000000&@50 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g|=+0#e000e06&|}|"+0#e000002&| +0#0000000&@55 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g|=+0#e000e06&|!|r|}|"+0#e000002&| +0#0000000&@53 +>t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g|=+0#e000e06&|:|2|0|}|"+0#e000002&| +0#0000000&@52 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g|=+0#e000e06&|!|r|:|2|0|}|"+0#e000002&| +0#0000000&@50 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g| +0#e000e06&|=| |}|"+0#e000002&| +0#0000000&@53 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g| +0#e000e06&|=| |!|r|}|"+0#e000002&| +0#0000000&@51 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g| +0#e000e06&|=| |:|2|0|}|"+0#e000002&| +0#0000000&@50 +|t|e|s|t| |=| |f+0#e000002&|"|{+0#e000e06&|s+0#0000000&|t|r|i|n|g| +0#e000e06&|=| |!|r|:|2|0|}|"+0#e000002&| +0#0000000&@48 +|t|e|s|t| |=| |f+0#e000002&|"|a|b|c| |{+0#e000e06&|a+0#0000000&|[|"|x|"|]|}+0#e000e06&| +0#e000002&|d|e|f|"| +0#0000000&@48 +|t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |c|o|n|t|a|i|n|s|:|\+0#e000e06&|n|{|"+0#0000000&|\|n|"|.|j|o|i|n|(|a|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@34 +|t|e|s|t| |=| |f+0#e000002&|"|T|o|d|a|y|'|s| |d|a|t|e| |i|s| |{+0#e000e06&|d+0#0000000&|a|t|e|t|i|m|e|.|n|o|w|(|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@32 +|t|e|s|t| |=| |f+0#e000002&|"|T|o|d|a|y|'|s| |f|o|r|m|a|t@1|e|d| |d|a|t|e| |i|s| |{+0#e000e06&|d+0#0000000&|a|t|e|t|i|m|e|.|n|o|w|(|)|:+0#e000e06&|%|Y|-|%|m|-|%|d| |%|H|:|%|M|:|%|S|}|"+0#e000002&| +0#0000000&@4 +|t|e|s|t| |=| |f+0#e000002&|"|D|a|t|e| |i|s| |{+0#e000e06&|d+0#0000000&|a|t|e|t|i|m|e|.|d|a|t|e|t|i|m|e|(|2|0|1|0|,| |7|,| |4|,| |1|2|,| |1|5|,| |5|8|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@13 +|t|e|s|t| |=| |f+0#e000002&|"|F|o|r|m|a|t@1|e|d| |d|a|t|e| |i|s| |{+0#e000e06&|d+0#0000000&|a|t|e|t|i|m|e|.|d|a|t|e|t|i|m|e|(|2|0|1|0|,| |7|,| |4|,| |1|2|,| |1|5|,| |5|8|)|:+0#e000e06&|%|Y|-|%|m +|-|%|d| |%|H|:|%|M|:|%|S|}|"+0#e000002&| +0#0000000&@60 +|t|e|s|t| |=| |f+0#e000002&|"|L|a|m|b|d|a| |r|e|t|u|r|n|s| |{+0#e000e06&|(+0#0000000&|l|a|m|b|d|a| |x|:| |x|*@1|2|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@31 +@57|1|3|1|,|1| @8|7|1|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_09.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_09.dump new file mode 100644 index 0000000000..9c9847d5c3 --- /dev/null +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_09.dump @@ -0,0 +1,20 @@ +|t+0&#ffffff0|e|s|t| |=| |f+0#e000002&|"|L|a|m|b|d|a| |r|e|t|u|r|n|s| |{+0#e000e06&|(+0#0000000&|l|a|m|b|d|a| |x|:| |x|*@1|2|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@31 +|t|e|s|t| |=| |f+0#e000002&|"|Z|e|r|o| |p|a|d@1|e|d| |l|a|m|b|d|a| |r|e|t|u|r|n|s| |{+0#e000e06&|(+0#0000000&|l|a|m|b|d|a| |x|:| |x|*@1|2|)|:+0#e000e06&|0|9|}|"+0#e000002&| +0#0000000&@16 +|t|e|s|t| |=| |f+0#e000002&|"|S|p|a|c|e| |p|a|d@1|e|d| |l|a|m|b|d|a| |r|e|t|u|r|n|s| |{+0#e000e06&|(+0#0000000&|l|a|m|b|d|a| |x|:| |x|*@1|2|)|:+0#e000e06&|{|w|i|d|t|h|}@1|"+0#e000002&| +0#0000000&@10 +|t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |c|o|p|y| |i|s| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|:|]|}+0#e000e06&|"+0#e000002&| +0#0000000&@41 +|t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |s|l|i|c|e| |i|s| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|1|:|]|}+0#e000e06&|"+0#e000002&| +0#0000000&@39 +>t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |s|l|i|c|e| |i|s| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|:|9|]|}+0#e000e06&|"+0#e000002&| +0#0000000&@39 +|t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |e|l|e|m|e|n|t|s| |a|r|e| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|:|2|:|]|}+0#e000e06&|"+0#e000002&| +0#0000000&@34 +|t|e|s|t| |=| |f+0#e000002&|"|P|a|d@1|e|d| |l|i|s|t| |c|o|p|y| |i|s| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|:|]|:+0#e000e06&|9@1|}|"+0#e000002&| +0#0000000&@31 +|t|e|s|t| |=| |f+0#e000002&|"|L|e|f|t|-|a|l|i|g|n|e|d| |l|i|s|t| |s|l|i|c|e| |i|s| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|1|:|]|:+0#e000e06&|<|9@1|}|"+0#e000002&| +0#0000000&@22 +|t|e|s|t| |=| |f+0#e000002&|"|R|i|g|h|t| |a|l|i|g|n|e|d| |l|i|s|t| |s|l|i|c|e| |i|s| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|:|9|]|:+0#e000e06&|>|9@1|}|"+0#e000002&| +0#0000000&@21 +|t|e|s|t| |=| |f+0#e000002&|"|C|e|n|t|e|r|-|a|l|i|g|n|e|d| |l|i|s|t| |e|l|e|m|e|n|t|s| |a|r|e| |{+0#e000e06&|i+0#0000000&|t|e|m|s|[|:|2|:|]|:+0#e000e06&|^|9@1|}|"+0#e000002&| +0#0000000&@15 +|t|e|s|t| |=| |f+0#e000002&|"|E|x|p|r|e|s@1|i|o|n| |i|s| |{+0#e000e06&|x+0#0000000&| |=@1| |1|}+0#e000e06&|"+0#e000002&| +0#0000000&@42 +|t|e|s|t| |=| |f+0#e000002&|"|E|x|p|r|e|s@1|i|o|n| |i|s| |{+0#e000e06&|x+0#0000000&| |!|=| |1|}+0#e000e06&|"+0#e000002&| +0#0000000&@42 +|t|e|s|t| |=| |f+0#e000002&|"|E|x|p|r|e|s@1|i|o|n| |i|s| |{+0#e000e06&|(+0#0000000&|x| |:|=| |1|)|}+0#e000e06&|"+0#e000002&| +0#0000000&@40 +|t|e|s|t| |=| |f+0#e000002&|"|D|e|b|u|g| |e|x|p|r|e|s@1|i|o|n| |i|s| |{+0#e000e06&|x+0#0000000&| |=@1| |1|=+0#e000e06&|}|"+0#e000002&| +0#0000000&@35 +|t|e|s|t| |=| |f+0#e000002&|"|D|e|b|u|g| |e|x|p|r|e|s@1|i|o|n| |i|s| |{+0#e000e06&|x+0#0000000&| |!|=| |1|=+0#e000e06&|}|"+0#e000002&| +0#0000000&@35 +|t|e|s|t| |=| |f+0#e000002&|"|D|e|b|u|g| |e|x|p|r|e|s@1|i|o|n| |i|s| |{+0#e000e06&|(+0#0000000&|x| |:|=| |1|)|=+0#e000e06&|}|"+0#e000002&| +0#0000000&@33 +|t|e|s|t| |=| |f+0#e000002&|"|L|i|s|t| |c|o|m|p|r|e|h|e|n|s|i|o|n| |r|e|t|u|r|n|s| |{+0#e000e06&| +0#0000000&|[|x|*@1|2| |f|o|r| |x| |i|n| |r|a|n|g|e|(|1|0|)|]| |}+0#e000e06&|"+0#e000002&| +0#0000000&@8 +|t|e|s|t| |=| |f+0#e000002&|"|P|a|d@1|e|d| |l|i|s|t| |c|o|m|p|r|e|h|e|n|s|i|o|n| |r|e|t|u|r|n|s| |{+0#e000e06&| +0#0000000&|[|x|*@1|2| |f|o|r| |x| |i|n| |r|a|n|g|e|(|1|0|)|]| |:+0#e000e06&|@+0#4040ff13&@2 +| +0#0000000&@56|1|4|8|,|1| @8|8|0|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_10.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_10.dump new file mode 100644 index 0000000000..15781d7f67 --- /dev/null +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_10.dump @@ -0,0 +1,20 @@ +|t+0&#ffffff0|e|s|t| |=| |f+0#e000002&|"|P|a|d@1|e|d| |l|i|s|t| |c|o|m|p|r|e|h|e|n|s|i|o|n| |r|e|t|u|r|n|s| |{+0#e000e06&| +0#0000000&|[|x|*@1|2| |f|o|r| |x| |i|n| |r|a|n|g|e|(|1|0|)|]| |:+0#e000e06&|9@1|} +|"+0#e000002&| +0#0000000&@73 +|t|e|s|t| |=| |f+0#e000002&|"|D|i|c|t| |c|o|m|p|r|e|h|e|n|s|i|o|n| |r|e|t|u|r|n|s| |{+0#e000e06&| +0#0000000&|{|x|:| |x|*@1|2| |f|o|r| |x| |i|n| |r|a|n|g|e|(|1|0|)|}| |}+0#e000e06&|"+0#e000002&| +0#0000000&@5 +|t|e|s|t| |=| |f+0#e000002&|"|P|a|d@1|e|d| |d|i|c|t| |c|o|m|p|r|e|h|e|n|s|i|o|n| |r|e|t|u|r|n|s| |{+0#e000e06&| +0#0000000&|{|x|:| |x|*@1|2| |f|o|r| |x| |i|n| |r|a|n|g|e|(|1|0|)|}| |:+0#e000e06& +|9@1|}|"+0#e000002&| +0#0000000&@70 +> @74 +|#+0#0000e05&| |B|y|t|e|s| +0#0000000&@67 +|t|e|s|t| |=| |b+0#e000002&|'|B|y|t|e|s| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|'| +0#e000002&|a|n|d| |\+0#e000e06&|"| +0#e000002&|a|n|d| |\+0#e000e06&|t|'+0#e000002&| +0#0000000&@29 +|t|e|s|t| |=| |B+0#e000002&|"|B|y|t|e|s| |w|i|t|h| |e|s|c|a|p|e|s| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1|"+0#e000002&| +0#0000000&@32 +|t|e|s|t| |=| |b+0#e000002&|'|B|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L|A|M|A|T|I +|O|N| |M|A|R|K|}|'| +0#0000000&@65 +|t|e|s|t| |=| |B+0#e000002&|"|B|y|t|e|s| |w|i|t|h| |e|s|c|a|p|e|d| |\+0#e000e06&@1| +0#e000002&|b|a|c|k|s|l|a|s|h| |a|n|d| |i|g|n|o|r|e|d| |\+0#e000e06&| +0#0000000&@20 +|n+0#e000002&|e|w|l|i|n|e|"| +0#0000000&@66 +|t|e|s|t| |=| |b+0#e000002&|'@2|B|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@38 +|a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@42 +|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|'@2| +0#0000000&@38 +|t|e|s|t| |=| |B+0#e000002&|"@2|B|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@38 +|a+0#e000002&|n|d| |e|s|c|a|p|e|s| |\+0#e000e06&|t| +0#e000002&|a|n|d| |\+0#e000e06&|0|4|0| +0#e000002&|a|n|d| |\+0#e000e06&|x|F@1| +0#0000000&@42 +|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|"@2| +0#0000000&@38 +@57|1|6|4|,|0|-|1| @6|8|9|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_11.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_11.dump new file mode 100644 index 0000000000..297f46cf49 --- /dev/null +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_11.dump @@ -0,0 +1,20 @@ +|a+0#e000002#ffffff0|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|"@2| +0#0000000&@38 +@75 +|#+0#0000e05&| |R|a|w| |b|y|t|e|s| +0#0000000&@63 +|t|e|s|t| |=| |b+0#e000002&|r|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t|'| +0#0000000&@24 +|t|e|s|t| |=| |b+0#e000002&|R|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1|"| +0#0000000&@27 +>t|e|s|t| |=| |B+0#e000002&|r|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L +|A|M|A|T|I|O|N| |M|A|R|K|}|'| +0#0000000&@60 +|t|e|s|t| |=| |B+0#e000002&|R|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\@1| |b|a|c|k|s|l|a|s|h|e|s| |a|n|d| |l|i|t|e|r|a|l| |\| +0#0000000&@13 +|n+0#e000002&|e|w|l|i|n|e|"| +0#0000000&@66 +|t|e|s|t| |=| |r+0#e000002&|b|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|'| |a|n|d| |\|"| |a|n|d| |\|t|'| +0#0000000&@24 +|t|e|s|t| |=| |r+0#e000002&|B|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|0|4|0| |a|n|d| |\|x|F@1|"| +0#0000000&@27 +|t|e|s|t| |=| |R+0#e000002&|b|'|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5| |a|n|d| |\|N|{|I|N|V|E|R|T|E|D| |E|X|C|L +|A|M|A|T|I|O|N| |M|A|R|K|}|'| +0#0000000&@60 +|t|e|s|t| |=| |R+0#e000002&|B|"|R|a|w| |b|y|t|e|s| |w|i|t|h| |l|i|t|e|r|a|l| |\@1| |b|a|c|k|s|l|a|s|h|e|s| |a|n|d| |l|i|t|e|r|a|l| |\| +0#0000000&@13 +|n+0#e000002&|e|w|l|i|n|e|"| +0#0000000&@66 +|t|e|s|t| |=| |b+0#e000002&|r|'@2|R|a|w| |b|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@33 +|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 +|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|'@2| +0#0000000&@38 +|t|e|s|t| |=| |R+0#e000002&|B|"@2|R|a|w| |b|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@33 +@57|1|8|1|,|1| @8|9|8|%| diff --git a/runtime/syntax/testdir/dumps/python_strings_bytes_12.dump b/runtime/syntax/testdir/dumps/python_strings_bytes_12.dump new file mode 100644 index 0000000000..d2cf6bad0a --- /dev/null +++ b/runtime/syntax/testdir/dumps/python_strings_bytes_12.dump @@ -0,0 +1,20 @@ +|t+0&#ffffff0|e|s|t| |=| |R+0#e000002&|B|"@2|R|a|w| |b|y|t|e|s| |w|i|t|h| |q|u|o|t|e|s| |'| |a|n|d| |"| +0#0000000&@33 +|a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|t| |a|n|d| |\|0|4|0| |a|n|d| |\|x|F@1| +0#0000000&@42 +>a+0#e000002&|n|d| |l|i|t|e|r|a|l| |\|u|0@1|A|1| |a|n|d| |\|U|0@2|1|0|6|0|5|"@2| +0#0000000&@38 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|9|4|,|1| @8|B|o|t| diff --git a/runtime/syntax/testdir/input/python_strings_bytes.py b/runtime/syntax/testdir/input/python_strings_bytes.py index 02eb1b00e7..1b87fd4ac7 100644 --- a/runtime/syntax/testdir/input/python_strings_bytes.py +++ b/runtime/syntax/testdir/input/python_strings_bytes.py @@ -99,6 +99,69 @@ and fields {1}, {2} and {1 + 2}""" +# F-string replacement fields +test = f"String is { + "one plus " + "two plus " + "three"}" +test = f"Number is { + 1 + + 2 + + 3}" +test = f"abc{a # This is a comment } + + 1}" +test = f"def{a # So is this : + + 2}" +test = f"ghi{a # And this " + + 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"result: {value:{width:d}.{precision!s}}" +test = f"result: {value:{options}{width}{grouping}{precision}{type}}" +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"{string=}" +test = f"{string=!r}" +test = f"{string=:20}" +test = f"{string=!r:20}" +test = f"{string = }" +test = f"{string = !r}" +test = f"{string = :20}" +test = f"{string = !r:20}" +test = f"abc {a["x"]} def" +test = f"List contains:\n{"\n".join(a)}" +test = f"Today's date is {datetime.now()}" +test = f"Today's formatted date is {datetime.now():%Y-%m-%d %H:%M:%S}" +test = f"Date is {datetime.datetime(2010, 7, 4, 12, 15, 58)}" +test = f"Formatted date is {datetime.datetime(2010, 7, 4, 12, 15, 58):%Y-%m-%d %H:%M:%S}" +test = f"Lambda returns {(lambda x: x**2)}" +test = f"Zero padded lambda returns {(lambda x: x**2):09}" +test = f"Space padded lambda returns {(lambda x: x**2):{width}}" +test = f"List copy is {items[:]}" +test = f"List slice is {items[1:]}" +test = f"List slice is {items[:9]}" +test = f"List elements are {items[:2:]}" +test = f"Padded list copy is {items[:]:99}" +test = f"Left-aligned list slice is {items[1:]:<99}" +test = f"Right aligned list slice is {items[:9]:>99}" +test = f"Center-aligned list elements are {items[:2:]:^99}" +test = f"Expression is {x == 1}" +test = f"Expression is {x != 1}" +test = f"Expression is {(x := 1)}" +test = f"Debug expression is {x == 1=}" +test = f"Debug expression is {x != 1=}" +test = f"Debug expression is {(x := 1)=}" +test = f"List comprehension returns { [x**2 for x in range(10)] }" +test = f"Padded list comprehension returns { [x**2 for x in range(10)] :99}" +test = f"Dict comprehension returns { {x: x**2 for x in range(10)} }" +test = f"Padded dict comprehension returns { {x: x**2 for x in range(10)} :99}" + # Bytes test = b'Bytes with escapes \' and \" and \t' test = B"Bytes with escapes \040 and \xFF" -- 2.47.2