-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.bqn.js
103 lines (101 loc) · 3.04 KB
/
source.bqn.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/razetime/bqn-vscode>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.bqn'],
names: ['bqn'],
patterns: [
{include: '#bracket'},
{include: '#number'},
{include: '#name'},
{include: '#operator'},
{include: '#variable'},
{include: '#string'},
{include: '#comment'},
{include: '#entity'},
{include: '#subject'}
],
repository: {
bracket: {patterns: [{match: '(\\(|\\))', name: 'meta.bracket.bqn'}]},
comment: {
patterns: [
{
begin: '#',
captures: {0: {name: 'punctuation.definition.comment.bqn'}},
end: '$',
name: 'comment.line.number-sign.bqn'
}
]
},
entity: {
patterns: [
{
match:
'([˙˜˘¨´˝`⌜⁼]|(‿\\K|\\b|^)_[A-ZÀ-ÖØ-Þa-zß-öø-ÿ𝕣][_A-ZÀ-ÖØ-Þa-zß-öø-ÿ¯π∞0-9]*[^_](\\b|(?=‿)))',
name: 'keyword.operator.modifier1.bqn'
}
]
},
number: {
patterns: [
{
match:
'(?<![A-Z_a-z0-9π∞¯])¯?(¯_*)?((\\d[\\d_]*(\\.\\d[\\d_]*)?|π_*)([eE]_*(¯_*)?\\d[\\d_]*)?|∞_*)(i_*(¯_*)?((\\d[\\d_]*(\\.\\d[\\d_]*)?|π_*)([eE]_*(¯_*)?\\d[\\d_]*)?|∞_*))?',
name: 'constant.numeric.bqn'
}
]
},
operator: {
patterns: [
{
match:
'([∘○⊸⟜⌾⊘◶⎊⎉⚇⍟]|((?:[𝕗𝔽𝕘𝔾𝕨𝕎𝕩𝕏𝕤𝕊𝕣‿])|\\b|^)_[A-ZÀ-ÖØ-Þa-zß-öø-ÿ𝕣][_A-ZÀ-ÖØ-Þa-zß-öø-ÿ¯π∞0-9]*_(\\b|(?=[𝕗𝔽𝕘𝔾𝕨𝕎𝕩𝕏𝕤𝕊𝕣‿])))',
name: 'keyword.control.modifier2.bqn'
}
]
},
string: {
patterns: [
{
begin: "'",
beginCaptures: {0: {name: 'punctuation.definition.string.begin.bqn'}},
end: "'",
endCaptures: {0: {name: 'punctuation.definition.string.end.bqn'}},
name: 'string.quoted.double.bqn'
},
{
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.bqn'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.bqn'}},
name: 'string.quoted.double.bqn'
}
]
},
subject: {
patterns: [
{
match: '[𝕗𝕘𝕨𝕩𝕤]|•?[a-zß-öø-ÿ][A-ZÀ-ÖØ-Þa-zß-öø-ÿ_0-9π∞¯]*',
name: 'support.class.bqn'
}
]
},
variable: {
patterns: [
{
match:
'[𝔽𝔾𝕎𝕏𝕊+\\-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!⍕⍎]|•?[A-ZÀ-ÖØ-Þ][A-ZÀ-ÖØ-Þa-zß-öø-ÿ_0-9π∞¯]*',
name: 'variable.language.function.bqn'
}
]
}
},
scopeName: 'source.bqn'
}
export default grammar