-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsyntax_test.res
354 lines (323 loc) · 11.6 KB
/
syntax_test.res
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
// SYNTAX TEST "ReScript.sublime-syntax"
// hi
// ^ source.res comment.line
//
// <- source.res comment.line punctuation.definition.comment
/* hello
// <- source.res comment.block punctuation.definition.comment.begin
world */
//^ source.res comment.block
// ^ source.res comment.block punctuation.definition.comment.end
"aa";
// ^ source.res string.quoted.double punctuation.definition.string.begin
// ^^ source.res string.quoted.double
// ^ source.res string.quoted.double punctuation.definition.string.end
// ^ source.res punctuation.terminator
'a'
// ^^^ source.res string.quoted.single
'ab'
// ^^^^ source.res
exception Hello
// <- keyword
// ^^^^^ variable.function variable.other
let a = -.0.1
// ^^ source.res keyword.operator
// ^^^ source.res constant.numeric
let a = 0b1
// ^ source.res keyword.operator
// ^^^ source.res constant.numeric
let a = 0o73
// ^^^^ source.res constant.numeric
let a = 0xff
// ^^^^ source.res constant.numeric
let a = 0Xff
// ^^^^ source.res constant.numeric
let a = +1_000_000.12
// ^ source.res keyword.operator
// ^^^^^^^^^^^^ source.res constant.numeric
let a = 1E3
// ^^^source.res constant.numeric
// bad
let a = 0bf
// ^^^source.res
let a = 0o58
// ^^^^source.res
let a = 0xfz
// ^^^^source.res
let a = -.1
// ^^ source.res keyword.operator
// ^source.res
let a = 1.
// ^source.res constant.numeric
// ^source.res punctuation.accessor
let a = .2
// ^source.res punctuation.accessor
// ^source.res constant.numeric
let bar = true
// <- source.res keyword
// ^source.res constant.language
let recordAccess = fooRecord.myName
// ^source.res punctuation.accessor
let recordAccessWithScope = fooRecord.ReasonReact.myName
// ^source.res entity.name.namespace
let [1, 2.2] = foo()
// ^ source.res constant.numeric
// ^^^ source.res constant.numeric
let [c, [a, [1], list{a, ...rest}, c], 2.2] = [c, 1, "d", 'a', 1+2]
// ^ source.res keyword
// ^ source.res keyword.operator
type bla<'a> = {
// <- source.res storage.type
// ^ source.res punctuation.section.braces.begin
a: int,
// ^ source.res punctuation.separator
ok: 'a,
}
// <- source.res punctuation.section.braces.end
let getItem = (theList) =>
if callSomeFunctionThatThrows() {
/* return the found item here */
// ^ source.res comment.block
} else {
raise(Not_found)
}
let result =
try (getItem([1, 2, 3])) {
| Not_found => 0 /* Default value if getItem throws */
//^ source.res punctuation.separator
// ^ source.res comment.block
}
let getCenterCoordinates = (aBla, doHello, ~b=1, ~c, ()) => {
// ^ source.res punctuation.definition.keyword
let x = doSomeOperationsHere("a")
let yy = doSomeMoreOperationsHere()
(x, y)
}
a->b(c)->Some
//^^ keyword.operator
// ^^ keyword.operator
a >= b
//^ keyword.operator
let f: (~radius: option<int>=?) = 1
// ^ source.res
// ^ keyword.operator.assignment
// ^ punctuation.separator
let f: (~radius: option<int>= ?) = 1
// ^ source.res
// ^ keyword.operator.assignment
// ^ punctuation.separator
type profession = Teacher | Director
// ^ source.res
/* test */
let person1 = Teacher
// ^ source.res
let getProfession = (person) =>
switch person {
| [Teacher] => "A teacher"
| Director => "A director"
| rest => "..."
}
let openSesame = 1
// ^^^^^^^^^^ source.res
open Soup
// <- source.res keyword
// ^^^^ entity.name.namespace
include {let a = 1}
// <- keyword
// ^ source.res keyword
open Belt.Map
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
include Belt.Map.Make()
// ^ source.res entity.name.namespace
Foo.Some(Bar)
// <- source.res entity.name.namespace
// ^ source.res
// ^ source.res
Foo.Some(Bar())
// ^ source.res
Foo.make(Bar())
module Bla = Belt.Map.Make(Bar({type t let a:b = "cc"}))
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res punctuation.section.parens.begin
// ^ source.res entity.name.namespace
// ^ source.res punctuation.section.parens.begin
// ^ source.res storage.type
// ^ source.res punctuation.section.parens.end
// ^ source.res punctuation.section.parens.end
module SetOfIntPairs: Foo = MakeSet(IntPair)
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
module SetOfIntPairs = MakeSet((IntPair), Bar);
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
module SetOfIntPairs = MakeSet(IntPair({type t = Bar}))
// ^ source.res entity.name.namespace
// ^^^ entity.name.namespace
module Foo = (Bar: Baz) => (Bar: Baz) => {let a = Bar};
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res
module Foo = (Bar: Baz) => (Bar: Baz) => List;
// ^ source.res entity.name.namespace
module Nested = (Foo: {}) => {
module NestMore = Bla
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
}
module type Bla = {
// ^ source.res entity.name.namespace
include (module type of BaseComponent)
// ^ source.res entity.name.namespace
}
/* test */
module School = {
type profession = Teacher | Director
/* test */
let person1 = Teacher
let getProfession = (person) =>
switch (person) {
| Teacher => "A teacher"
| Director => "A director"
}
module Nested = (
Foo: Bar,
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
{
type a = Bar
// ^ source.res
let a = ["1"]
}
) => {
module NestMore =
Bla
// ^ source.res entity.name.namespace
module NestMore = (Foo: {}) => Bla
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
}
module Nested2 = (
Foo: Bar,
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
Bar: Baz,
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
) => List
// ^ source.res entity.name.namespace
module Nested = (Foo: Bar, {type a = Bar let a = 1 } ) => {
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res
module NestMore = Bla
module NestMore: Foo = Bla
module NestMore: {type t = Bar} = Bla
// ^ source.res punctuation.section.braces.begin
// ^ source.res
// ^ source.res punctuation.section.braces.end
// ^ source.res entity.name.namespace
module NestMore: {type t = Bar} = {
// ^ source.res
type t = Variant
// ^ source.res
let a = ["hello"]
}
module NestMore = (Foo: {type t = Variant}) => Bla
module NestMore: Bla = (Foo: {}) => Bla
module NestMore: {type t = Bar let a: b = "cc" module Foo = {}} = (Foo: {}) => Bla
// ^ source.res
// ^ source.res entity.name.namespace
module type NestMore = {}
module NestMore = () => Bla.Qux
// ^ source.res entity.name.namespace
}
}
let p: School.School2.profession = School.getProfession(School.Foo)
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
// ^ source.res
let getAudience = (~excited) => excited ? "world!" : "world"
let jsx = <div className="foo">
<>
hi
</>
<Comp.Uter bar />
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
<Foo>
// ^ source.res entity.name.namespace
"hi"
</Foo>
// ^ source.res entity.name.namespace
<Foo.Bar> {"hi"} </Foo.Bar>
// ^ source.res entity.name.namespace
// ^ source.res entity.name.namespace
<Comp bar />
// ^ source.res entity.name.namespace
</div>
let \"a b" = c
let str = `hi`
// ^ source.res string.quoted.other punctuation.definition.string.begin
// ^^ source.res string.quoted.other
// ^ source.res string.quoted.other punctuation.definition.string.end
let interp = j`hello $bla bye`
// ^ string.quoted.other variable.annotation
// ^ punctuation.section.interpolation
// ^^^ source.res
// ^^^^^ string.quoted.other
let interp = j`hello $1 bye`
// ^^^^^^ string.quoted.other
let interp = j`hello ${world.bla->b(a)} bye`
// ^ source.res string.quoted.other punctuation.definition.string.begin
// ^ source.res string.quoted.other
// ^^ source.res punctuation.section.interpolation.begin
// ^ punctuation.accessor
// ^^ keyword.operator
// ^ punctuation.section.parens.begin
// ^ punctuation.section.interpolation.end
// ^^^ string.quoted.other
// ^ string.quoted.other punctuation.definition.string.end
let variant = #foo
// ^ source.res punctuation.definition.keyword
// ^^^ variable.function variable.other
let #...foo = bar
// ^^^^ punctuation.definition.keyword
// ^^^ variable.function variable.other
@foo(bar) let a = 1
// ^ source.res meta.annotation punctuation.definition.annotation
// ^^^ source.res meta.annotation variable.annotation
@foo (bar) let a = 1
@foo(@bar(baz)) let a = 1
// ^ source.res meta.annotation punctuation.definition.annotation
// ^^^ source.res meta.annotation variable.annotation
@foo let a = 1
@@foo let a = 1
// ^^ source.res meta.annotation punctuation.definition.annotation
@@foo(bar) let a = 1
%foo(bar)-2
// ^ source.res meta.annotation punctuation.definition.annotation
// ^^^ source.res meta.annotation variable.annotation
%foo (bar)-2
%foo-1
%%foo let a = 1
// ^^ source.res meta.annotation punctuation.definition.annotation
// ^^^ source.res meta.annotation variable.annotation
%%foo(bar) let a = 1
%%foo (bar) let a = 1
@bs.module external foo: {..} => {..} = "bla"
// ^^ source.res keyword.operator
// ^^ source.res keyword.operator
let asd = ["bar"]
let asd = list{"bar"}
// ^ source.res keyword
let asd = foo["bar"]
// ^ source.res
foo["bar"] = baz
// <- source.res