-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.mligo.js
82 lines (80 loc) · 2.48 KB
/
source.mligo.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/pewulfman/Ligo-grammar>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.mligo'],
names: ['cameligo'],
patterns: [
{include: '#string'},
{include: '#block_comment'},
{include: '#line_comment'},
{include: '#attribute'},
{include: '#macro'},
{include: '#letbinding'},
{include: '#lambda'},
{include: '#typedefinition'},
{include: '#controlkeywords'},
{include: '#numericliterals'},
{include: '#operators'},
{include: '#identifierconstructor'},
{include: '#module'}
],
repository: {
attribute: {match: '\\[@.*\\]', name: 'keyword.control.attribute.mligo'},
block_comment: {
begin: '\\(\\*',
end: '\\*\\)',
name: 'comment.block.mligo'
},
controlkeywords: {
match: '\\b(match|with|if|then|else|assert|failwith|begin|end|in)\\b',
name: 'keyword.control.mligo'
},
identifierconstructor: {
captures: {1: {name: 'variable.other.enummember.mligo'}},
match: '\\b([A-Z][a-zA-Z0-9_$]*)\\s+'
},
lambda: {
begin: '\\b(fun)\\b',
beginCaptures: {1: {name: 'keyword.other.mligo'}},
end: '(->)',
endCaptures: {1: {name: 'keyword.operator.mligo'}}
},
letbinding: {
captures: {
1: {name: 'keyword.other.mligo'},
2: {name: 'storage.modifier.mligo'},
3: {name: 'entity.name.function.mligo'}
},
match: '\\b(let)\\b\\s*\\b(rec|)\\s*\\b([a-zA-Z$_][a-zA-Z0-9$_]*)'
},
line_comment: {match: '\\/\\/.*$', name: 'comment.block.mligo'},
macro: {match: '^\\#[a-zA-Z]+', name: 'meta.preprocessor.mligo'},
module: {
captures: {
1: {name: 'storage.class.mligo'},
2: {name: 'storage.var.mligo'}
},
match: '\\b([A-Z][a-zA-Z0-9_$]*)\\.([a-z][a-zA-Z0-9_$]*)'
},
numericliterals: {
match: '(\\+|\\-)?[0-9]+(n|tz|tez|mutez|)\\b',
name: 'constant.numeric.mligo'
},
operators: {
match:
'\\s+(::|\\-|\\+|mod|land|lor|lxor|lsl|lsr|&&|\\|\\||>|<>|<=|=>|<|>)\\s+',
name: 'keyword.operator.mligo'
},
string: {begin: '\\"', end: '\\"', name: 'string.quoted.double.mligo'},
typedefinition: {match: '\\b(type)\\b', name: 'entity.name.type.mligo'}
},
scopeName: 'source.mligo'
}
export default grammar