forked from nilium/sublime-scheme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Scheme.tmLanguage
746 lines (735 loc) · 18.7 KB
/
Scheme.tmLanguage
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>
The foldings do not currently work the way I want them to. This
may be a limitation of the way they are applied rather than the
regexps in use. Nonetheless, the foldings will end on the last
identically indented blank line following an s-expression. Not
ideal perhaps, but it works. Also, the #illegal pattern never
matches an unpaired ( as being illegal. Why?! -- Rob Rix
Ok, hopefully this grammar works better on quoted stuff now. It
may break for fancy macros, but should generally work pretty
smoothly. -- Jacob Rus
I have attempted to get this under control but because of the way folding
and indentation interact in Textmate, I am not sure if it is possible. In the
meantime, I have implemented Python-style folding anchored at newlines.
Additionally, I have made some minor improvements to the numeric constant
highlighting. Next up is square bracket expressions, I guess, but that
should be trivial. -- ozy`
</string>
<key>fileTypes</key>
<array>
<string>scm</string>
<string>sch</string>
</array>
<key>foldingStartMarker</key>
<string>(?x)^ [ \t]* \(
(?<par>
( [^()\n]++ | \( \g<par> \)? )*+
)
$</string>
<key>foldingStopMarker</key>
<string>^\s*$</string>
<key>keyEquivalent</key>
<string>^~S</string>
<key>name</key>
<string>Scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#sexp</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>include</key>
<string>#language-functions</string>
</dict>
<dict>
<key>include</key>
<string>#quote</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>comment</key>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.scheme</string>
</dict>
</dict>
<key>match</key>
<string>(;).*$\n?</string>
<key>name</key>
<string>comment.line.semicolon.scheme</string>
</dict>
<key>constants</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>#[t|f]</string>
<key>name</key>
<string>constant.language.boolean.scheme</string>
</dict>
<dict>
<key>match</key>
<string>(?<=[\(\s])((#e|#i)?[0-9]+(\.[0-9]+)?|(#x)[0-9a-fA-F]+|(#o)[0-7]+|(#b)[01]+)(?=[\s;()'",\[\]])</string>
<key>name</key>
<string>constant.numeric.scheme</string>
</dict>
</array>
</dict>
<key>illegal</key>
<dict>
<key>match</key>
<string>[()\[\]]</string>
<key>name</key>
<string>invalid.illegal.parenthesis.scheme</string>
</dict>
<key>language-functions</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(?x)
(?<=(\s|\(|\[)) # preceded by space or (
( do|or|and|else|quasiquote|begin|if|case|set!|
cond|let|unquote|define|let\*|unquote-splicing|delay|
letrec)
(?=(\s|\())</string>
<key>name</key>
<string>keyword.control.scheme</string>
</dict>
<dict>
<key>comment</key>
<string>
These functions run a test, and return a boolean
answer.
</string>
<key>match</key>
<string>(?x)
(?<=(\s|\()) # preceded by space or (
( char-alphabetic|char-lower-case|char-numeric|
char-ready|char-upper-case|char-whitespace|
(?:char|string)(?:-ci)?(?:=|<=?|>=?)|
atom|boolean|bound-identifier=|char|complex|
identifier|integer|symbol|free-identifier=|inexact|
eof-object|exact|list|(?:input|output)-port|pair|
real|rational|zero|vector|negative|odd|null|string|
eq|equal|eqv|even|number|positive|procedure
)
(\?) # name ends with ? sign
(?=(\s|\()) # followed by space or (
</string>
<key>name</key>
<string>support.function.boolean-test.scheme</string>
</dict>
<dict>
<key>comment</key>
<string>
These functions change one type into another.
</string>
<key>match</key>
<string>(?x)
(?<=(\s|\()) # preceded by space or (
( char->integer|exact->inexact|inexact->exact|
integer->char|symbol->string|list->vector|
list->string|identifier->symbol|vector->list|
string->list|string->number|string->symbol|
number->string
)
(?=(\s|\()) # followed by space or (
</string>
<key>name</key>
<string>support.function.convert-type.scheme</string>
</dict>
<dict>
<key>comment</key>
<string>
These functions are potentially dangerous because
they have side-effects which could affect other
parts of the program.
</string>
<key>match</key>
<string>(?x)
(?<=(\s|\()) # preceded by space or (
( set-(?:car|cdr)| # set car/cdr
(?:vector|string)-(?:fill|set) # fill/set string/vector
)
(!) # name ends with ! sign
(?=(\s|\()) # followed by space or (
</string>
<key>name</key>
<string>support.function.with-side-effects.scheme</string>
</dict>
<dict>
<key>comment</key>
<string>
+, -, *, /, =, >, etc.
</string>
<key>match</key>
<string>(?x)
(?<=(\s|\()) # preceded by space or (
( >=?|<=?|=|[*/+-])
(?=(\s|\()) # followed by space or (
</string>
<key>name</key>
<string>keyword.operator.arithmetic.scheme</string>
</dict>
<dict>
<key>match</key>
<string>(?x)
(?<=(\s|\()) # preceded by space or (
( append|apply|approximate|
call-with-current-continuation|call/cc|catch|
construct-identifier|define-syntax|display|foo|
for-each|force|cd|gen-counter|gen-loser|
generate-identifier|last-pair|length|let-syntax|
letrec-syntax|list|list-ref|list-tail|load|log|
macro|magnitude|map|map-streams|max|member|memq|
memv|min|newline|nil|not|peek-char|rationalize|
read|read-char|return|reverse|sequence|substring|
syntax|syntax-rules|transcript-off|transcript-on|
truncate|unwrap-syntax|values-list|write|write-char|
# cons, car, cdr, etc
cons|c(a|d){1,4}r|
# unary math operators
abs|acos|angle|asin|assoc|assq|assv|atan|ceiling|
cos|floor|round|sin|sqrt|tan|
(?:real|imag)-part|numerator|denominator
# other math operators
modulo|exp|expt|remainder|quotient|lcm|
# ports / files
call-with-(?:input|output)-file|
(?:close|current)-(?:input|output)-port|
with-(?:input|output)-from-file|
open-(?:input|output)-file|
# char-«foo»
char-(?:downcase|upcase|ready)|
# make-«foo»
make-(?:polar|promise|rectangular|string|vector)
# string-«foo», vector-«foo»
string(?:-(?:append|copy|length|ref))?|
vector(?:-length|-ref)
)
(?=(\s|\()) # followed by space or (
</string>
<key>name</key>
<string>support.function.general.scheme</string>
</dict>
<dict>
<key>match</key>
<string>(?x)
(?<=(\()) # preceded by (
(
# nullary operators
list|newline
)
(?=(\))) # followed by )
</string>
<key>name</key>
<string>support.function.general.scheme.nullary</string>
</dict>
</array>
</dict>
<key>quote</key>
<dict>
<key>comment</key>
<string>
We need to be able to quote any kind of item, which creates
a tiny bit of complexity in our grammar. It is hopefully
not overwhelming complexity.
Note: the first two matches are special cases. quoted
symbols, and quoted empty lists are considered constant.other
</string>
<key>patterns</key>
<array>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.quoted.symbol.scheme</string>
</dict>
</dict>
<key>match</key>
<string>(?x)
(')\s*
([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)
</string>
<key>name</key>
<string>constant.other.symbol.scheme</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.quoted.empty-list.scheme</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>meta.expression.scheme</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.section.expression.begin.scheme</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>punctuation.section.expression.end.scheme</string>
</dict>
</dict>
<key>match</key>
<string>(?x)
(')\s*
((\()\s*(\)))
</string>
<key>name</key>
<string>constant.other.empty-list.schem</string>
</dict>
<dict>
<key>begin</key>
<string>(')\s*</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.quoted.scheme</string>
</dict>
</dict>
<key>comment</key>
<string>quoted double-quoted string or s-expression</string>
<key>end</key>
<string>(?=[\s()])|(?<=\n)</string>
<key>name</key>
<string>string.other.quoted-object.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#quoted</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>quote-sexp</key>
<dict>
<key>begin</key>
<string>(?<=\()\s*(quote)\b\s*</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.quote.scheme</string>
</dict>
</dict>
<key>comment</key>
<string>
Something quoted with (quote «thing»). In this case «thing»
will not be evaluated, so we are considering it a string.
</string>
<key>contentName</key>
<string>string.other.quote.scheme</string>
<key>end</key>
<string>(?=[\s)])|(?<=\n)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#quoted</string>
</dict>
</array>
</dict>
<key>quoted</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>begin</key>
<string>(\()</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.expression.begin.scheme</string>
</dict>
</dict>
<key>end</key>
<string>(\))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.expression.end.scheme</string>
</dict>
</dict>
<key>name</key>
<string>meta.expression.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#quoted</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#quote</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<key>sexp</key>
<dict>
<key>begin</key>
<string>(\()</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.expression.begin.scheme</string>
</dict>
</dict>
<key>end</key>
<string>(\))(\n)?</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.expression.end.scheme</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>meta.after-expression.scheme</string>
</dict>
</dict>
<key>name</key>
<string>meta.expression.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>begin</key>
<string>(?x)
(?<=\() # preceded by (
(define)\s+ # define
(\() # list of parameters
([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)
((\s+
([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])
)*
)\s*
(\))
</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.scheme</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.function.scheme</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>entity.name.function.scheme</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>variable.parameter.function.scheme</string>
</dict>
<key>7</key>
<dict>
<key>name</key>
<string>punctuation.definition.function.scheme</string>
</dict>
</dict>
<key>end</key>
<string>(?=\))</string>
<key>name</key>
<string>meta.declaration.procedure.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>include</key>
<string>#sexp</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?x)
(?<=\() # preceded by (
(lambda)\s+
(\() # opening paren
((?:
([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])
\s+
)*(?:
([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])
)?)
(\)) # closing paren
</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.scheme</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.variable.scheme</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>variable.parameter.scheme</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>punctuation.definition.variable.scheme</string>
</dict>
</dict>
<key>comment</key>
<string>
Not sure this one is quite correct. That \s* is
particularly troubling
</string>
<key>end</key>
<string>(?=\))</string>
<key>name</key>
<string>meta.declaration.procedure.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>include</key>
<string>#sexp</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?<=\()(define)\s([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)\s*.*?</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.scheme</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>variable.other.scheme</string>
</dict>
</dict>
<key>end</key>
<string>(?=\))</string>
<key>name</key>
<string>meta.declaration.variable.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>include</key>
<string>#sexp</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#quote-sexp</string>
</dict>
<dict>
<key>include</key>
<string>#quote</string>
</dict>
<dict>
<key>include</key>
<string>#language-functions</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>match</key>
<string>(?<=[\(\s])(#\\)(space|newline|tab)(?=[\s\)])</string>
<key>name</key>
<string>constant.character.named.scheme</string>
</dict>
<dict>
<key>match</key>
<string>(?<=[\(\s])(#\\)x[0-9A-F]{2,4}(?=[\s\)])</string>
<key>name</key>
<string>constant.character.hex-literal.scheme</string>
</dict>
<dict>
<key>match</key>
<string>(?<=[\(\s])(#\\).(?=[\s\)])</string>
<key>name</key>
<string>constant.character.escape.scheme</string>
</dict>
<dict>
<key>comment</key>
<string>
the . in (a . b) which conses together two elements
a and b. (a b c) == (a . (b . (c . nil)))
</string>
<key>match</key>
<string>(?<=[ ()])\.(?=[ ()])</string>
<key>name</key>
<string>punctuation.separator.cons.scheme</string>
</dict>
<dict>
<key>include</key>
<string>#sexp</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<key>string</key>
<dict>
<key>begin</key>
<string>(")</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.scheme</string>
</dict>
</dict>
<key>end</key>
<string>(")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.scheme</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.double.scheme</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\.</string>
<key>name</key>
<string>constant.character.escape.scheme</string>
</dict>
</array>
</dict>
</dict>
<key>scopeName</key>
<string>source.scheme</string>
<key>uuid</key>
<string>3EC2CFD0-909C-4692-AC29-1A60ADBC161E</string>
</dict>
</plist>