/
source.bb.js
172 lines (171 loc) · 5.18 KB
/
source.bb.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/yoctoproject/vscode-bitbake>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.bb', '.bbappend', '.bbclass'],
names: ['bitbake'],
patterns: [
{include: '#escaped-single-quote'},
{include: '#escaped-double-quote'},
{include: '#string'},
{include: '#numeric'},
{include: '#keywords'},
{include: '#comment'},
{include: '#inline-python'},
{include: '#variable-expansion'},
{include: '#functions'},
{include: '#bitbake-operator'},
{include: '#variable-name'},
{include: '#operator'}
],
repository: {
'bitbake-operator': {
match: '(?<=:)(append|prepend|remove)',
name: 'keyword.control.bb'
},
comment: {
captures: {
1: {name: 'punctuation.whitespace.comment.leading.bb'},
2: {name: 'comment.line.bb'},
3: {name: 'comment.line.number-sign.bb'},
4: {name: 'comment.line.text.bb'}
},
match: '(\\s*)((#)(.*))\\n'
},
'escaped-double-quote': {
match: '\\\\"',
name: 'constant.character.escape.bb'
},
'escaped-single-quote': {
match: "\\\\'",
name: 'constant.character.escape.bb'
},
functions: {
captures: {
1: {name: 'entity.name.function.python.bb'},
2: {name: 'keyword.operator.bb'},
3: {name: 'keyword.other.bitbake-operator.bb'}
},
match: '([a-zA-Z_][\\w_]*)(:([a-zA-Z_][\\w_]*))?(?=\\s*\\()'
},
'inline-python': {
begin: '(\\$\\{(@))',
beginCaptures: {
1: {name: 'punctuation.definition.template-expression.end.bb'},
2: {name: 'entity.name.function.decorator.python.bb'}
},
end: '(\\})',
endCaptures: {
1: {name: 'punctuation.definition.template-expression.end.bb'}
},
patterns: [
{include: '#operator'},
{include: '#keywords'},
{match: '(\\[)', name: 'meta.embedded.brackets.begin.bb'},
{match: '(\\])', name: 'meta.embedded.brackets.end.bb'},
{include: '#numeric'},
{include: '#functions'},
{include: '#parenthesis-open'},
{include: '#parenthesis-close'},
{include: '#variable-name'},
{include: '#string'}
]
},
keywords: {
patterns: [
{
captures: {1: {name: 'keyword.control.bb'}},
match:
'(?<![[:punct:]])\\b(include|require|inherit|inherit_defer|addtask|deltask|after|before|export|echo|if|fi|unset|print|fakeroot|EXPORT_FUNCTIONS|INHERIT)\\b(?![[:punct:]])'
},
{include: '#python-keywords'},
{
captures: {1: {name: 'storage.type.function.python.bb'}},
match: '\\b(python|def)\\b(\\(?)'
}
]
},
numeric: {match: '(-|\\.)?[0-9]+(\\.[0-9]+)?', name: 'constant.numeric.bb'},
operator: {
match: '(=|\\?=|\\?\\?=|:=|\\+=|=\\+|\\.=|=\\.|\\.|,)',
name: 'keyword.operator.bb'
},
'parenthesis-close': {
match: '\\)',
name: 'meta.embedded.parenthesis.close.bb'
},
'parenthesis-open': {
match: '([\\w])*\\(',
name: 'meta.embedded.parenthesis.open.bb'
},
'python-keywords': {
patterns: [
{
captures: {1: {name: 'keyword.control.bb'}},
match:
'\\b(if|elif|else|for|while|break|continue|return|yield|try|except|finally|raise|assert|import|from|as|pass|del|with|async|await)\\b'
},
{
captures: {1: {name: 'storage.type.function.python.bb'}},
match: '\\b(def|class|global|nonlocal|and|or|not|in|is|lambda)\\b\\s+'
},
{match: '\\b(True|False)\\b', name: 'constant.language.python.bb'}
]
},
string: {
patterns: [
{
begin: '(""")',
end: '(""")',
name: 'string.quoted.triple.bb',
patterns: [
{include: '#escaped-single-quote'},
{include: '#escaped-double-quote'},
{include: '#inline-python'},
{include: '#variable-expansion'}
]
},
{
begin: '(")',
end: '(")',
name: 'string.quoted.double.bb',
patterns: [
{include: '#escaped-double-quote'},
{include: '#inline-python'},
{include: '#variable-expansion'}
]
},
{
begin: "(')",
end: "(')",
name: 'string.quoted.single.bb',
patterns: [
{include: '#escaped-single-quote'},
{include: '#inline-python'},
{include: '#variable-expansion'}
]
}
]
},
'variable-expansion': {
begin: '(\\$\\{)',
beginCaptures: {
1: {name: 'punctuation.definition.template-expression.begin.bb'}
},
end: '(\\})',
endCaptures: {
1: {name: 'punctuation.definition.template-expression.end.bb'}
},
name: 'variable.other.names.bb'
},
'variable-name': {
captures: {1: {name: 'variable.other.names.bb'}},
match: '([a-zA-Z_][\\w_]*)'
}
},
scopeName: 'source.bb'
}
export default grammar