Skip to content

Commit 4e0828f

Browse files
committed
Added support for new integer literal syntax
1 parent bbac2dd commit 4e0828f

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Revision 2.6.1 (unknown):
88
- Removed "OverflowWarning" (removed in Python 2.5);
99
- Added option "python_print_as_function" for highlight "print" as a
1010
function;
11+
- Added support for new integer literal syntax "0o" and "0b";
1112

1213
Revision 2.5.6 (2007-02-04):
1314

TODO.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
- Add configuration for "print" status (function or builtin)
2-
3-
- Integer literal support
4-
51
- Python 3.0 string formatting
62

73
- Need more accurate way to handle indentation errors. For example

python.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,18 @@ endif
188188

189189
" Numbers (ints, longs, floats, complex)
190190
syn match pythonHexNumber "\<0[xX]\x\+[lL]\=\>" display
191-
syn match pythonHexNumber "\<0[xX]\>" display
191+
syn match pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
192+
syn match pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
193+
192194
syn match pythonNumber "\<\d\+[lLjJ]\=\>" display
195+
193196
syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
194197
syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
195198
syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
196199

197-
syn match pythonOctalError "\<0\o*[89]\d*[lL]\=\>" display
198-
syn match pythonHexError "\<0[xX]\X\+[lL]\=\>" display
200+
syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
201+
syn match pythonHexError "\<0[xX]\x*\X\x*[lL]\=\>" display
202+
syn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" display
199203

200204
if exists("python_highlight_builtins") && python_highlight_builtins != 0
201205
" Builtin functions, types and objects
@@ -303,9 +307,12 @@ if version >= 508 || !exists("did_python_syn_inits")
303307

304308
HiLink pythonNumber Number
305309
HiLink pythonHexNumber Number
310+
HiLink pythonOctNumber Number
311+
HiLink pythonBinNumber Number
306312
HiLink pythonFloat Float
307-
HiLink pythonOctalError Error
313+
HiLink pythonOctError Error
308314
HiLink pythonHexError Error
315+
HiLink pythonBinError Error
309316

310317
HiLink pythonBuiltinObj Structure
311318
HiLink pythonBuiltinFunc Function

0 commit comments

Comments
 (0)