-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.lean4.js
151 lines (149 loc) · 5.14 KB
/
source.lean4.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
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/leanprover/vscode-lean4>
// and licensed `apache-2.0`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: ['lean-4'],
patterns: [
{include: '#comments'},
{match: '\\b(Prop|Type|Sort)\\b', name: 'storage.type.lean4'},
{match: '\\battribute\\b\\s*\\[[^\\]]*\\]', name: 'storage.modifier.lean4'},
{match: '@\\[[^\\]]*\\]', name: 'storage.modifier.lean4'},
{
match:
'\\b(?<!\\.)(global|local|scoped|partial|unsafe|private|protected|noncomputable)(?!\\.)\\b',
name: 'storage.modifier.lean4'
},
{match: '\\b(sorry|admit|stop)\\b', name: 'invalid.illegal.lean4'},
{
match: '#(print|eval|reduce|check|check_failure)\\b',
name: 'keyword.other.lean4'
},
{match: '\\bderiving\\s+instance\\b', name: 'keyword.other.command.lean4'},
{
begin:
'\\b(?<!\\.)(inductive|coinductive|structure|theorem|axiom|abbrev|lemma|def|instance|class|constant)\\b\\s+(\\{[^}]*\\})?',
beginCaptures: {1: {name: 'keyword.other.definitioncommand.lean4'}},
end: '(?=\\bwith\\b|\\bextends\\b|\\bwhere\\b|[:\\|\\(\\[\\{⦃<>])',
name: 'meta.definitioncommand.lean4',
patterns: [
{include: '#comments'},
{include: '#definitionName'},
{match: ','}
]
},
{
match:
'\\b(?<!\\.)(theorem|show|have|from|suffices|nomatch|def|class|structure|instance|set_option|initialize|builtin_initialize|example|inductive|coinductive|axiom|constant|universe|universes|variable|variables|import|open|export|theory|prelude|renaming|hiding|exposing|do|by|let|extends|mutual|mut|where|rec|syntax|macro_rules|macro|deriving|fun|section|namespace|end|infix|infixl|infixr|postfix|prefix|notation|abbrev|if|then|else|calc|match|with|for|in|unless|try|catch|finally|return|continue|break)(?!\\.)\\b',
name: 'keyword.other.lean4'
},
{begin: '«', contentName: 'entity.name.lean4', end: '»'},
{
begin: '(s!)"',
beginCaptures: {1: {name: 'keyword.other.lean4'}},
end: '"',
name: 'string.interpolated.lean4',
patterns: [
{
begin: '(\\{)',
beginCaptures: {1: {name: 'keyword.other.lean4'}},
end: '(\\})',
endCaptures: {1: {name: 'keyword.other.lean4'}},
patterns: [{include: '$self'}]
},
{match: '\\\\[\\\\"ntr\']', name: 'constant.character.escape.lean4'},
{
match: '\\\\x[0-9A-Fa-f][0-9A-Fa-f]',
name: 'constant.character.escape.lean4'
},
{
match: '\\\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]',
name: 'constant.character.escape.lean4'
}
]
},
{
begin: '"',
end: '"',
name: 'string.quoted.double.lean4',
patterns: [
{match: '\\\\[\\\\"ntr\']', name: 'constant.character.escape.lean4'},
{
match: '\\\\x[0-9A-Fa-f][0-9A-Fa-f]',
name: 'constant.character.escape.lean4'
},
{
match: '\\\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]',
name: 'constant.character.escape.lean4'
}
]
},
{match: '\\b(true|false)\\b', name: 'constant.language.lean4'},
{match: "'[^\\\\']'", name: 'string.quoted.single.lean4'},
{
captures: {1: {name: 'constant.character.escape.lean4'}},
match:
"'(\\\\(x[0-9A-Fa-f][0-9A-Fa-f]|u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]|.))'",
name: 'string.quoted.single.lean4'
},
{match: '`+[^\\[(]\\S+', name: 'entity.name.lean4'},
{
match:
'\\b([0-9]+|0([xX][0-9a-fA-F]+)|[-]?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?)\\b',
name: 'constant.numeric.lean4'
}
],
repository: {
blockComment: {
begin: '/-',
end: '-/',
name: 'comment.block.lean4',
patterns: [{include: 'source.lean4.markdown'}, {include: '#blockComment'}]
},
comments: {
patterns: [
{include: '#dashComment'},
{include: '#docComment'},
{include: '#stringBlock'},
{include: '#modDocComment'},
{include: '#blockComment'}
]
},
dashComment: {
begin: '--',
end: '$',
name: 'comment.line.double-dash.lean4',
patterns: [{include: 'source.lean4.markdown'}]
},
definitionName: {
patterns: [
{
match:
'\\b[^:«»\\(\\)\\{\\}[:space:]=→λ∀?][^:«»\\(\\)\\{\\}[:space:]]*',
name: 'entity.name.function.lean4'
},
{begin: '«', contentName: 'entity.name.function.lean4', end: '»'}
]
},
docComment: {
begin: '/--',
end: '-/',
name: 'comment.block.documentation.lean4',
patterns: [{include: 'source.lean4.markdown'}, {include: '#blockComment'}]
},
modDocComment: {
begin: '/-!',
end: '-/',
name: 'comment.block.documentation.lean4',
patterns: [{include: 'source.lean4.markdown'}, {include: '#blockComment'}]
}
},
scopeName: 'source.lean4'
}
export default grammar