-
Notifications
You must be signed in to change notification settings - Fork 2
/
RON.sublime-syntax
201 lines (200 loc) · 6.15 KB
/
RON.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
%YAML 1.2
---
name: RON
file_extensions:
- ron
version: 2
scope: source.ron
variables: # from RustEnhanced
non_raw_ident: '[[:alpha:]][_[:alnum:]]*|_[_[:alnum:]]+'
identifier: '(?:(?:(?:r\#)?{{non_raw_ident}})\b)' # include a word boundary at the end to ensure all possible characters are consumed, to prevent catastrophic backtracking
contexts:
main:
- include: extension
- include: value
extension:
- match: '\#\!\['
scope: punctuation.section.array.begin.ron
push:
- meta_scope: meta.structure.array.ron
- match: '\]'
scope: punctuation.section.array.end.ron
pop: true
- include: extension_inner
- match: ','
scope: punctuation.separator.array.ron
- match: '[^\s\]]'
scope: invalid.illegal.expected-array-separator.ron
extension_inner:
- match: 'enable\('
push:
- meta_scope: meta.structure.entity.ron
- match: '\)'
scope: punctuation.section.entity.end.ron
pop: true
- include: extension_name
- match: ','
scope: punctuation.separator.entity.ron
extension_name:
- match: 'unwrap_newtypes'
scope: entity.name.tag.ron
- match: 'implicit_some'
scope: entity.name.tag.ron
array:
- match: '\['
scope: punctuation.section.array.begin.ron
push:
- meta_scope: meta.structure.array.ron
- match: '\]'
scope: punctuation.section.array.end.ron
pop: true
- include: value
- match: ','
scope: punctuation.separator.array.ron
- match: '[^\s\]]'
scope: invalid.illegal.expected-array-separator.ron
comments:
- match: /\*\*(?!/)
scope: punctuation.definition.comment.ron
push:
- meta_scope: comment.block.documentation.ron
- include: block_comment
- match: /\*
scope: punctuation.definition.comment.ron
push:
- meta_scope: comment.block.ron
- include: block_comment
- match: (//).*$\n?
scope: comment.line.double-slash.ron
captures:
1: punctuation.definition.comment.ron
block_comment:
- match: \*/
pop: true
- match: /\*
push: block_comment
constant:
- match: \b(true|false)\b
scope: constant.language.ron
number:
# handles integer and decimal numbers
- match: |-
(?x: # turn on extended mode
-? # an optional minus
(?:
0 # a zero
| # ...or...
[1-9] # a 1-9 character
\d* # followed by zero or more digits
)
(?:
(?:
\. # a period
\d+ # followed by one or more digits
)?
(?:
[eE] # an e character
[+-]? # followed by an option +/-
\d+ # followed by one or more digits
)? # make exponent optional
)? # make decimal portion optional
)
scope: constant.numeric.ron
object:
- match: '[A-Za-z_][A-Za-z_0-9]*'
scope: entity.name.class.ron
- match: '\('
scope: punctuation.section.dictionary.begin.ron
push:
- meta_scope: meta.structure.entity.ron
- match: '\)'
scope: punctuation.section.dictionary.end.ron
pop: true
- match: '[a-z_][A-Za-z_0-9]*(?!#")'
scope: entity.name.tag.ron
- match: '\:'
scope: punctuation.separator.dictionary.key-value.ron
- include: value
- match: ','
scope: punctuation.separator.dictionary.ron
dictionary:
- match: '\{'
scope: punctuation.section.dictionary.begin.ron
push:
- meta_scope: meta.structure.dictionary.ron
- match: '\}'
scope: punctuation.section.dictionary.end.ron
pop: true
- include: value
- match: ':'
scope: punctuation.separator.dictionary.key-value.ron
- include: value
- match: ','
scope: punctuation.separator.dictionary.ron
string:
- match: '"'
scope: punctuation.definition.string.begin.ron
push: inside-string
inside-string:
- meta_scope: string.quoted.double.ron
- match: '"'
scope: punctuation.definition.string.end.ron
pop: true
- include: string-escape
- match: $\n?
scope: invalid.illegal.unclosed-string.ron
pop: true
string-escape:
- match: |-
(?x: # turn on extended mode
\\ # a literal backslash
(?: # ...followed by...
["\\/bfnrt] # one of these characters
| # ...or...
u # a u
[0-9a-fA-F]{4} # and four hex digits
)
)
scope: constant.character.escape.ron
- match: \\.
scope: invalid.illegal.unrecognized-string-escape.ron
format-raw-string: # from RustEnhanced
- match: (r)(#*)"
captures:
1: storage.type.string.ron
2: punctuation.definition.string.begin.ron
push:
- meta_include_prototype: false
- meta_scope: string.quoted.double.raw.ron
- match : '"\2'
scope : punctuation.definition.string.end.ron
pop : true
- include : format-escapes
format-escapes:
- match: '\{\{|\}\}'
scope: constant.character.escape.ron
- match: |-
(?x) # Spec from http://doc.rust-lang.org/std/fmt/
\{
(\d+|{{identifier}})?
(
: # format_spec delimiter
(.?[<>^])? # [[fill]align]
[+-]? # [sign]
\#? # ['#']
0? # [0]
(\d+\$?)? # [width]
(\.(\d+\$?|\*)?)? # ['.' precision]
(\?|{{identifier}})? # [type]
)?
\}
scope: constant.other.placeholder.ron
value:
- include: constant
- include: number
- include: format-raw-string
- include: string
- include: array
- include: dictionary
- include: object
- include: comments