forked from petervaro/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython.js
More file actions
110 lines (101 loc) · 3.26 KB
/
Copy pathPython.js
File metadata and controls
110 lines (101 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Python Regular Expressions
*
* @author Peter Varo
* @author Craig Campbell
* @version 1.1.0
*/
Rainbow.extend('python', [
//- COMMENT ------------------------------------------------------------------//
{
'name' : 'comment.line.hashmark.python',
'pattern': /#.*/g
},
//- NUMBERS ------------------------------------------------------------------//
{
'name' : 'constant.numeric.integer.binary.python',
'pattern': /\b0b[01]+/g
},
{
'name' : 'constant.numeric.integer.hexadecimal.python',
'pattern': /\b0x[0-9a-fA-F]+/g
},
{
'name' : 'constant.numeric.integer.octal.python',
'pattern': /\b0o[0-7]+/g
},
{
//.001 .1e6 .1E6 .1e+6 .1E+6 .1e-6 .1E-6
'name' : 'constant.numeric.float_and_complex.decimal.floatnumber.python',
'pattern': /(?=\W)\.\d+([eE][+-]?\d+)?[jJ]?/g
},
{
//1. 1.0 1.1e6 1.1E6 1.1e+6 1.1E+6 1.1e-6 1.1E-6
'name' : 'constant.numeric.float_and_complex.decimal.pointfloat.python',
'pattern': /\d+\.(\d+([eE][+-]?\d+)?)?[jJ]?/g
},
{
//1e6 1E6 1e+6 1E+6 1e-6 1E-6
'name' : 'constant.numeric.float_and_complex.decimal.exponent.python',
'pattern': /\b(?!\.)\d+[eE][+-]?\d+[jJ]?/g
},
{
'name' : 'constant.numeric.integer_and_complex.decimal.python',
'pattern': /\b(?!\.)([1-9]\d*|0)[jJ]?/g
},
//- KEYWORDS -----------------------------------------------------------------//
{
'name' : 'storage.modifier.declaration.python',
'pattern': /\b(global|nonlocal)\b/g
},
{
'name' : 'keyword.control.import_and_import_from.python',
'pattern': /\b(import|from)\b/g
},
{
'name' : 'keyword.control.flow_block_delimiters.python',
'pattern': /\b(elif|else|except|finally|for|if|try|while|with|break|continue|pass|raise|return|yield)\b/g
},
{
'name' : 'keyword.operator.bool.logical.python',
'pattern': /\b(and|in|is|not|or)\b/g
},
{
'name' : 'keyword.other.python',
'pattern': /\b(as|assert|del)\b/g
},
//- OPERATORS ----------------------------------------------------------------//
{
'name' : 'keyword.operator.comparison.python',
'pattern': /<=|>=|==|<|>|!=/g
},
{
'name' : 'keyword.operator.assignment.augmented.python',
'pattern': /\+=|-=|\*=|\/=|\/\/=|%=|&=|\|=|\^=|<<=|>>=|\*\*=/g
},
{
'name' : 'keyword.operator.arithmetic.python',
'pattern': /\+|-|\*|\*\*|\/|\/\/|%|<<|>>|&|\||\^|~/g
},
{
'name' : 'keyword.operator.value_and_annotation_assignment.python',
'pattern': /=|->/g
},
//- CLASS --------------------------------------------------------------------//
{
'pattern': /\s*(class)\s+([A-z_]\w*)(\s*\(([A-z_]\w*\s*,?\s*)*\))?:/g,
'matches':
{
1: 'storage.type.class.python',
2: 'entity.name.type.class.python',
3: 'entity.other.inherited-class.python'
}
}
// {
// 'pattern': /\s*class\s+\w+\s*\(([\w,\s]*)\):/g,
// 'matches':
// {
// 1: 'entity.other.inherited-class.python'
// }
// }
], true);