lezer-beancount 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/index.cjs +181 -46
- package/dist/index.js +183 -48
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
This is a Beancount grammar for the [lezer](https://lezer.codemirror.net/) parser system.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/lezer-beancount)
|
|
6
|
+
[](https://github.com/robinvdvleuten/lezer-beancount/actions/workflows/build.yml)
|
|
7
|
+
[](https://licenses.dev/npm/lezer-beancount)
|
|
8
|
+
|
|
5
9
|
Reference:
|
|
6
10
|
|
|
7
11
|
- https://beancount.github.io/docs/index.html
|
|
8
12
|
- https://beancount.github.io/docs/beancount_language_syntax.html (contains the full spec)
|
|
13
|
+
|
|
14
|
+
## Testing
|
|
15
|
+
|
|
16
|
+
Besides its own fixtures, the test suite holds the parser to the ledgers of [go-beancount](https://github.com/robinvdvleuten/beancount)'s compliance and fuzz corpora, in `test/corpus`: on each file, the parser's error nodes must sit on the lines go-beancount's parser reports syntax errors on. go-beancount checks its parser against Beancount's own. The files that differ, and why, are listed in `test/corpus-known-failures.list`.
|
|
17
|
+
|
|
18
|
+
To update the corpus to a newer go-beancount (needs Go):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd scripts/corpus && go get github.com/robinvdvleuten/beancount@<commit> && cd ../.. && npm run sync-corpus
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The corpus is go-beancount's, under the GPL-2.0; it is test data only and not part of the npm package.
|
package/dist/index.cjs
CHANGED
|
@@ -4,98 +4,233 @@ var lr = require('@lezer/lr');
|
|
|
4
4
|
var highlight = require('@lezer/highlight');
|
|
5
5
|
var language = require('@codemirror/language');
|
|
6
6
|
|
|
7
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
8
|
+
const Indent = 1,
|
|
9
|
+
eol = 93,
|
|
10
|
+
eof = 94,
|
|
11
|
+
commentBreak = 95,
|
|
12
|
+
LineDate = 2,
|
|
13
|
+
Date = 3,
|
|
14
|
+
number = 96,
|
|
15
|
+
OrgMarker = 4;
|
|
16
|
+
|
|
17
|
+
const newline = 10, carriageReturn = 13, space = 32, tab = 9, semicolon = 59, hash = 35;
|
|
18
|
+
|
|
19
|
+
const isDigit = ch => ch >= 48 && ch <= 57;
|
|
20
|
+
const isTagChar = ch =>
|
|
21
|
+
isDigit(ch) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) ||
|
|
22
|
+
ch == 45 || ch == 95 || ch == 46 || ch == 47;
|
|
23
|
+
|
|
24
|
+
// Beancount's lexer reads a line's leading spaces and tabs as an indent,
|
|
25
|
+
// unless a carriage return is among them: a lone \r is whitespace to it,
|
|
26
|
+
// but no indent.
|
|
27
|
+
function indentAt(input, pos) {
|
|
28
|
+
let start = pos, cr = false;
|
|
29
|
+
for (;;) {
|
|
30
|
+
let ch = input.peek(pos);
|
|
31
|
+
if (ch == space || ch == tab) pos++;
|
|
32
|
+
else if (ch == carriageReturn) { cr = true; pos++; }
|
|
33
|
+
else break;
|
|
34
|
+
}
|
|
35
|
+
return { end: pos, indented: pos > start && !cr };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Whether the line ending at the line break at pos holds only whitespace.
|
|
39
|
+
function blankBefore(input, pos) {
|
|
40
|
+
while ([space, tab, carriageReturn].includes(input.peek(pos - 1))) pos--;
|
|
41
|
+
let prev = input.peek(pos - 1);
|
|
42
|
+
return prev < 0 || prev == newline;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Line structure, as Beancount's lexer and grammar see it:
|
|
46
|
+
// - an indented line holding only a comment goes on the line before it,
|
|
47
|
+
// when that one is no blank line: its line break is a commentBreak,
|
|
48
|
+
// skipped;
|
|
49
|
+
// - any other line break is an eol, ending its line; a blank line, or one
|
|
50
|
+
// holding a comment in column 1, ends a directive's body;
|
|
51
|
+
// - the indent of a line with content is an Indent, which continues a
|
|
52
|
+
// directive's body (and is an error where none goes on: an indented
|
|
53
|
+
// comment after a blank line too);
|
|
54
|
+
// - the end of the file ends its last line (eof, empty).
|
|
55
|
+
const lineBreak = new lr.ExternalTokenizer((input, stack) => {
|
|
56
|
+
if (input.next < 0) {
|
|
57
|
+
// Empty, so only where a line ends: elsewhere the parse ends.
|
|
58
|
+
if (stack.canShift(eof)) input.acceptToken(eof);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (input.next == newline) {
|
|
62
|
+
let { end, indented } = indentAt(input, 1);
|
|
63
|
+
if (indented && input.peek(end) == semicolon && !blankBefore(input, 0)) input.acceptToken(commentBreak, end);
|
|
64
|
+
else input.acceptToken(eol, 1);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let prev = input.peek(-1);
|
|
68
|
+
if (prev >= 0 && prev != newline) return;
|
|
69
|
+
let { end, indented } = indentAt(input, 0);
|
|
70
|
+
let next = input.peek(end);
|
|
71
|
+
if (indented && next >= 0 && next != newline) input.acceptToken(Indent, end);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
75
|
+
const isLeap = year => year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
|
76
|
+
|
|
77
|
+
// The end of the date at pos, as Beancount's lexer reads one: four or more
|
|
78
|
+
// digits, then twice a - or / and digits. -1 when there is none, 0 when
|
|
79
|
+
// there is one naming no day.
|
|
80
|
+
function dateEnd(input, pos) {
|
|
81
|
+
let parts = [];
|
|
82
|
+
for (let i = 0; i < 3; i++) {
|
|
83
|
+
if (i > 0) {
|
|
84
|
+
let sep = input.peek(pos);
|
|
85
|
+
if (sep != 45 && sep != 47) return -1;
|
|
86
|
+
pos++;
|
|
87
|
+
}
|
|
88
|
+
let start = pos, value = 0;
|
|
89
|
+
while (isDigit(input.peek(pos))) value = value * 10 + input.peek(pos++) - 48;
|
|
90
|
+
if (pos == start || (i == 0 && pos - start < 4)) return -1;
|
|
91
|
+
parts.push(value);
|
|
92
|
+
}
|
|
93
|
+
let [year, month, day] = parts;
|
|
94
|
+
if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 ||
|
|
95
|
+
day > (month == 2 && isLeap(year) ? 29 : daysInMonth[month - 1])) return 0;
|
|
96
|
+
return pos;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The end of the number at 0, as Beancount's lexer reads one: digits, with
|
|
100
|
+
// commas between groups of three after at most three, and a fraction, which
|
|
101
|
+
// may be empty ("5."). 0 for a malformed one.
|
|
102
|
+
function numberEnd(input) {
|
|
103
|
+
let pos = 0;
|
|
104
|
+
while (isDigit(input.peek(pos))) pos++;
|
|
105
|
+
if (input.peek(pos) == 44 && (isDigit(input.peek(pos + 1)) || input.peek(pos + 1) == 44)) {
|
|
106
|
+
if (pos > 3) return 0;
|
|
107
|
+
while (input.peek(pos) == 44 && (isDigit(input.peek(pos + 1)) || input.peek(pos + 1) == 44)) {
|
|
108
|
+
for (let i = 1; i <= 3; i++) if (!isDigit(input.peek(pos + i))) return 0;
|
|
109
|
+
pos += 4;
|
|
110
|
+
if (isDigit(input.peek(pos))) return 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (input.peek(pos) == 46) {
|
|
114
|
+
pos++;
|
|
115
|
+
while (isDigit(input.peek(pos))) pos++;
|
|
116
|
+
}
|
|
117
|
+
return pos;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Dates and numbers, read together so that wherever a number may go a date
|
|
121
|
+
// is a date (and an error), as to Beancount. A directive starts with a date
|
|
122
|
+
// at the start of a line (LineDate); elsewhere a date is a value. A date
|
|
123
|
+
// naming no day or a malformed number is no token at all, so an error.
|
|
124
|
+
const numbers = new lr.ExternalTokenizer(input => {
|
|
125
|
+
if (!isDigit(input.next)) return;
|
|
126
|
+
let date = dateEnd(input, 0);
|
|
127
|
+
if (date == 0) return;
|
|
128
|
+
if (date < 0) {
|
|
129
|
+
let end = numberEnd(input);
|
|
130
|
+
if (end) input.acceptToken(number, end);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let back = 0;
|
|
134
|
+
while ([space, tab, carriageReturn].includes(input.peek(back - 1))) back--;
|
|
135
|
+
let atLineStart = input.peek(back - 1) < 0 || input.peek(back - 1) == newline;
|
|
136
|
+
let lineStart = atLineStart && !indentAt(input, back).indented;
|
|
137
|
+
input.acceptToken(lineStart ? LineDate : Date, date);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const orgLineStarts = [42, 58, 35, 33, 38, 63, 37]; // * : # ! & ? %
|
|
141
|
+
|
|
142
|
+
// Beancount skips a line starting with one of *:#!&?% and another character
|
|
143
|
+
// (an org-mode heading or property, a flagged line), unless a # starts a tag.
|
|
144
|
+
const orgLine = new lr.ExternalTokenizer(input => {
|
|
145
|
+
let prev = input.peek(-1);
|
|
146
|
+
if (prev >= 0 && prev != newline) return;
|
|
147
|
+
let first = input.next, second = input.peek(1);
|
|
148
|
+
if (!orgLineStarts.includes(first) || second < 0 || second == newline ||
|
|
149
|
+
(first == hash && isTagChar(second))) return;
|
|
150
|
+
let pos = 1;
|
|
151
|
+
while (input.peek(pos) >= 0 && input.peek(pos) != newline) pos++;
|
|
152
|
+
input.acceptToken(OrgMarker, pos);
|
|
153
|
+
});
|
|
154
|
+
|
|
7
155
|
const beancountHighlighting = highlight.styleTags({
|
|
8
|
-
// Comments
|
|
9
156
|
LineComment: highlight.tags.lineComment,
|
|
10
157
|
|
|
11
|
-
// Literals
|
|
12
158
|
String: highlight.tags.string,
|
|
13
159
|
Number: highlight.tags.number,
|
|
14
160
|
Date: highlight.tags.literal,
|
|
15
161
|
BooleanValue: highlight.tags.bool,
|
|
162
|
+
NullValue: highlight.tags.null,
|
|
16
163
|
|
|
17
|
-
// Accounts and Currencies
|
|
18
164
|
Account: highlight.tags.variableName,
|
|
19
165
|
Currency: highlight.tags.unit,
|
|
20
166
|
|
|
21
|
-
// Transaction flags
|
|
22
167
|
TxnFlag: highlight.tags.modifier,
|
|
23
168
|
TxnKeyword: highlight.tags.modifier,
|
|
24
169
|
|
|
25
|
-
// Tags and Links
|
|
26
170
|
Tag: highlight.tags.tagName,
|
|
27
171
|
Link: highlight.tags.link,
|
|
28
172
|
|
|
29
|
-
|
|
30
|
-
"open close balance pad note document event price commodity query custom": highlight.tags.keyword,
|
|
31
|
-
"option include plugin pushtag poptag": highlight.tags.keyword,
|
|
173
|
+
Keyword: highlight.tags.keyword,
|
|
32
174
|
|
|
33
|
-
// Metadata
|
|
34
175
|
MetadataKey: highlight.tags.propertyName,
|
|
35
|
-
identifier: highlight.tags.name,
|
|
36
176
|
|
|
37
|
-
// Operators
|
|
38
177
|
ArithOp: highlight.tags.arithmeticOperator,
|
|
39
|
-
PriceOp: highlight.tags.operator,
|
|
40
178
|
"~": highlight.tags.operator,
|
|
41
179
|
|
|
42
|
-
|
|
43
|
-
LotLabel: highlight.tags.special(highlight.tags.operator),
|
|
180
|
+
CostTotal: highlight.tags.special(highlight.tags.operator),
|
|
44
181
|
CostMerge: highlight.tags.special(highlight.tags.operator),
|
|
45
182
|
|
|
46
|
-
// Delimiters
|
|
47
183
|
"{ } {{ }}": highlight.tags.brace,
|
|
48
184
|
"( )": highlight.tags.paren,
|
|
49
185
|
",": highlight.tags.separator,
|
|
50
186
|
":": highlight.tags.punctuation,
|
|
51
187
|
"@ @@": highlight.tags.operator,
|
|
52
188
|
|
|
53
|
-
OrgHeader: highlight.tags.heading,
|
|
54
189
|
OrgMarker: highlight.tags.heading,
|
|
55
190
|
});
|
|
56
191
|
|
|
192
|
+
// Fold from the end of the header line, so comment lines above the first
|
|
193
|
+
// posting or metadata line fold too, to the end of the last line, before
|
|
194
|
+
// the line break the directive ends with.
|
|
57
195
|
const beancountFolding = language.foldNodeProp.add({
|
|
58
|
-
|
|
59
|
-
|
|
196
|
+
DatedDirective: (node, state) => {
|
|
197
|
+
let from = state.doc.lineAt(node.from).to;
|
|
198
|
+
let to = state.doc.lineAt(node.to).from == node.to ? node.to - 1 : node.to;
|
|
199
|
+
return from < to ? { from, to } : null;
|
|
200
|
+
},
|
|
60
201
|
});
|
|
61
202
|
|
|
62
203
|
const beancountIndentation = language.indentNodeProp.add({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Note: context => context.baseIndent + context.unit,
|
|
71
|
-
Document: context => context.baseIndent + context.unit,
|
|
72
|
-
Event: context => context.baseIndent + context.unit,
|
|
73
|
-
Price: context => context.baseIndent + context.unit,
|
|
74
|
-
Commodity: context => context.baseIndent + context.unit,
|
|
75
|
-
Query: context => context.baseIndent + context.unit,
|
|
76
|
-
Custom: context => context.baseIndent + context.unit,
|
|
204
|
+
DatedDirective: context => context.baseIndent + context.unit,
|
|
205
|
+
// A new, still empty line ends a dated directive the way a blank line
|
|
206
|
+
// does, but right after one it is where its body goes on.
|
|
207
|
+
File: context => {
|
|
208
|
+
let before = context.node.childBefore(context.pos);
|
|
209
|
+
return before && before.name == "DatedDirective" && before.to == context.pos ? context.unit : 0;
|
|
210
|
+
},
|
|
77
211
|
});
|
|
78
212
|
|
|
79
213
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
80
|
-
const spec_identifier = {__proto__:null,open:
|
|
214
|
+
const spec_identifier = {__proto__:null,txn:205, open:87, close:95, balance:99, pad:105, note:109, document:113, event:117, price:121, commodity:125, query:129, custom:133, option:139, include:143, plugin:147, pushtag:151, poptag:155, pushmeta:159, popmeta:163};
|
|
81
215
|
const parser = lr.LRParser.deserialize({
|
|
82
216
|
version: 14,
|
|
83
|
-
states: "
|
|
84
|
-
stateData: "
|
|
85
|
-
goto: "
|
|
86
|
-
nodeNames: "⚠ LineComment File DatedDirective
|
|
87
|
-
maxTerm:
|
|
217
|
+
states: "=vQ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!xQ#{!yQ#|!zQ$O!|Q$Q#OQ$S#SQ$U#YQ$a#[Q$l#lQ$r#xQ$t#zQ$z$VS%Z$b$cQ%a${R%k%[X!e|!a!f#c`!c|!a!f!g#_#b#c$es#g!k!n!}#T#i#k#v#w#y#{#|$O$Q$S$l$r$tQ#W!]R${$VQ!t!QQ!{!VS#P!Y#SS#U!]$VQ#o!sQ#u!uY$W#[$Z$]$c%hQ$m#rQ$n#qQ$o#tS$|$Y%eQ%c%QQ%l%tR%m%bQ$b#[R%[$cS$^#[$cW%O$Y$Z%e%hR%W$]R%T$YQ%R$YQ%U$ZQ%o%eR%q%hQ%R$YR%o%eR%V$ZR!m!OR!v!QT#R!Y#S",
|
|
220
|
+
nodeNames: "⚠ Indent Date Date OrgMarker LineComment File DatedDirective Transaction TxnKeyword TxnFlag String Tag Link PostingBlock TransactionMetadata MetadataKey : Number ( ) ArithOp ArithOp Amount Currency Account BooleanValue NullValue TransactionTags Posting CostSpec { CostMerge CostTotal , } {{ }} PriceAnnotation PriceOp @ @@ Open open MetadataBlock DirectiveMetadata Close close Balance balance ~ Pad pad Note note Document document Event event Price price Commodity commodity Query query Custom custom UndatedDirective Option option Include include Plugin plugin Pushtag pushtag Poptag poptag Pushmeta pushmeta Popmeta popmeta OrgHeader",
|
|
221
|
+
maxTerm: 122,
|
|
88
222
|
nodeProps: [
|
|
89
|
-
["isolate", -
|
|
223
|
+
["isolate", -2,5,11,""],
|
|
224
|
+
["group", -18,43,47,49,52,54,56,58,60,62,64,66,69,71,73,75,77,79,81,"Keyword"]
|
|
90
225
|
],
|
|
91
226
|
propSources: [beancountHighlighting,beancountFolding,beancountIndentation],
|
|
92
|
-
skippedNodes: [0,
|
|
93
|
-
repeatNodeCount:
|
|
94
|
-
tokenData: "
|
|
95
|
-
tokenizers: [0, 1, 2
|
|
96
|
-
topRules: {"File":[0,
|
|
97
|
-
specialized: [{term:
|
|
98
|
-
tokenPrec:
|
|
227
|
+
skippedNodes: [0,5],
|
|
228
|
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q![9p!c!}9p#R#S9p#T#o9p~9uT#X~}!O9p!Q![9p!c!}9p#R#S9p#T#o9p~:ZPo~#o#p:^~:cOt~~:hPs~#q#r:k~:pOu~~:uO!S~",
|
|
230
|
+
tokenizers: [lineBreak, numbers, orgLine, 0, 1, 2],
|
|
231
|
+
topRules: {"File":[0,6]},
|
|
232
|
+
specialized: [{term: 101, get: (value) => spec_identifier[value] || -1}],
|
|
233
|
+
tokenPrec: 1875
|
|
99
234
|
});
|
|
100
235
|
|
|
101
236
|
exports.parser = parser;
|
package/dist/index.js
CHANGED
|
@@ -1,99 +1,234 @@
|
|
|
1
|
-
import { LRParser } from '@lezer/lr';
|
|
1
|
+
import { ExternalTokenizer, LRParser } from '@lezer/lr';
|
|
2
2
|
import { styleTags, tags } from '@lezer/highlight';
|
|
3
|
-
import { foldNodeProp,
|
|
3
|
+
import { foldNodeProp, indentNodeProp } from '@codemirror/language';
|
|
4
|
+
|
|
5
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
6
|
+
const Indent = 1,
|
|
7
|
+
eol = 93,
|
|
8
|
+
eof = 94,
|
|
9
|
+
commentBreak = 95,
|
|
10
|
+
LineDate = 2,
|
|
11
|
+
Date = 3,
|
|
12
|
+
number = 96,
|
|
13
|
+
OrgMarker = 4;
|
|
14
|
+
|
|
15
|
+
const newline = 10, carriageReturn = 13, space = 32, tab = 9, semicolon = 59, hash = 35;
|
|
16
|
+
|
|
17
|
+
const isDigit = ch => ch >= 48 && ch <= 57;
|
|
18
|
+
const isTagChar = ch =>
|
|
19
|
+
isDigit(ch) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) ||
|
|
20
|
+
ch == 45 || ch == 95 || ch == 46 || ch == 47;
|
|
21
|
+
|
|
22
|
+
// Beancount's lexer reads a line's leading spaces and tabs as an indent,
|
|
23
|
+
// unless a carriage return is among them: a lone \r is whitespace to it,
|
|
24
|
+
// but no indent.
|
|
25
|
+
function indentAt(input, pos) {
|
|
26
|
+
let start = pos, cr = false;
|
|
27
|
+
for (;;) {
|
|
28
|
+
let ch = input.peek(pos);
|
|
29
|
+
if (ch == space || ch == tab) pos++;
|
|
30
|
+
else if (ch == carriageReturn) { cr = true; pos++; }
|
|
31
|
+
else break;
|
|
32
|
+
}
|
|
33
|
+
return { end: pos, indented: pos > start && !cr };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Whether the line ending at the line break at pos holds only whitespace.
|
|
37
|
+
function blankBefore(input, pos) {
|
|
38
|
+
while ([space, tab, carriageReturn].includes(input.peek(pos - 1))) pos--;
|
|
39
|
+
let prev = input.peek(pos - 1);
|
|
40
|
+
return prev < 0 || prev == newline;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Line structure, as Beancount's lexer and grammar see it:
|
|
44
|
+
// - an indented line holding only a comment goes on the line before it,
|
|
45
|
+
// when that one is no blank line: its line break is a commentBreak,
|
|
46
|
+
// skipped;
|
|
47
|
+
// - any other line break is an eol, ending its line; a blank line, or one
|
|
48
|
+
// holding a comment in column 1, ends a directive's body;
|
|
49
|
+
// - the indent of a line with content is an Indent, which continues a
|
|
50
|
+
// directive's body (and is an error where none goes on: an indented
|
|
51
|
+
// comment after a blank line too);
|
|
52
|
+
// - the end of the file ends its last line (eof, empty).
|
|
53
|
+
const lineBreak = new ExternalTokenizer((input, stack) => {
|
|
54
|
+
if (input.next < 0) {
|
|
55
|
+
// Empty, so only where a line ends: elsewhere the parse ends.
|
|
56
|
+
if (stack.canShift(eof)) input.acceptToken(eof);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (input.next == newline) {
|
|
60
|
+
let { end, indented } = indentAt(input, 1);
|
|
61
|
+
if (indented && input.peek(end) == semicolon && !blankBefore(input, 0)) input.acceptToken(commentBreak, end);
|
|
62
|
+
else input.acceptToken(eol, 1);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
let prev = input.peek(-1);
|
|
66
|
+
if (prev >= 0 && prev != newline) return;
|
|
67
|
+
let { end, indented } = indentAt(input, 0);
|
|
68
|
+
let next = input.peek(end);
|
|
69
|
+
if (indented && next >= 0 && next != newline) input.acceptToken(Indent, end);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
73
|
+
const isLeap = year => year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
|
74
|
+
|
|
75
|
+
// The end of the date at pos, as Beancount's lexer reads one: four or more
|
|
76
|
+
// digits, then twice a - or / and digits. -1 when there is none, 0 when
|
|
77
|
+
// there is one naming no day.
|
|
78
|
+
function dateEnd(input, pos) {
|
|
79
|
+
let parts = [];
|
|
80
|
+
for (let i = 0; i < 3; i++) {
|
|
81
|
+
if (i > 0) {
|
|
82
|
+
let sep = input.peek(pos);
|
|
83
|
+
if (sep != 45 && sep != 47) return -1;
|
|
84
|
+
pos++;
|
|
85
|
+
}
|
|
86
|
+
let start = pos, value = 0;
|
|
87
|
+
while (isDigit(input.peek(pos))) value = value * 10 + input.peek(pos++) - 48;
|
|
88
|
+
if (pos == start || (i == 0 && pos - start < 4)) return -1;
|
|
89
|
+
parts.push(value);
|
|
90
|
+
}
|
|
91
|
+
let [year, month, day] = parts;
|
|
92
|
+
if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 ||
|
|
93
|
+
day > (month == 2 && isLeap(year) ? 29 : daysInMonth[month - 1])) return 0;
|
|
94
|
+
return pos;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// The end of the number at 0, as Beancount's lexer reads one: digits, with
|
|
98
|
+
// commas between groups of three after at most three, and a fraction, which
|
|
99
|
+
// may be empty ("5."). 0 for a malformed one.
|
|
100
|
+
function numberEnd(input) {
|
|
101
|
+
let pos = 0;
|
|
102
|
+
while (isDigit(input.peek(pos))) pos++;
|
|
103
|
+
if (input.peek(pos) == 44 && (isDigit(input.peek(pos + 1)) || input.peek(pos + 1) == 44)) {
|
|
104
|
+
if (pos > 3) return 0;
|
|
105
|
+
while (input.peek(pos) == 44 && (isDigit(input.peek(pos + 1)) || input.peek(pos + 1) == 44)) {
|
|
106
|
+
for (let i = 1; i <= 3; i++) if (!isDigit(input.peek(pos + i))) return 0;
|
|
107
|
+
pos += 4;
|
|
108
|
+
if (isDigit(input.peek(pos))) return 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (input.peek(pos) == 46) {
|
|
112
|
+
pos++;
|
|
113
|
+
while (isDigit(input.peek(pos))) pos++;
|
|
114
|
+
}
|
|
115
|
+
return pos;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Dates and numbers, read together so that wherever a number may go a date
|
|
119
|
+
// is a date (and an error), as to Beancount. A directive starts with a date
|
|
120
|
+
// at the start of a line (LineDate); elsewhere a date is a value. A date
|
|
121
|
+
// naming no day or a malformed number is no token at all, so an error.
|
|
122
|
+
const numbers = new ExternalTokenizer(input => {
|
|
123
|
+
if (!isDigit(input.next)) return;
|
|
124
|
+
let date = dateEnd(input, 0);
|
|
125
|
+
if (date == 0) return;
|
|
126
|
+
if (date < 0) {
|
|
127
|
+
let end = numberEnd(input);
|
|
128
|
+
if (end) input.acceptToken(number, end);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
let back = 0;
|
|
132
|
+
while ([space, tab, carriageReturn].includes(input.peek(back - 1))) back--;
|
|
133
|
+
let atLineStart = input.peek(back - 1) < 0 || input.peek(back - 1) == newline;
|
|
134
|
+
let lineStart = atLineStart && !indentAt(input, back).indented;
|
|
135
|
+
input.acceptToken(lineStart ? LineDate : Date, date);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const orgLineStarts = [42, 58, 35, 33, 38, 63, 37]; // * : # ! & ? %
|
|
139
|
+
|
|
140
|
+
// Beancount skips a line starting with one of *:#!&?% and another character
|
|
141
|
+
// (an org-mode heading or property, a flagged line), unless a # starts a tag.
|
|
142
|
+
const orgLine = new ExternalTokenizer(input => {
|
|
143
|
+
let prev = input.peek(-1);
|
|
144
|
+
if (prev >= 0 && prev != newline) return;
|
|
145
|
+
let first = input.next, second = input.peek(1);
|
|
146
|
+
if (!orgLineStarts.includes(first) || second < 0 || second == newline ||
|
|
147
|
+
(first == hash && isTagChar(second))) return;
|
|
148
|
+
let pos = 1;
|
|
149
|
+
while (input.peek(pos) >= 0 && input.peek(pos) != newline) pos++;
|
|
150
|
+
input.acceptToken(OrgMarker, pos);
|
|
151
|
+
});
|
|
4
152
|
|
|
5
153
|
const beancountHighlighting = styleTags({
|
|
6
|
-
// Comments
|
|
7
154
|
LineComment: tags.lineComment,
|
|
8
155
|
|
|
9
|
-
// Literals
|
|
10
156
|
String: tags.string,
|
|
11
157
|
Number: tags.number,
|
|
12
158
|
Date: tags.literal,
|
|
13
159
|
BooleanValue: tags.bool,
|
|
160
|
+
NullValue: tags.null,
|
|
14
161
|
|
|
15
|
-
// Accounts and Currencies
|
|
16
162
|
Account: tags.variableName,
|
|
17
163
|
Currency: tags.unit,
|
|
18
164
|
|
|
19
|
-
// Transaction flags
|
|
20
165
|
TxnFlag: tags.modifier,
|
|
21
166
|
TxnKeyword: tags.modifier,
|
|
22
167
|
|
|
23
|
-
// Tags and Links
|
|
24
168
|
Tag: tags.tagName,
|
|
25
169
|
Link: tags.link,
|
|
26
170
|
|
|
27
|
-
|
|
28
|
-
"open close balance pad note document event price commodity query custom": tags.keyword,
|
|
29
|
-
"option include plugin pushtag poptag": tags.keyword,
|
|
171
|
+
Keyword: tags.keyword,
|
|
30
172
|
|
|
31
|
-
// Metadata
|
|
32
173
|
MetadataKey: tags.propertyName,
|
|
33
|
-
identifier: tags.name,
|
|
34
174
|
|
|
35
|
-
// Operators
|
|
36
175
|
ArithOp: tags.arithmeticOperator,
|
|
37
|
-
PriceOp: tags.operator,
|
|
38
176
|
"~": tags.operator,
|
|
39
177
|
|
|
40
|
-
|
|
41
|
-
LotLabel: tags.special(tags.operator),
|
|
178
|
+
CostTotal: tags.special(tags.operator),
|
|
42
179
|
CostMerge: tags.special(tags.operator),
|
|
43
180
|
|
|
44
|
-
// Delimiters
|
|
45
181
|
"{ } {{ }}": tags.brace,
|
|
46
182
|
"( )": tags.paren,
|
|
47
183
|
",": tags.separator,
|
|
48
184
|
":": tags.punctuation,
|
|
49
185
|
"@ @@": tags.operator,
|
|
50
186
|
|
|
51
|
-
OrgHeader: tags.heading,
|
|
52
187
|
OrgMarker: tags.heading,
|
|
53
188
|
});
|
|
54
189
|
|
|
190
|
+
// Fold from the end of the header line, so comment lines above the first
|
|
191
|
+
// posting or metadata line fold too, to the end of the last line, before
|
|
192
|
+
// the line break the directive ends with.
|
|
55
193
|
const beancountFolding = foldNodeProp.add({
|
|
56
|
-
|
|
57
|
-
|
|
194
|
+
DatedDirective: (node, state) => {
|
|
195
|
+
let from = state.doc.lineAt(node.from).to;
|
|
196
|
+
let to = state.doc.lineAt(node.to).from == node.to ? node.to - 1 : node.to;
|
|
197
|
+
return from < to ? { from, to } : null;
|
|
198
|
+
},
|
|
58
199
|
});
|
|
59
200
|
|
|
60
201
|
const beancountIndentation = indentNodeProp.add({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Note: context => context.baseIndent + context.unit,
|
|
69
|
-
Document: context => context.baseIndent + context.unit,
|
|
70
|
-
Event: context => context.baseIndent + context.unit,
|
|
71
|
-
Price: context => context.baseIndent + context.unit,
|
|
72
|
-
Commodity: context => context.baseIndent + context.unit,
|
|
73
|
-
Query: context => context.baseIndent + context.unit,
|
|
74
|
-
Custom: context => context.baseIndent + context.unit,
|
|
202
|
+
DatedDirective: context => context.baseIndent + context.unit,
|
|
203
|
+
// A new, still empty line ends a dated directive the way a blank line
|
|
204
|
+
// does, but right after one it is where its body goes on.
|
|
205
|
+
File: context => {
|
|
206
|
+
let before = context.node.childBefore(context.pos);
|
|
207
|
+
return before && before.name == "DatedDirective" && before.to == context.pos ? context.unit : 0;
|
|
208
|
+
},
|
|
75
209
|
});
|
|
76
210
|
|
|
77
211
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
78
|
-
const spec_identifier = {__proto__:null,open:
|
|
212
|
+
const spec_identifier = {__proto__:null,txn:205, open:87, close:95, balance:99, pad:105, note:109, document:113, event:117, price:121, commodity:125, query:129, custom:133, option:139, include:143, plugin:147, pushtag:151, poptag:155, pushmeta:159, popmeta:163};
|
|
79
213
|
const parser = LRParser.deserialize({
|
|
80
214
|
version: 14,
|
|
81
|
-
states: "
|
|
82
|
-
stateData: "
|
|
83
|
-
goto: "
|
|
84
|
-
nodeNames: "⚠ LineComment File DatedDirective
|
|
85
|
-
maxTerm:
|
|
215
|
+
states: "=vQ]Q_OOO}QXO'#CcOOQP'#Dq'#DqOOQP'#EQ'#EQOOQV'#Ec'#EcO!xQXO'#EcOOQV'#ER'#ERQ]Q_OOO#QQXO'#DrO#VQXO'#DtO#[QXO'#DvO#aQXO'#DxO#fQXO'#DzO#kQXO'#D|O#kQXO'#EOOOQP'#Ce'#CeOOQP'#Ed'#EdO#pQXO'#CdOOQV,58},58}O$RQXO'#DWO$WQXO'#D[O$]QXO'#D^O$bQXO'#DaO$gQXO'#DcO$lQXO'#DeO$qQXO'#DgO$vQaO'#DiO${QaO'#DkO%QQXO'#DmO%VQXO'#DoOOQV'#Eh'#EhOOQV,5:},5:}OOQV-E8P-E8PO%[QXO,5:^OOQP,5:`,5:`O%aQXO,5:bOOQP,5:d,5:dOOQP,5:f,5:fOOQP'#Cl'#ClO%lQXO,5:hO%qQXO,5:jO%vQXO'#EgOOQP'#ES'#ESO#sQXO,59OO&XQ_O,59OO#sQXO,59OO'PQaO,59rO!xQXO,59vO'_QZO,59xO'mQXO,59{O'rQXO,59}O'wQXO,5:PO'|QXO,5:RO'_QZO,5:TO!xQXO,5:VO(RQXO,5:XO(WQcO,5:ZOOQP1G/x1G/xOOQP1G/|1G/|O)mQcO1G0SOOQP1G0U1G0UOOQP,5;R,5;ROOQP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Q#m!nQ$P!}Q$T#TQ$k#kQ$p#vQ$q#wQ$s#yQ$u#{Q$v#|Q$w$OQ$x$QQ$y$SQ%]$lQ%_$rR%`$ts#h!k!n!}#T#i#k#v#w#y#{#|$O$Q$S$l$r$tTTOVTQOVQVORpVQ{aY!`{!i#Y#x#zQ!i}S#Y!b$dQ#x!xR#z!yU!f|!a#cR#^!fQ%f%RR%p%fQ%i%UR%r%iQ#b!gQ$e#_T$f#b$eQ#e!jR$i#ep#i!k!n!}#T#k#v#w#y#{#|$O$Q$S$l$r$tR$j#iQ#S!YR$R#STUOVRaPR}aQoTQ|aS!a{}Q!k!OQ!n!PQ!}!WQ#T!YQ#c!iS#k!l!mQ#v!vQ#w!wQ#y!xQ#{!yQ#|!zQ$O!|Q$Q#OQ$S#SQ$U#YQ$a#[Q$l#lQ$r#xQ$t#zQ$z$VS%Z$b$cQ%a${R%k%[X!e|!a!f#c`!c|!a!f!g#_#b#c$es#g!k!n!}#T#i#k#v#w#y#{#|$O$Q$S$l$r$tQ#W!]R${$VQ!t!QQ!{!VS#P!Y#SS#U!]$VQ#o!sQ#u!uY$W#[$Z$]$c%hQ$m#rQ$n#qQ$o#tS$|$Y%eQ%c%QQ%l%tR%m%bQ$b#[R%[$cS$^#[$cW%O$Y$Z%e%hR%W$]R%T$YQ%R$YQ%U$ZQ%o%eR%q%hQ%R$YR%o%eR%V$ZR!m!OR!v!QT#R!Y#S",
|
|
218
|
+
nodeNames: "⚠ Indent Date Date OrgMarker LineComment File DatedDirective Transaction TxnKeyword TxnFlag String Tag Link PostingBlock TransactionMetadata MetadataKey : Number ( ) ArithOp ArithOp Amount Currency Account BooleanValue NullValue TransactionTags Posting CostSpec { CostMerge CostTotal , } {{ }} PriceAnnotation PriceOp @ @@ Open open MetadataBlock DirectiveMetadata Close close Balance balance ~ Pad pad Note note Document document Event event Price price Commodity commodity Query query Custom custom UndatedDirective Option option Include include Plugin plugin Pushtag pushtag Poptag poptag Pushmeta pushmeta Popmeta popmeta OrgHeader",
|
|
219
|
+
maxTerm: 122,
|
|
86
220
|
nodeProps: [
|
|
87
|
-
["isolate", -
|
|
221
|
+
["isolate", -2,5,11,""],
|
|
222
|
+
["group", -18,43,47,49,52,54,56,58,60,62,64,66,69,71,73,75,77,79,81,"Keyword"]
|
|
88
223
|
],
|
|
89
224
|
propSources: [beancountHighlighting,beancountFolding,beancountIndentation],
|
|
90
|
-
skippedNodes: [0,
|
|
91
|
-
repeatNodeCount:
|
|
92
|
-
tokenData: "
|
|
93
|
-
tokenizers: [0, 1, 2
|
|
94
|
-
topRules: {"File":[0,
|
|
95
|
-
specialized: [{term:
|
|
96
|
-
tokenPrec:
|
|
225
|
+
skippedNodes: [0,5],
|
|
226
|
+
repeatNodeCount: 9,
|
|
227
|
+
tokenData: ":u~RrXY#]]^#]pq#]qr#krs#pst$tuv#kvw#kxy%|yz&Rz{&W{|&_|}&d}!O&i!P!Q&nW!c!h)e!h!i-u!i!p)e!p!q2f!q!v)e!v!w6[!w!})e#Q#R8Y#T#o9^#o#p:U#q#r:c#r#s:p#t;'S-S;'S;=`-o<%lO-S~#bR#U~XY#]]^#]pq#]P#pOYP~#sVOr#prs$Ys#O#p#O#P$_#P;'S#p;'S;=`$n<%lO#p~$_OZ~~$bSOY#pZ;'S#p;'S;=`$n<%lO#p~$qP;=`<%l#pV${V#jSYP}!O%b!O!P%b!P!Q%b!Q![%b!c!}%b#R#S%b#T#o%bR%gV[R}!O%b!O!P%b!P!Q%b!Q![%b!c!}%b#R#S%b#T#o%b~&ROc~~&WOd~V&_O#cUYP~&dO#b~~&iOr~~&nO#a~~&sU#d~wx'V}!O'V!O!P'V!Q!['V!c!}'l#R#S'VU'YUwx'V}!O'V!O!P'V!Q!['V!c!}'l#R#S'VU'qUhUwx(T}!O(T!O!P(T!Q!['l!c!}'l#R#S(TU(WUwx(T}!O(T!O!P(T!Q!['l!c!}'l#R#S(T~(oOa~~(tST~OY(oZ;'S(o;'S;=`)Q<%lO(o~)TP;=`<%l(o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T#o-S#t;'S-S;'S;=`-o<%lO-S~5iZkQhUwx(T}!O*_!O!P(T!Q![+T![!]+{!c!}+T#R#S(T#T#o-S#t;'S-S;'S;=`-o<%lO-S~6c]YPhUwx(T}!O*_!O!P(T!Q![+T![!]+{!c!t+T!t!u7[!u!}+T#R#S(T#T#o-S#t;'S-S;'S;=`-o<%lO-S~7a]hUwx(T}!O*_!O!P(T!Q![+T![!]+{!c!w+T!w!x0n!x!}+T#R#S(T#T#o-S#t;'S-S;'S;=`-o<%lO-S~8]V}!O8r!O!P8r!P!Q8r!Q![8r!c!}8r#R#S8r#T#o8r~8wV]~}!O8r!O!P8r!P!Q8r!Q![8r!c!}8r#R#S8r#T#o8r~9aT}!O9p!Q![9p!c!}9p#R#S9p#T#o9p~9uT#X~}!O9p!Q![9p!c!}9p#R#S9p#T#o9p~:ZPo~#o#p:^~:cOt~~:hPs~#q#r:k~:pOu~~:uO!S~",
|
|
228
|
+
tokenizers: [lineBreak, numbers, orgLine, 0, 1, 2],
|
|
229
|
+
topRules: {"File":[0,6]},
|
|
230
|
+
specialized: [{term: 101, get: (value) => spec_identifier[value] || -1}],
|
|
231
|
+
tokenPrec: 1875
|
|
97
232
|
});
|
|
98
233
|
|
|
99
234
|
export { parser };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lezer-beancount",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "lezer-based Beancount grammar",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Robin van der Vleuten <robin@webstronauts.com>",
|
|
@@ -15,15 +15,18 @@
|
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
19
|
-
"
|
|
18
|
+
"build": "rollup -c",
|
|
19
|
+
"prepare": "npm run build",
|
|
20
|
+
"pretest": "npm run build",
|
|
21
|
+
"test": "uvu test",
|
|
22
|
+
"sync-corpus": "cd scripts/corpus && go run . ../../test/corpus"
|
|
20
23
|
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@codemirror/language": "^6.10.0",
|
|
26
|
+
"@codemirror/state": "^6.5.2",
|
|
23
27
|
"@lezer/generator": "^1.8.0",
|
|
24
28
|
"@lezer/highlight": "^1.2.0",
|
|
25
29
|
"@lezer/lr": "^1.4.0",
|
|
26
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
27
30
|
"rollup": "^4.53.3",
|
|
28
31
|
"uvu": "^0.5.6"
|
|
29
32
|
},
|