-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
source.berry.js
102 lines (100 loc) · 2.37 KB
/
source.berry.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/berry-lang/berry-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: ['.be'],
names: ['berry', 'be'],
patterns: [
{include: '#controls'},
{include: '#strings'},
{include: '#comment-block'},
{include: '#comments'},
{include: '#keywords'},
{include: '#function'},
{include: '#member'},
{include: '#identifier'},
{include: '#number'},
{include: '#operator'}
],
repository: {
'comment-block': {
begin: '\\#\\-',
end: '\\-#',
name: 'comment.berry',
patterns: []
},
comments: {
begin: '\\#',
end: '\\n',
name: 'comment.line.berry',
patterns: []
},
controls: {
patterns: [
{
match:
'\\b(if|elif|else|for|while|do|end|break|continue|return|try|except|raise)\\b',
name: 'keyword.control.berry'
}
]
},
function: {
patterns: [
{
match: '\\b([a-zA-Z_][a-zA-Z0-9_]*(?=\\s*\\())',
name: 'entity.name.function.berry'
}
]
},
identifier: {
patterns: [{match: '\\b[_A-Za-z]\\w+\\b', name: 'identifier.berry'}]
},
keywords: {
patterns: [
{
match:
'\\b(var|static|def|class|true|false|nil|self|super|import|as)\\b',
name: 'keyword.berry'
}
]
},
member: {
patterns: [
{
captures: {0: {name: 'entity.other.attribute-name.berry'}},
match: '\\.([a-zA-Z_][a-zA-Z0-9_]*)'
}
]
},
number: {
patterns: [
{
match: '0x[a-fA-F0-9]+|\\d+|(\\d+\\.?|\\.\\d)\\d*([eE][+-]?\\d+)?',
name: 'constant.numeric.berry'
}
]
},
operator: {
patterns: [
{
match: '\\(|\\)|\\[|\\]|\\.|-|\\!|~|\\*|/|%|\\+|&|\\^|\\||<|>|=|:',
name: 'keyword.operator.berry'
}
]
},
strings: {
patterns: [
{match: '"(\\\\.|[^"])*"', name: 'string.quoted.double.berry'},
{match: "'(\\\\.|[^'])*'", name: 'string.quoted.single.berry'}
]
}
},
scopeName: 'source.berry'
}
export default grammar