-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.mupad.js
104 lines (102 loc) · 3.13 KB
/
source.mupad.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/ccreutzig/sublime-MuPAD>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.mu'],
names: ['mupad'],
patterns: [
{
begin: '//',
end: '$',
name: 'comment.line.double-slash.mupad',
patterns: []
},
{include: '#blockcomment'},
{
match:
'\\b(axiom|end_axiom|category|end_category|begin|break|case|do|downto|elif|else|end_case|end_for|end_if|end_proc|end_repeat|end_while|for|from|if|%if|local|name|next|of|option|otherwise|proc|quit|repeat|save|step|then|to|until|while|domain|end|inherits|end_domain)\\b',
name: 'keyword.control.mupad'
},
{
match: '\\b(intersect|minus|union)\\b|->|-->|\\.',
name: 'keyword.operator.mupad'
},
{
match: '\\b(div|mod)\\b|\\+|-|\\*|/|\\^|\\|',
name: 'keyword.operator.arithmetic.mupad'
},
{
match: '\\b(and|in|not|or|xor)\\b|>|<|<>|=|<=>|<==|==>|\\|\\||&&',
name: 'keyword.operator.logical.mupad'
},
{match: ':=', name: 'keyword.operator.assignment.mupad'},
{match: '::', name: 'punctuation.accessor.mupad'},
{match: ';', name: 'punctuation.terminator.mupad'},
{match: ',', name: 'punctuation.separator.mupad'},
{
match:
'\\b(E|FAIL|FALSE|I|NIL|TRUE|UNKNOWN|PI|EULER|CATALAN|infinity|undefined)\\b',
name: 'constant.language.mupad'
},
{match: '(\\b[a-zA-Z_#]\\w*\\b|`.*?`)', name: 'entity.name.variable.mupad'},
{
captures: {
1: {name: 'entity.name.function.mupad'},
2: {name: 'variable.parameter.mupad'}
},
match:
'(?:\\b([a-zA-Z_]w+(?:::\\w+)*|`.*?`)\\s*:=\\s*)\\bproc\\b\\s*\\((.*?)\\)',
name: 'declaration.function.mupad.one'
},
{
captures: {
1: {name: 'entity.name.function.mupad'},
2: {name: 'variable.parameter.mupad'}
},
match:
'(?:\\b([a-zA-Z_]w+(?:::\\w+)*|`.*?`)\\s*:=\\s*)\\s*\\((.*?)\\)\\s*--?>',
name: 'declaration.function.mupad.two'
},
{
captures: {
1: {name: 'entity.name.function.mupad'},
2: {name: 'variable.parameter.mupad'}
},
match:
'(?:\\b([a-zA-Z_]w+(?:::\\w+)*|`.*?`)\\s*:=\\s*)\\s*(\\w+)\\s*--?>',
name: 'declaration.function.mupad.three'
},
{
match: '\\b(([0-9]+\\.?[0-9]*)((e|E)(\\+|-)?[0-9]+)?[ij]?)\\b',
name: 'constant.numeric.mupad'
},
{
begin: '"',
end: '"',
name: 'string.quoted.double.mupad',
patterns: [{include: '#string_escaped_char'}]
}
],
repository: {
blockcomment: {
begin: '/\\*',
end: '\\*/',
name: 'comment.block.mupad',
patterns: [{include: '#blockcomment'}]
},
string_escaped_char: {
patterns: [
{match: '\\\\(\\\\|[bntr"])', name: 'constant.character.escape.mupad'},
{match: '\\\\.', name: 'invalid.illegal.unknown-escape.mupad'}
]
}
},
scopeName: 'source.mupad'
}
export default grammar