-
Notifications
You must be signed in to change notification settings - Fork 2
/
syntax_test_rebol.reb
369 lines (317 loc) · 10.3 KB
/
syntax_test_rebol.reb
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
; SYNTAX TEST "Packages/Rebol/Rebol.sublime-syntax"
LEX_DELIMIT: charset [
#"^(00)" ; null
#"^(0A)" ; LF
#"^(0D)" ; CR
#"^(20)" ; SPACE
#"^(22)" ; QUOTE `"`
"()/;[]{}"
] ; ==> '\x00\x0A\x0D\x20\x22\(\)/;\[\]{}'
;----
;^^^^ comment.docline.rebol punctuation.definition.comment.begin.rebol
;@@ foo
;^^ comment.todo.rebol punctuation.definition.comment.todo.rebol
; ^^^ comment.todo.rebol
; aaa
; ^^^ comment.line.rebol
#!/usr/bin/rebol
;^^^^^^^^^^^^^^^^ comment.line.shebang.rebol
;----------------------------------------------------------------
;-- integer! decimal!
111
; ^^^ constant.numeric.rebol
; ^ keyword.operator.arithmetic.rebol
1' ;@@ valid in Rebol but not in Red!
; ^^ constant.numeric.rebol
; ^ constant.numeric.rebol punctuation.separator.quote.rebol
1'000'000
; ^^^^^^^^^
; ^ constant.numeric.rebol punctuation.separator.quote.rebol
1.0
; ^^^ constant.numeric.rebol
; ^ constant.numeric.rebol punctuation.separator.decimal.rebol
1'000.0
; ^^^^^^^ constant.numeric.rebol
2e1
; ^^^ constant.numeric.rebol
; ^ constant.numeric.rebol constant.numeric.exponent.rebol punctuation.separator.exponent.rebol
2.0e2
; ^^^^^ constant.numeric.rebol
; ^ constant.numeric.rebol punctuation.separator.decimal.rebol
; ^ constant.numeric.rebol constant.numeric.exponent.rebol punctuation.separator.exponent.rebol
-2 + 2
; ^^ constant.numeric.rebol
; ^ constant.numeric.rebol punctuation.definition.numeric.sign.rebol
2e+1
; ^^^^ constant.numeric.rebol
; ^ constant.numeric.rebol constant.numeric.exponent.rebol punctuation.separator.exponent.rebol
; ^ constant.numeric.rebol constant.numeric.exponent.rebol punctuation.definition.numeric.sign.rebol
; ^ constant.numeric.rebol constant.numeric.exponent.rebol
1.#inf
; ^^^^^^ constant.numeric.rebol
+1.#inf
-1.#INF
1.#nan
+1.#NaN
; ^^^^^^^ constant.numeric.rebol
; ^ constant.numeric.rebol punctuation.definition.numeric.sign.rebol
;----------------------------------------------------------------
;-- logic! none!
true false none
; ^^^^ constant.language.rebol
; ^^^^^ constant.language.rebol
; ^^^^ constant.language.rebol
;----------------------------------------------------------------
;-- time!
1:00
; ^^^^ constant.numeric.time.rebol
; ^ constant.numeric.time.rebol punctuation.separator.time.rebol
; ^^ constant.numeric.time.rebol
1:00am
; ^^^^^^ constant.numeric.time.rebol
; ^^ constant.numeric.time.rebol storage.type.ampm.rebol
1:00:00
1:00:00.01
1:00:00,02
+1:00
+1:00:00
+1:00:00.01
+1:00:00,02
1:00am
1:00:00am
1:00:00.01am
1:00:00,02am
+1:00am
+1:00:00am
+1:00:00.01am
+1:00:00,02am
10:0
10:0
10:0:00
10:0:00.01
10:0:00,02
+10:0
+10:0:00
+10:0:00.01
+10:0:00,02
10:0am
10:0:00am
10:0:00.01am
10:0:00,02am
+10:0am
+10:0:00am
+10:0:00.01am
+10:0:00,02am
10:00
10:00
10:00:00
10:00:00.01
10:00:00,02
+10:00
+10:00:00
+10:00:00.01
+10:00:00,02
10:00am
10:00:00am
10:00:00.01am
10:00:00,02am
+10:00am
+10:00:00am
+10:00:00.01am
+10:00:00,02am
;----------------------------------------------------------------
;-- pair!
2x2
; ^^^ constant.numeric.pair.rebol
; ^ constant.numeric.pair.rebol storage.type.numeric.pair.rebol
0x0.5
; ^^^ constant.numeric.pair.rebol
0.5x0
; ^^^^^ constant.numeric.pair.rebol
; ^ constant.numeric.pair.rebol storage.type.numeric.pair.rebol
; ^ constant.numeric.pair.rebol
2.2x3.4
; ^^^ constant.numeric.pair.rebol
2e2x1
; ^^^^^ constant.numeric.pair.rebol
1.#InFx1.#NaN
; ^^^^^^ constant.numeric.pair.rebol constant.numeric.pair.special.rebol
-1.0x+2.0
;----------------------------------------------------------------
;-- string
"a;b"
; ^^^^^ string.quoted.double.rebol
; ^ string.quoted.double.rebol punctuation.definition.string.begin.rebol
; ^ string.quoted.double.rebol punctuation.definition.string.end.rebol
"a{b"
{a;b}
; ^^^^^ string.quoted.double.rebol
; ^ string.quoted.double.rebol punctuation.definition.string.begin.rebol
; ^ string.quoted.double.rebol punctuation.definition.string.end.rebol
;----------------------------------------------------------------
;-- char!
#"a"
; ^^^^ constant.character.literal.rebol
; ^ constant.character.literal.rebol storage.modifier.rebol
; ^ constant.character.literal.rebol punctuation.definition.character.begin.rebol
; ^ constant.character.literal.rebol punctuation.definition.character.end.rebol
#";"
; ^^^^ constant.character.literal.rebol
; ^ constant.character.literal.rebol punctuation.definition.character.begin.rebol
#"^/"
; ^^ constant.character.literal.rebol constant.character.escape.rebol
#"^(00)"
#"^(tab)"
; ^^^^^^^^^ constant.character.literal.rebol
; ^^^^^^ constant.character.literal.rebol constant.character.escape.rebol
#"" ; valid, same like #"^@"
; ^^^ constant.character.literal.rebol
; invalid chars:
#"foo" #"^ab" #"^(tab)x" #"^(00000)"
;----------------------------------------------------------------
;-- hex number (Red only)
FFh
0Ah
01AAh
AAAAAAh
AAAAAAAAh
; ^^^^^^^^^ constant.numeric.hex.rebol
; ^ constant.numeric.hex.rebol storage.type.numeric.hex.rebol
;these should not be recognized as valid numbers:
0h Ah AAAAAAAAAAh aah
" ^(0) ^(00) ^(000) invalid:^(0000a)"
; ^ string.quoted.double.rebol punctuation.definition.string.begin.rebol
; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.rebol
; ^ string.quoted.double.rebol invalid.rebol invalid.illegal.rebol
;-- map!
#[a: 1 b: 2]
; ^^ meta.mapping.rebol punctuation.section.mapping.begin.rebol
; ^ meta.mapping.rebol punctuation.section.mapping.begin.rebol storage.modifier.rebol
; ^ meta.mapping.rebol entity.name.word.set.rebol
; ^ meta.mapping.rebol punctuation.section.mapping.end.rebol
;-- Construction syntax
#(true)
#(false)
#(none)
#(unset!)
#(logic! 0)
#(string! "abc" 2)
#(f32![1 2 3 4])
my-image: #(image! 2x2 #{FFFFFFFFFFFFFFFFFFFFFFFF})
my-block: [image! 2x2 #{FFFFFFFFFFFFFFFFFFFFFFFF}]
;with comments inside:
#(
binary! ; type
#{f00d} ; series
2 ; index
)
#(logic! 0)
; ^^^^^^^^^^^ meta.construct.rebol
; ^^ meta.construct.rebol punctuation.section.construct.begin.rebol
; ^ meta.construct.rebol punctuation.section.construct.begin.rebol storage.modifier.rebol
; ^^^^^^ meta.construct.rebol storage.type.datatype.rebol
; ^ meta.construct.rebol constant.numeric.rebol
; ^ meta.construct.rebol punctuation.section.construct.end.rebol
#(true)
;----------------------------------------------------------------
;-- binary!
#{F00D}
; ^^ binary.base16.rebol string.binary.prefix
; ^^^^ binary.base16.rebol string.binary.base16.rebol
; ^ binary.base16.rebol string.binary.prefix
16#{F00D}
; ^^^^ binary.base16.rebol string.binary.prefix
64#{8A0=}
; ^^^^ binary.base64.rebol string.binary.prefix
; ^^^^ binary.base64.rebol string.binary.base64.rebol
2#{0000 1100}
; ^^^ binary.base2.rebol string.binary.prefix
; ^^^^^^^^^ binary.base2.rebol string.binary.base2.rebol
;----------------------------------------------------------------
;-- tag!
<tag>
; ^^^^ entity.tag.rebol entity.other.namespace.xml
<tag name="foo" id='id'/>
; ^^^^^^^^ entity.tag.rebol entity.other.namespace.xml
; ^^^^^ entity.tag.rebol string.quoted.double.xml
; ^^ entity.tag.rebol entity.other.namespace.xml
; ^^^^ entity.tag.rebol string.quoted.single.xml
<---> ;<-- this is word! in Red, not a tag!
;----------------------------------------------------------------
;-- url!
http://user:pass@host:80/path?query#tag
; ^^^^ string.url.rebol string.url.scheme.rebol
; ^^^ string.url.rebol storage.type.url.rebol
; ^^^^^^^^^^^^^^^ string.url.rebol
scheme:/
; ^^^^^^ string.url.rebol string.url.scheme.rebol
; ^^ string.url.rebol storage.type.url.rebol
scheme://
scheme:host
mailto:user@foo.com
path/:a ;<-- not url!
;----------------------------------------------------------------
;-- set-word! get-word!
value: 111
; ^^^^^ entity.name.word.set.rebol
; ^ keyword.operator.assignment.rebol
:value
; ^ keyword.operator.assignment.rebol
; ^^^^^ entity.name.word.get.rebol
word's:
>>:
; true, false and none are not colorized as set-words
; to warn that it's not recommended
true: false: none:
;----------------------------------------------------------------
;-- lit-word!
'value
; ^ keyword.operator.quote.rebol
; ^^^^^ entity.name.word.lit.rebol
; these are valid lit-words:
'value''''
'_'
'_'_
'>>>>
; these are invalid lit-words:
'2nd ''foo ':foo '@ref
;----------------------------------------------------------------
;-- refinement!
/refinement
; ^ keyword.operator.refinement.rebol
; ^^^^^^^^^^ entity.name.word.refinement.rebol
/2nd /<< />>
path/foo/3
;----------------------------------------------------------------
;-- datatype!
integer!
; ^^^^^^^^ storage.type.datatype.rebol
; ^ storage.type.datatype.rebol storage.type.punctuation.rebol
;----------------------------------------------------------------
;-- function!
foo1: function [
;^^^ entity.name.function.rebol
"Some description"
argument [any-value!] "description"
/refinement
value [string!] "description"
;comment
][
;function body
if refinement [return value]
argument
]
foo2: function/with [][][]
foo3: closure/extern [][][]
ctx1: context [
;^^^ entity.name.class.rebol
foo: 1
]
ctx2: construct/with [a: 1] object [a: 2 b: 2]
my-module: module [][]
;^^^^^^^^^ entity.name.function.rebol
my-module: module/mixin [][] ctx2
<--->
;^^^^^ variable.other.rebol
---->
;^^^^^ variable.other.rebol