-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVolt.sublime-syntax
154 lines (143 loc) · 4.64 KB
/
Volt.sublime-syntax
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
%YAML 1.2
---
# Very rudimentary support for the Volt Language.
#
# This file copies heavily from the D language syntax.
name: Volt
comment: Volt language
file_extensions:
- volt
scope: source.volt
variables:
name: '[[:alpha:]_][[:alpha:]0-9_]*'
escape_sequence: '\\([''"?\\0abfnrtv]|x{{hex_char}}{2}|[0-7]{1,3}|u{{hex_char}}{4}|U{{hex_char}}{8}|&\w+;)'
hex_char: '[0-9a-fA-F]'
contexts:
prototype:
- include: comments
main:
- include: module
- include: declarations
- include: keywords
- include: numbers
- include: strings
module:
- match: \bmodule\b
scope: keyword.declaration.namespace.volt
push:
- meta_scope: meta.namespace.volt
- match: '{{name}}(?=\s*(;|$))'
scope: meta.path.volt entity.name.namespace.volt
- match: '{{name}}'
scope: meta.path.volt variable.other.volt
push:
- match: \.
scope: meta.path.volt punctuation.accessor.dot.volt
pop: true
- include: not-whitespace-illegal
- include: expect-end-of-line
declarations:
- match: '((fn)\s+({{name}})|(~this|this))\s*(\()'
captures:
2: keyword.function.volt
3: entity.name.function.volt
4: keyword.function.volt
5: meta.group.volt punctuation.section.group.begin.volt
push:
- meta_scope: meta.function-call.volt
- meta_content_scope: meta.group.volt
- match: '\)'
scope: meta.group.volt punctuation.section.group.end.volt
pop: true
- match: '(import)\s+({{name}})\s*='
captures:
1: keyword.import.volt
2: entity.name.import.volt
- match: '(import)\s+{{name}}'
captures:
1: keyword.import.volt
- match: '(struct|union|class|interface|enum)\s+({{name}})'
captures:
1: keyword.function.volt
2: entity.name.declaration.volt
keywords:
- match: '\b(if|else|for|while|try|catch|finally|return|switch|case|break|continue|default|foreach|foreach_reverse)\b'
scope: keyword.control.volt
- match: '\b(version)\b'
scope: keyword.version.volt
- match: '\b(private|protected|public|export)\b'
scope: storage.modifier.access-control.volt
- match: '\b(abstract|final)\b'
scope: storage.modifier.classes.volt
- match: '\b(const|immutable|scope|ref|in|out)\b'
scope: storage.modifier.volt
- match: '\b(global|local)\b'
scope: storage.modifier.thread.volt
- match: '(/|&|\||-|\+|<<|<>|>>|>>>||\*|%|\^|\^\^|~)='
scope: keyword.operator.assignment.volt
- match: '(/|<=|>=|==|!<>=|!<=|!>=|\.\.\.|\.\.|&|&&|\||\|\||-|--|\+|\+\+|<|<<|<>|>|>>|>>>|!|!<>|!<|!>|\?|,|:|\$|\*|%|\^|\^\^|~|@|=>|#)'
scope: keyword.operator.volt
- match: '(cast)'
scope: keyword.operator.volt
numbers:
- match: '\b(-)?[0-9.]+\b'
scope: constant.numeric.volt
strings:
- match: '"'
scope: punctuation.definition.string.begin.volt
set:
- meta_include_prototype: false
- meta_scope: meta.string.volt string.quoted.double.volt
- match: '"'
scope: punctuation.definition.string.end.volt
pop: true
- match: '{{escape_sequence}}'
scope: constant.character.escape.volt
- match: \\.
scope: invalid.illegal.unknown-escape.volt
- match: "`"
scope: punctuation.definition.string.begin.volt
set:
- meta_include_prototype: false
- meta_scope: meta.string.d string.quoted.double.raw.backtick.volt
- match: '`'
captures:
1: punctuation.definition.string.end.volt
2: storage.type.string.volt
pop: true
comments:
- match: /\*\*?
scope: punctuation.definition.comment.volt
push:
- meta_scope: comment.block.volt
- match: \*/
scope: punctuation.definition.comment.volt
pop: true
- match: (///?).*$\n?
scope: comment.line.double-slash.volt
captures:
1: punctuation.definition.comment.volt
- include: nested-comment
nested-comment:
- match: /\+\+?
scope: punctuation.definition.comment.volt
push:
- meta_scope: comment.block.nested.volt
- match: \+/
scope: punctuation.definition.comment.volt
pop: true
- include: nested-comment
not-whitespace-illegal:
- match: '\S'
scope: invalid.illegal.volt
not-whitespace-illegal-pop:
- match: '\S'
scope: invalid.illegal.volt
pop: true
end-of-line:
- match: ';'
scope: punctuation.terminator.volt
pop: true
expect-end-of-line:
- include: end-of-line
- include: not-whitespace-illegal-pop