-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.vyper.js
93 lines (91 loc) · 2.9 KB
/
source.vyper.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/davidhq/SublimeEthereum>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.vy'],
names: ['vyper'],
patterns: [
{match: '\\#.*', name: 'comment'},
{begin: '(\\"\\"\\")', end: '(\\"\\"\\")', name: 'comment'},
{match: '\\b(event|indexed)\\b', name: 'keyword.control'},
{
captures: {
2: {name: 'entity.name.function'},
3: {name: 'entity.name.function'}
},
match:
'\\b(contract|interface|library|using|struct|constructor|modifier)(\\s+[A-Za-z_]\\w*)?(?:\\s+is\\s+((?:[A-Za-z_][\\,\\s]*)*))?\\b',
name: 'keyword.control'
},
{
captures: {
2: {name: 'entity.name.function'},
3: {name: 'entity.name.function'}
},
match: '\\b(def)(\\s+[A-Za-z_]\\w*)?\\b',
name: 'keyword'
},
{match: '\\b(True|False)\\b', name: 'constant.language'},
{match: '\\bself\\b', name: 'markup.italic'},
{
match:
'\\b(address(?:\\s+payable)?|string|bytes?\\d*|int\\d*|uint\\d*|bool|u?fixed\\d+x\\d+)\\b',
name: 'support.type'
},
{
match:
'\\b(import|constant|map|raise|payable|storage|memory|calldata|if|else|for|while|do|break|continue|return|private|public|immutable|pure|view|internal|external|this|suicide|selfdestruct|delegatecall|emit|new|is|throw|revert|assert|require|\\_)\\b',
name: 'keyword.control'
},
{match: '\\b(not|and|or|pass|from|import|as)\\b', name: 'keyword'},
{match: '(@[A-Za-z_]\\w*)\\b', name: 'markup.italic'},
{
match: '(=|!|>|<|\\||&|\\?|\\^|~|\\*|\\+|\\-|\\/|\\%|\\bhex\\b)',
name: 'keyword.operator'
},
{
captures: {1: {name: 'support.type'}, 2: {name: 'support.type'}},
match: '\\b(msg|block|tx)\\.([A-Za-z_]\\w*)\\b'
},
{
captures: {1: {name: 'markup.italic'}},
match: '\\b(blockhash|gasleft)\\s*\\('
},
{
captures: {
1: {name: 'entity.name.function'},
2: {name: 'constant.numeric'},
3: {name: 'constant.numeric'}
},
match: '\\b([A-Za-z_]\\w*)(?:\\[(\\d*)\\])?(?:\\[(\\d*)\\])?\\('
},
{
match: '\\b(?:[+-]?\\.?\\d[\\d_eE]*)(?:\\.\\d+[\\deE]*)?\\b',
name: 'constant.numeric'
},
{match: '\\b(0[xX][a-fA-F0-9]+)\\b', name: 'constant.numeric'},
{
begin: '(?<!\\\\)[\\"\\\']',
end: '(?<!\\\\)[\\"\\\']',
name: 'string.quoted',
patterns: [{include: '#string'}]
}
],
repository: {
string: {
patterns: [
{match: '\\\\"', name: 'constant.character.escape'},
{match: "\\\\'", name: 'constant.character.escape'},
{match: '.', name: 'string.quoted'}
]
}
},
scopeName: 'source.vyper'
}
export default grammar