-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathsource.metta.js
More file actions
101 lines (99 loc) · 3.18 KB
/
Copy pathsource.metta.js
File metadata and controls
101 lines (99 loc) · 3.18 KB
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.metta'],
names: ['metta'],
patterns: [
{include: '#comment'},
{include: '#string'},
{include: '#number'},
{include: '#variable'},
{include: '#space-atom'},
{include: '#operator'},
{include: '#keyword'},
{include: '#builtin-function'},
{include: '#arithmetic'},
{include: '#builtin-type'},
{include: '#boolean'},
{include: '#punctuation'},
{include: '#function-call'}
],
repository: {
arithmetic: {
match: '(?<=[()\\s])(\\+|-|\\*|/|%|<|>|<=|>=|==)(?=[()\\s])',
name: 'support.function.arithmetic.metta'
},
boolean: {
match: '(?<=[()\\s])(True|False)(?=[()\\s])',
name: 'constant.language.boolean.metta'
},
'builtin-function': {
match:
'(?<=[()\\s])(get-type|get-metatype|collapse|superpose|assertEqual|assertEqualToResult|add-atom|remove-atom|get-atoms|new-space|car-atom|cdr-atom|cons-atom|nop|empty|Error|trace!|println!|sealed|apply|chain|unify)(?=[()\\s])',
name: 'support.function.builtin.metta'
},
'builtin-type': {
match:
'(?<=[()\\s])(Type|Atom|Symbol|Expression|Variable|Grounded|Number|Bool|String|%Undefined%)(?=[()\\s])',
name: 'support.type.builtin.metta'
},
comment: {match: ';[^\n\r]*', name: 'comment.line.semicolon.metta'},
'function-call': {
match: '(?<=\\()[a-zA-Z_][a-zA-Z0-9_!?-]*',
name: 'entity.name.function.metta'
},
keyword: {
match:
'(?<=[()\\s])(match|let\\*?|if|case|import!|include|bind!|pragma!|function|return)(?=[()\\s])',
name: 'keyword.control.metta'
},
number: {
match:
'(?<=[()\\s]|^)-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?(?=[()\\s]|$)',
name: 'constant.numeric.metta'
},
operator: {
patterns: [
{
match: '(?<=[\\s(]|^)!(?=[\\s(])',
name: 'keyword.operator.evaluation.metta'
},
{
match: '(?<=[\\s(])=(?=[\\s()])',
name: 'keyword.operator.definition.metta'
},
{
match: '(?<=[\\s(]):(?=[\\s()])',
name: 'keyword.operator.type-annotation.metta'
},
{match: '->', name: 'keyword.operator.arrow.metta'}
]
},
punctuation: {
patterns: [
{match: '\\(', name: 'punctuation.definition.list.begin.metta'},
{match: '\\)', name: 'punctuation.definition.list.end.metta'}
]
},
'space-atom': {
match: '&[a-zA-Z_][a-zA-Z0-9_-]*',
name: 'variable.language.self.metta'
},
string: {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.metta'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.metta'}},
name: 'string.quoted.double.metta',
patterns: [{match: '\\\\.', name: 'constant.character.escape.metta'}]
},
variable: {match: '\\$[^()\\s";]+', name: 'variable.other.metta'}
},
scopeName: 'source.metta'
}
export default grammar