Added support for brace escaping in str.format

This commit is contained in:
Dmitry Vasiliev
2008-09-22 13:01:18 +04:00
parent 9c1c35f333
commit a2208995a6
4 changed files with 16 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
Revision 3.0.0 (2008-09-?): Revision 3.0.0 (2008-09-?):
- Updated support for str.format;
- Added new builtins introduced in Python 2.6: "ascii", "exec", - Added new builtins introduced in Python 2.6: "ascii", "exec",
"memoryview", "print"; "memoryview", "print";
- Removed builtins: "apply", "basestring", "buffer", "callable", "coerce", - Removed builtins: "apply", "basestring", "buffer", "callable", "coerce",
@@ -8,7 +9,9 @@ Revision 3.0.0 (2008-09-?):
Revision 2.6.2 (2008-09-?): Revision 2.6.2 (2008-09-?):
- Added "VMSError" exception;
- Added support for b"..." syntax; - Added support for b"..." syntax;
- Added support for str.format brace escaping;
Revision 2.6.1 (2008-09-21): Revision 2.6.1 (2008-09-21):

View File

@@ -193,12 +193,15 @@ endif
if exists("python_highlight_string_format") && python_highlight_string_format != 0 if exists("python_highlight_string_format") && python_highlight_string_format != 0
" str.format syntax " str.format syntax
syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
endif endif
if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
" String templates " String templates
syn match pythonStrTemplate "\$\(\$\|{[a-zA-Z_][a-zA-Z0-9_]*}\|[a-zA-Z_][a-zA-Z0-9_]*\)" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
endif endif
if exists("python_highlight_doctests") && python_highlight_doctests != 0 if exists("python_highlight_doctests") && python_highlight_doctests != 0
@@ -264,7 +267,7 @@ if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
syn keyword pythonExClass SystemError SystemExit TypeError syn keyword pythonExClass SystemError SystemExit TypeError
syn keyword pythonExClass UnboundLocalError UnicodeError syn keyword pythonExClass UnboundLocalError UnicodeError
syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError
syn keyword pythonExClass UnicodeTranslateError ValueError syn keyword pythonExClass UnicodeTranslateError ValueError VMSError
syn keyword pythonExClass WindowsError ZeroDivisionError syn keyword pythonExClass WindowsError ZeroDivisionError
syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning

View File

@@ -186,12 +186,15 @@ endif
if exists("python_highlight_string_format") && python_highlight_string_format != 0 if exists("python_highlight_string_format") && python_highlight_string_format != 0
" str.format syntax " str.format syntax
syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rsa]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
endif endif
if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
" String templates " String templates
syn match pythonStrTemplate "\$\(\$\|{[a-zA-Z_][a-zA-Z0-9_]*}\|[a-zA-Z_][a-zA-Z0-9_]*\)" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
endif endif
if exists("python_highlight_doctests") && python_highlight_doctests != 0 if exists("python_highlight_doctests") && python_highlight_doctests != 0
@@ -252,7 +255,7 @@ if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
syn keyword pythonExClass SystemError SystemExit TypeError syn keyword pythonExClass SystemError SystemExit TypeError
syn keyword pythonExClass UnboundLocalError UnicodeError syn keyword pythonExClass UnboundLocalError UnicodeError
syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError
syn keyword pythonExClass UnicodeTranslateError ValueError syn keyword pythonExClass UnicodeTranslateError ValueError VMSError
syn keyword pythonExClass WindowsError ZeroDivisionError syn keyword pythonExClass WindowsError ZeroDivisionError
syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning

View File

@@ -75,9 +75,9 @@ b"test"
" %f " " %f "
"{0.name!r:b} {0[n]} {name!s: }" "{0.name!r:b} {0[n]} {name!s: } {{test}} {{}}"
"${test} ${test ${test}aname" "${test} ${test ${test}aname $$$ $test+nope"
# Doctests. # Doctests.