tree-sitter-beancount 2.4.2 → 2.5.0
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/grammar.js +44 -22
- package/package.json +3 -3
- package/prebuilds/darwin-arm64/tree-sitter-beancount.node +0 -0
- package/prebuilds/darwin-x64/tree-sitter-beancount.node +0 -0
- package/prebuilds/linux-arm64/tree-sitter-beancount.node +0 -0
- package/prebuilds/linux-x64/tree-sitter-beancount.node +0 -0
- package/prebuilds/win32-arm64/tree-sitter-beancount.node +0 -0
- package/prebuilds/win32-x64/tree-sitter-beancount.node +0 -0
- package/src/grammar.json +177 -50
- package/src/node-types.json +24 -1
- package/src/parser.c +8764 -7281
- package/src/scanner.c +32 -8
package/grammar.js
CHANGED
|
@@ -9,6 +9,7 @@ module.exports = grammar({
|
|
|
9
9
|
word: ($) => $.identifier,
|
|
10
10
|
|
|
11
11
|
inline: ($) => [
|
|
12
|
+
$.currency_key_value,
|
|
12
13
|
],
|
|
13
14
|
|
|
14
15
|
conflicts: ($) => [
|
|
@@ -82,11 +83,13 @@ module.exports = grammar({
|
|
|
82
83
|
date: $ => token(/([12]\d{3}[-\/](0[1-9]|1[0-2])[-\/](0[1-9]|[12]\d|3[01]))/),
|
|
83
84
|
// Account names: Assets|Liabilities|Equity|Income|Expenses followed by colon-separated components
|
|
84
85
|
// Components can contain Unicode letters/numbers including CJK characters
|
|
86
|
+
// account: $ => $.identifier, // token(/[^\s\\ \n\r]/),
|
|
87
|
+
|
|
85
88
|
account: $ =>
|
|
86
89
|
token(
|
|
87
90
|
seq(
|
|
88
|
-
/
|
|
89
|
-
|
|
91
|
+
/[A-Z][\p{L}\p{N}\u3040-\u309f\u30a0-\u30ff\u4e00-\u9fff\uac00-\ud7a3]*/,
|
|
92
|
+
repeat(
|
|
90
93
|
seq(
|
|
91
94
|
":",
|
|
92
95
|
/[\p{Lu}\p{N}\u3040-\u309f\u30a0-\u30ff\u4e00-\u9fff\uac00-\ud7a3][\p{L}\p{N}\u3040-\u309f\u30a0-\u30ff\u4e00-\u9fff\uac00-\ud7a3\-]*/,
|
|
@@ -96,6 +99,7 @@ module.exports = grammar({
|
|
|
96
99
|
),
|
|
97
100
|
currency: $ => token(/[A-Z]([A-Z0-9\'\._\-]{0,22}[A-Z0-9])?/),
|
|
98
101
|
string: $ => token(/"([^"]|\\")*"/),
|
|
102
|
+
unquoted_string: $ => token(prec(-1, /[^\r\n]+/)),
|
|
99
103
|
number: $ => token(/([0-9]+|[0-9][0-9,]+[0-9])(\.[0-9]*)?/),
|
|
100
104
|
tag: $ => token(/#[A-Za-z0-9\-_/.]+/),
|
|
101
105
|
link: $ => token(/\^[A-Za-z0-9\-_/.]+/),
|
|
@@ -219,17 +223,11 @@ module.exports = grammar({
|
|
|
219
223
|
$.flag,
|
|
220
224
|
),
|
|
221
225
|
|
|
222
|
-
price_annotation: $ =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// ),
|
|
228
|
-
// seq(
|
|
229
|
-
// $.at,
|
|
230
|
-
// $.incomplete_amount
|
|
231
|
-
// )
|
|
232
|
-
//),
|
|
226
|
+
price_annotation: $ =>
|
|
227
|
+
choice(
|
|
228
|
+
$.incomplete_amount,
|
|
229
|
+
$.currency
|
|
230
|
+
),
|
|
233
231
|
|
|
234
232
|
posting: $ =>
|
|
235
233
|
seq(
|
|
@@ -250,25 +248,49 @@ module.exports = grammar({
|
|
|
250
248
|
|
|
251
249
|
key: $ => token(/[a-z][a-zA-Z0-9\-_]+/),
|
|
252
250
|
|
|
251
|
+
currency_key_value: $ =>
|
|
252
|
+
prec.left(seq(
|
|
253
|
+
alias("currency", $.key),
|
|
254
|
+
":",
|
|
255
|
+
optional(
|
|
256
|
+
seq(
|
|
257
|
+
repeat(/ /),
|
|
258
|
+
field("value", alias($.value_currency, $.value)),
|
|
259
|
+
)
|
|
260
|
+
),
|
|
261
|
+
)),
|
|
262
|
+
|
|
253
263
|
value: $ =>
|
|
254
|
-
choice(
|
|
264
|
+
prec.left(choice(
|
|
255
265
|
$.string,
|
|
256
|
-
$.account,
|
|
257
266
|
$.date,
|
|
258
267
|
$.currency,
|
|
268
|
+
$.account,
|
|
259
269
|
$.tag,
|
|
260
270
|
$.bool,
|
|
261
271
|
$._none,
|
|
262
272
|
$._number_expr,
|
|
263
|
-
$.amount
|
|
264
|
-
|
|
273
|
+
$.amount,
|
|
274
|
+
$.string,
|
|
275
|
+
$.unquoted_string,
|
|
276
|
+
)),
|
|
277
|
+
|
|
278
|
+
value_currency: $ => seq($.currency),
|
|
265
279
|
|
|
266
280
|
key_value: $ =>
|
|
267
|
-
|
|
268
|
-
$.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
281
|
+
choice(
|
|
282
|
+
$.currency_key_value,
|
|
283
|
+
prec.left(seq(
|
|
284
|
+
$.key,
|
|
285
|
+
":",
|
|
286
|
+
optional(
|
|
287
|
+
seq(
|
|
288
|
+
repeat(/ /),
|
|
289
|
+
$.value,
|
|
290
|
+
),
|
|
291
|
+
),
|
|
292
|
+
)),
|
|
293
|
+
),
|
|
272
294
|
|
|
273
295
|
_key_value_line: $ => seq(
|
|
274
296
|
$._indent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-beancount",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "a tree-sitter parser for the beancount syntax",
|
|
5
5
|
"main": "bindings/node",
|
|
6
6
|
"types": "bindings/node",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"node-addon-api": "^8.5.0",
|
|
37
37
|
"node-gyp-build": "^4.8.0",
|
|
38
|
-
"tar-fs": "^
|
|
38
|
+
"tar-fs": "^3.1.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"tree-sitter": "^0.25.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"prebuildify": "^6.0.0",
|
|
50
|
-
"tree-sitter-cli": "^0.
|
|
50
|
+
"tree-sitter-cli": "^0.26.3"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22.0.0"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -228,10 +228,10 @@
|
|
|
228
228
|
"members": [
|
|
229
229
|
{
|
|
230
230
|
"type": "PATTERN",
|
|
231
|
-
"value": "
|
|
231
|
+
"value": "[A-Z][\\p{L}\\p{N}\\u3040-\\u309f\\u30a0-\\u30ff\\u4e00-\\u9fff\\uac00-\\ud7a3]*"
|
|
232
232
|
},
|
|
233
233
|
{
|
|
234
|
-
"type": "
|
|
234
|
+
"type": "REPEAT",
|
|
235
235
|
"content": {
|
|
236
236
|
"type": "SEQ",
|
|
237
237
|
"members": [
|
|
@@ -263,6 +263,17 @@
|
|
|
263
263
|
"value": "\"([^\"]|\\\\\")*\""
|
|
264
264
|
}
|
|
265
265
|
},
|
|
266
|
+
"unquoted_string": {
|
|
267
|
+
"type": "TOKEN",
|
|
268
|
+
"content": {
|
|
269
|
+
"type": "PREC",
|
|
270
|
+
"value": -1,
|
|
271
|
+
"content": {
|
|
272
|
+
"type": "PATTERN",
|
|
273
|
+
"value": "[^\\r\\n]+"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
},
|
|
266
277
|
"number": {
|
|
267
278
|
"type": "TOKEN",
|
|
268
279
|
"content": {
|
|
@@ -698,8 +709,17 @@
|
|
|
698
709
|
]
|
|
699
710
|
},
|
|
700
711
|
"price_annotation": {
|
|
701
|
-
"type": "
|
|
702
|
-
"
|
|
712
|
+
"type": "CHOICE",
|
|
713
|
+
"members": [
|
|
714
|
+
{
|
|
715
|
+
"type": "SYMBOL",
|
|
716
|
+
"name": "incomplete_amount"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"type": "SYMBOL",
|
|
720
|
+
"name": "currency"
|
|
721
|
+
}
|
|
722
|
+
]
|
|
703
723
|
},
|
|
704
724
|
"posting": {
|
|
705
725
|
"type": "SEQ",
|
|
@@ -835,68 +855,173 @@
|
|
|
835
855
|
"value": "[a-z][a-zA-Z0-9\\-_]+"
|
|
836
856
|
}
|
|
837
857
|
},
|
|
838
|
-
"
|
|
839
|
-
"type": "CHOICE",
|
|
840
|
-
"members": [
|
|
841
|
-
{
|
|
842
|
-
"type": "SYMBOL",
|
|
843
|
-
"name": "string"
|
|
844
|
-
},
|
|
845
|
-
{
|
|
846
|
-
"type": "SYMBOL",
|
|
847
|
-
"name": "account"
|
|
848
|
-
},
|
|
849
|
-
{
|
|
850
|
-
"type": "SYMBOL",
|
|
851
|
-
"name": "date"
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
"type": "SYMBOL",
|
|
855
|
-
"name": "currency"
|
|
856
|
-
},
|
|
857
|
-
{
|
|
858
|
-
"type": "SYMBOL",
|
|
859
|
-
"name": "tag"
|
|
860
|
-
},
|
|
861
|
-
{
|
|
862
|
-
"type": "SYMBOL",
|
|
863
|
-
"name": "bool"
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
"type": "SYMBOL",
|
|
867
|
-
"name": "_none"
|
|
868
|
-
},
|
|
869
|
-
{
|
|
870
|
-
"type": "SYMBOL",
|
|
871
|
-
"name": "_number_expr"
|
|
872
|
-
},
|
|
873
|
-
{
|
|
874
|
-
"type": "SYMBOL",
|
|
875
|
-
"name": "amount"
|
|
876
|
-
}
|
|
877
|
-
]
|
|
878
|
-
},
|
|
879
|
-
"key_value": {
|
|
858
|
+
"currency_key_value": {
|
|
880
859
|
"type": "PREC_LEFT",
|
|
881
860
|
"value": 0,
|
|
882
861
|
"content": {
|
|
883
862
|
"type": "SEQ",
|
|
884
863
|
"members": [
|
|
885
864
|
{
|
|
886
|
-
"type": "
|
|
887
|
-
"
|
|
865
|
+
"type": "ALIAS",
|
|
866
|
+
"content": {
|
|
867
|
+
"type": "STRING",
|
|
868
|
+
"value": "currency"
|
|
869
|
+
},
|
|
870
|
+
"named": true,
|
|
871
|
+
"value": "key"
|
|
888
872
|
},
|
|
889
873
|
{
|
|
890
874
|
"type": "STRING",
|
|
891
875
|
"value": ":"
|
|
892
876
|
},
|
|
877
|
+
{
|
|
878
|
+
"type": "CHOICE",
|
|
879
|
+
"members": [
|
|
880
|
+
{
|
|
881
|
+
"type": "SEQ",
|
|
882
|
+
"members": [
|
|
883
|
+
{
|
|
884
|
+
"type": "REPEAT",
|
|
885
|
+
"content": {
|
|
886
|
+
"type": "PATTERN",
|
|
887
|
+
"value": " "
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
"type": "FIELD",
|
|
892
|
+
"name": "value",
|
|
893
|
+
"content": {
|
|
894
|
+
"type": "ALIAS",
|
|
895
|
+
"content": {
|
|
896
|
+
"type": "SYMBOL",
|
|
897
|
+
"name": "value_currency"
|
|
898
|
+
},
|
|
899
|
+
"named": true,
|
|
900
|
+
"value": "value"
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
]
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"type": "BLANK"
|
|
907
|
+
}
|
|
908
|
+
]
|
|
909
|
+
}
|
|
910
|
+
]
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
"value": {
|
|
914
|
+
"type": "PREC_LEFT",
|
|
915
|
+
"value": 0,
|
|
916
|
+
"content": {
|
|
917
|
+
"type": "CHOICE",
|
|
918
|
+
"members": [
|
|
919
|
+
{
|
|
920
|
+
"type": "SYMBOL",
|
|
921
|
+
"name": "string"
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
"type": "SYMBOL",
|
|
925
|
+
"name": "date"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
"type": "SYMBOL",
|
|
929
|
+
"name": "currency"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"type": "SYMBOL",
|
|
933
|
+
"name": "account"
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
"type": "SYMBOL",
|
|
937
|
+
"name": "tag"
|
|
938
|
+
},
|
|
893
939
|
{
|
|
894
940
|
"type": "SYMBOL",
|
|
895
|
-
"name": "
|
|
941
|
+
"name": "bool"
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
"type": "SYMBOL",
|
|
945
|
+
"name": "_none"
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
"type": "SYMBOL",
|
|
949
|
+
"name": "_number_expr"
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
"type": "SYMBOL",
|
|
953
|
+
"name": "amount"
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"type": "SYMBOL",
|
|
957
|
+
"name": "string"
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
"type": "SYMBOL",
|
|
961
|
+
"name": "unquoted_string"
|
|
896
962
|
}
|
|
897
963
|
]
|
|
898
964
|
}
|
|
899
965
|
},
|
|
966
|
+
"value_currency": {
|
|
967
|
+
"type": "SEQ",
|
|
968
|
+
"members": [
|
|
969
|
+
{
|
|
970
|
+
"type": "SYMBOL",
|
|
971
|
+
"name": "currency"
|
|
972
|
+
}
|
|
973
|
+
]
|
|
974
|
+
},
|
|
975
|
+
"key_value": {
|
|
976
|
+
"type": "CHOICE",
|
|
977
|
+
"members": [
|
|
978
|
+
{
|
|
979
|
+
"type": "SYMBOL",
|
|
980
|
+
"name": "currency_key_value"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
"type": "PREC_LEFT",
|
|
984
|
+
"value": 0,
|
|
985
|
+
"content": {
|
|
986
|
+
"type": "SEQ",
|
|
987
|
+
"members": [
|
|
988
|
+
{
|
|
989
|
+
"type": "SYMBOL",
|
|
990
|
+
"name": "key"
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
"type": "STRING",
|
|
994
|
+
"value": ":"
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
"type": "CHOICE",
|
|
998
|
+
"members": [
|
|
999
|
+
{
|
|
1000
|
+
"type": "SEQ",
|
|
1001
|
+
"members": [
|
|
1002
|
+
{
|
|
1003
|
+
"type": "REPEAT",
|
|
1004
|
+
"content": {
|
|
1005
|
+
"type": "PATTERN",
|
|
1006
|
+
"value": " "
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"type": "SYMBOL",
|
|
1011
|
+
"name": "value"
|
|
1012
|
+
}
|
|
1013
|
+
]
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
"type": "BLANK"
|
|
1017
|
+
}
|
|
1018
|
+
]
|
|
1019
|
+
}
|
|
1020
|
+
]
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
]
|
|
1024
|
+
},
|
|
900
1025
|
"_key_value_line": {
|
|
901
1026
|
"type": "SEQ",
|
|
902
1027
|
"members": [
|
|
@@ -2417,7 +2542,9 @@
|
|
|
2417
2542
|
"name": "_eof"
|
|
2418
2543
|
}
|
|
2419
2544
|
],
|
|
2420
|
-
"inline": [
|
|
2545
|
+
"inline": [
|
|
2546
|
+
"currency_key_value"
|
|
2547
|
+
],
|
|
2421
2548
|
"supertypes": [
|
|
2422
2549
|
"_entry",
|
|
2423
2550
|
"_directive"
|
package/src/node-types.json
CHANGED
|
@@ -773,7 +773,18 @@
|
|
|
773
773
|
{
|
|
774
774
|
"type": "key_value",
|
|
775
775
|
"named": true,
|
|
776
|
-
"fields": {
|
|
776
|
+
"fields": {
|
|
777
|
+
"value": {
|
|
778
|
+
"multiple": false,
|
|
779
|
+
"required": false,
|
|
780
|
+
"types": [
|
|
781
|
+
{
|
|
782
|
+
"type": "value",
|
|
783
|
+
"named": true
|
|
784
|
+
}
|
|
785
|
+
]
|
|
786
|
+
}
|
|
787
|
+
},
|
|
777
788
|
"children": {
|
|
778
789
|
"multiple": true,
|
|
779
790
|
"required": true,
|
|
@@ -1216,6 +1227,10 @@
|
|
|
1216
1227
|
"multiple": false,
|
|
1217
1228
|
"required": true,
|
|
1218
1229
|
"types": [
|
|
1230
|
+
{
|
|
1231
|
+
"type": "currency",
|
|
1232
|
+
"named": true
|
|
1233
|
+
},
|
|
1219
1234
|
{
|
|
1220
1235
|
"type": "incomplete_amount",
|
|
1221
1236
|
"named": true
|
|
@@ -1553,6 +1568,10 @@
|
|
|
1553
1568
|
{
|
|
1554
1569
|
"type": "unary_number_expr",
|
|
1555
1570
|
"named": true
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
"type": "unquoted_string",
|
|
1574
|
+
"named": true
|
|
1556
1575
|
}
|
|
1557
1576
|
]
|
|
1558
1577
|
}
|
|
@@ -1745,6 +1764,10 @@
|
|
|
1745
1764
|
"type": "txn",
|
|
1746
1765
|
"named": false
|
|
1747
1766
|
},
|
|
1767
|
+
{
|
|
1768
|
+
"type": "unquoted_string",
|
|
1769
|
+
"named": true
|
|
1770
|
+
},
|
|
1748
1771
|
{
|
|
1749
1772
|
"type": "{",
|
|
1750
1773
|
"named": false
|