-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.opa.js
133 lines (131 loc) · 3.51 KB
/
source.opa.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/mads379/opa.tmbundle>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.opa'],
names: ['opa'],
patterns: [{include: '#code'}],
repository: {
code: {
patterns: [
{include: '#xml-literal'},
{include: '#strings'},
{include: '#comments'},
{include: '#declarations'},
{include: '#keywords'},
{include: '#constants'},
{include: '#directive'}
]
},
comments: {
patterns: [
{
begin: '/\\*(\\*)?',
end: '\\*/',
name: 'comment.block.opa',
patterns: [
{match: '@\\w*', name: 'keyword.annotation.opa'},
{include: '#comments'}
]
},
{match: '\\/\\/.*$', name: 'comment.single.opa'}
]
},
constants: {
patterns: [
{match: '\\b(void|false|true)\\b', name: 'constant.language'},
{
match:
'\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)([LlFfUuDd]|UL|ul)?\\b',
name: 'constant.numeric.opa'
}
]
},
declarations: {
patterns: [
{
captures: {1: {name: 'entity.name.module'}},
match: '([\\w_]*)\\s*=\\s*{{'
},
{
captures: {1: {name: 'keyword.opa'}, 2: {name: 'entity.name.type'}},
match: '\\b(type)\\b\\s*([a-zA-Z_][a-zA-Z0-9_]*|`[^`\\n\\r]`)'
},
{
begin:
'^\\s*(@[\\w_]*)?\\s*([\\w_]*)\\((?=.*\\)\\s*(:\\s(\\w*))?\\s*=)',
beginCaptures: {
1: {name: 'keyword.directive.opa'},
2: {name: 'entity.name.function'}
},
end: '\\)\\s*(:\\s(\\w*))?\\s*='
},
{
captures: {1: {name: 'variable.other.opa'}},
match: '(\\w*)(:.*)?\\s*=[^=]'
}
]
},
directive: {match: '@[\\w_]*', name: 'keyword.directive.opa'},
'embedded-source': {
patterns: [
{
begin: '{',
end: '}',
name: 'source.opa.embeded.block',
patterns: [{include: '#code'}, {include: '#embedded-source'}]
}
]
},
keywords: {
match:
'\\b(_|as|do|else|if|match|then|type|with|and|begin|css|db|end|external|forall|import|package|parser|rec|server|val|xml_parser)\\b',
name: 'keyword.opa'
},
strings: {
patterns: [
{
begin: '(?<!\\\\)"',
end: '"',
name: 'string.quoted.double.scala',
patterns: [{match: '\\\\.', name: 'constant.character.escape.scala'}]
}
]
},
'xml-attribute': {
patterns: [
{
captures: {
1: {name: 'entity.other.attribute-name'},
3: {name: 'string.quoted.double'},
4: {name: 'variable.other.opa'}
},
match: '(\\w+)=(("[^"]*")|(#\\w*))'
}
]
},
'xml-literal': {
patterns: [
{
begin: '</?([a-zA-Z0-9]+)',
beginCaptures: {1: {name: 'entity.name.tag'}},
end: '/?>',
name: 'text.xml',
patterns: [
{include: '#xml-literal'},
{include: '#xml-attribute'},
{include: '#embedded-source'}
]
}
]
}
},
scopeName: 'source.opa'
}
export default grammar