-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.shen.js
125 lines (123 loc) · 3.51 KB
/
source.shen.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `bsd-3-clause`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.shen'],
names: ['shen'],
patterns: [{include: '#expressions'}],
repository: {
atoms: {
patterns: [
{
begin: '(\\")',
end: '(\\")',
name: 'string.quoted.double',
patterns: [
{match: '(~A|~R|~S|~%|c#\\d+;)', name: 'constant.character.escape'},
{match: '(c#[^;]*;)', name: 'invalid.illegal'}
]
},
{
match: '(?<=^|[\\s()\\[\\]])[+-]*\\d+\\.?\\d*(?=$|[\\s;()\\[\\]])',
name: 'constant.numeric'
},
{
match:
'(?<=^|[\\s()\\[\\]])[+-]*\\d+\\.?\\d*[^\\s;()\\[\\]]+(?=$|[\\s;()\\[\\]])',
name: 'invalid.illegal'
},
{
match:
'(?<=\\()(and|or|if|do|lambda|freeze|let|cond|cases|trap-error|where|package|defun|/.|define|defmacro|defcc|defprolog|datatype)(?=$|[\\s;()\\[\\]{}])',
name: 'keyword.control'
},
{
match:
'(?<=^|[\\s()\\[\\]{}])(->|<-|-->|<--|==>|<==|:=|__+)(?=$|[\\s;()\\[\\]{}])',
name: 'keyword.control'
},
{
match:
'(?<=^|[\\s()\\[\\]{}])(=|==|<|>|<=|>=|\\+|-|\\*|/)(?=$|[\\s;()\\[\\]{}])',
name: 'keyword.operator'
},
{
match: '(?<=\\(define\\s)([^\\s()\\[\\]{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'entity.name.function'
},
{
match: '(?<=\\(defmacro\\s)([^\\s()\\[\\]{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'entity.name.function'
},
{
match:
'(?<=\\(defprolog\\s)([^\\s()\\[\\]{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'entity.name.function'
},
{
match: '(?<=\\(package\\s)([^\\s()\\[\\]{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'entity.name.section'
},
{
match: '(?<=\\(datatype\\s)([^\\s()\\[\\]{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'entity.name.type'
},
{
match:
'(?<=^|[\\s()\\[\\]{}])([A-Z][^\\s()\\[\\];{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'variable.language'
},
{
match: '(?<=^|[\\s()\\[\\]])(<[^\\s()\\[\\]]*>)(?=$|[\\s;()\\[\\]])',
name: 'entity.name.tag'
},
{
match:
'(?<=^|[\\s)\\[\\]{}])([^A-Z\\s()\\[\\]:;\\|{}][^\\s()\\[\\];{}]*)(?=$|[\\s;()\\[\\]{}])',
name: 'constant.language'
},
{match: '(\\(\\)|\\[\\])', name: 'constant.language'}
]
},
comments: {
patterns: [
{match: '(\\\\\\\\.*$)', name: 'comment.line'},
{begin: '(\\\\\\*)', end: '(\\*\\\\)', name: 'comment.block'}
]
},
expressions: {
patterns: [
{include: '#comments'},
{include: '#atoms'},
{include: '#parens'},
{include: '#squares'}
]
},
parens: {
patterns: [
{
begin: '(\\()',
end: '(\\))',
name: 'meta.group',
patterns: [{include: '#expressions'}]
}
]
},
squares: {
patterns: [
{
begin: '(\\[)',
end: '(\\])',
name: 'meta.group',
patterns: [{include: '#expressions'}]
}
]
}
},
scopeName: 'source.shen'
}
export default grammar