-
Notifications
You must be signed in to change notification settings - Fork 15
/
OrgBeancount.sublime-syntax
311 lines (311 loc) · 9.82 KB
/
OrgBeancount.sublime-syntax
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: OrgBeancount
file_extensions:
- orgbeancount
version: 2
extends: Packages/OrgExtended/OrgExtended.sublime-syntax
scope: source.orgbeancount text.orgmode
contexts:
comment:
# Comment
- match: ;.*
scope: comment.line.beancount
comments:
- match: (?<=\s)(;.*)(?=\n)
captures:
1: comment.line.beancount
illegal:
- match: ([^\s])
scope: invalid.illegal.unrecognized.beancount
amount:
- match: ([\-|\+]?)((?:\d|\d[\d,]*\d)(?:\.\d*)?)\s*([A-Z][A-Z0-9\'\.\_\-]{0,22}[A-Z0-9])
captures:
1: keyword.operator.modifier.beancount
2: constant.numeric.currency.beancount
3: entity.type.commodity.beancount
scope: meta.amount.beancount
commodity:
- match: ([A-Z][A-Z0-9\'\.\_\-]{0,22}[A-Z0-9])
scope: entity.type.commodity.beancount
cost:
- match: \{\{?
captures:
0: keyword.operator.assignment.beancount
push:
- meta_scope: meta.cost.beancount
- include: amount
- include: date
- match: \,
scope: punctuation.separator.beancount
- include: illegal
- match: \}\}?
captures:
0: keyword.operator.assignment.beancount
pop: true
date:
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})
scope: meta.date.beancount
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
flag:
- match: (?<=\s)([*!&#?%PSTCURM])
scope: keyword.other.beancount
link:
- match: (?<=\s)(\^)([A-Za-z0-9\-_/.]+)(?=\s)
captures:
1: keyword.operator.link.beancount
2: markup.underline.link.beancount
meta:
- match: ^\s*([a-z][A-Za-z0-9\-]+)([:])\s
captures:
1: keyword.operator.directive.beancount
2: punctuation.separator.beancount
push:
- meta_scope: meta.meta.beancount
- include: string
- include: comments
- include: illegal
- match: \n
pop: true
posting:
- match: ^\s+(?=([A-Z\!]))
push:
- meta_scope: meta.posting.beancount
- include: meta
- include: comments
- include: flag
- include: account
- include: amount
- include: cost
- include: date
- include: price
- include: illegal
- match: (?=(^\s*$|^\S|^\s*[A-Z]))
pop: true
price:
- match: \@\@?
captures:
0: keyword.operator.assignment.beancount
push:
- meta_scope: meta.price.beancount
- include: amount
- include: illegal
- match: (?=(;|\n))
pop: true
string:
- match: \"
push:
- meta_scope: string.quoted.double.beancount
- match: \\.
scope: constant.character.escape.beancount
- match: \"
pop: true
tag:
- match: (?<=\s)(#)([A-Za-z0-9\-_/.]+)(?=\s)
captures:
1: keyword.operator.tag.beancount
2: entity.name.tag.beancount
account:
# Account
- match: ([A-Z][A-Za-z0-9\-]+)(:)
captures:
1: constant.language.beancount
2: punctuation.separator.beancount
push:
- meta_scope: meta.account.beancount
# Sub Accounts
- match: ([A-Z][A-Za-z0-9\-]+)([:]?)
captures:
1: variable.account.beancount
2: punctuation.separator.beancount
push:
- match: ([:]?)|(\s)
pop: true
- include: illegal
- include: $self
- match: \s
pop: true
main:
- meta_append: true
# Tag directive
- match: ^(poptag|pushtag)\s+(#)([A-Za-z0-9\-_/.]+)
captures:
1: support.function.beancount
2: keyword.operator.tag.beancount
3: entity.name.tag.beancount
push:
- meta_scope: meta.directive.tag.beancount
- include: comment
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Include
- match: ^(include)\s+(\".*\")
captures:
1: support.function.beancount
2: string.quoted.double.beancount
push:
- meta_scope: meta.directive.include.beancount
- include: comment
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Option directive
- match: ^(option)\s+(\".*\")\s+(\".*\")
captures:
1: support.function.beancount
2: support.variable.beancount
3: support.quoted.double.beancount
push:
- meta_scope: meta.directive.option.beancount
- include: comment
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Plugin
- match: ^(plugin)\s+(\"(.*)\")\s+(\".*\")
captures:
1: support.function.beancount
2: support.quoted.double.beancount
3: entity.name.function.beancount
4: string.quoted.double.beancount
push:
- meta_scope: keyword.operator.directive.beancount
- include: comment
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Open/Close/Pad directive
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s+(open|close|pad)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.beancount
push:
- meta_scope: meta.directive.dated.beancount
- include: comment
- include: illegal
- include: account
- include: commodity
- match: \,
scope: punctuation.separator.beancount
- match: (?=(^\s*$|^\S))
pop: true
# Event directive
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s(event)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.directive.beancount
push:
- meta_scope: meta.directive.dated.beancount
- include: comment
- include: meta
- include: string
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Commodity directive
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s(commodity)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.directive.beancount
push:
- meta_scope: meta.directive.dated.beancount
- include: comments
- include: meta
- include: commodity
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Note/Document directive
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s(note|document)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.directive.beancount
push:
- meta_scope: meta.directive.dated.beancount
- include: comments
- include: meta
- include: account
- include: string
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Price directives
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s(price)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.directive.beancount
push:
- meta_scope: meta.directive.dated.beancount
- include: comments
- include: meta
- include: commodity
- include: amount
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Balance directives
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s(balance)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.directive.beancount
push:
- meta_scope: meta.directive.dated.beancount
- include: comments
- include: meta
- include: account
- include: amount
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true
# Transaction directive
- match: ([0-9]{4})([\-|/])([0-9]{2})([\-|/])([0-9]{2})\s+(txn|[*!&#?%PSTCURM])(?:\s+(".*")(?=\s+"))?\s+(".*?")(?=((?:\s+#[a-zA-z\-]+(?=\s))*(?:\s+\^[a-zA-z\-\.]+(?=\s))*(?:\s+;\s*.*)?)\s)
captures:
1: constant.numeric.date.year.beancount
2: punctuation.separator.beancount
3: constant.numeric.date.month.beancount
4: punctuation.separator.beancount
5: constant.numeric.date.day.beancount
6: support.function.directive.beancount
7: string.quoted.tiers.beancount
8: string.quoted.narration.beancount}
push:
- meta_scope: meta.directive.transaction.beancount
- include: comments
- include: posting
- include: meta
- include: tag
- include: link
- include: illegal
- match: (?=(^\s*$|^\S))
pop: true