tree-sitter-beancount 2.3.3 → 2.4.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.
Files changed (51) hide show
  1. package/README.md +334 -4
  2. package/binding.gyp +17 -7
  3. package/bindings/node/binding.cc +14 -22
  4. package/bindings/node/index.d.ts +28 -0
  5. package/bindings/node/index.js +3 -15
  6. package/grammar.js +38 -125
  7. package/package.json +35 -5
  8. package/prebuilds/darwin-arm64/tree-sitter-beancount.node +0 -0
  9. package/prebuilds/darwin-x64/tree-sitter-beancount.node +0 -0
  10. package/prebuilds/linux-arm64/tree-sitter-beancount.node +0 -0
  11. package/prebuilds/linux-x64/tree-sitter-beancount.node +0 -0
  12. package/prebuilds/win32-arm64/tree-sitter-beancount.node +0 -0
  13. package/prebuilds/win32-x64/tree-sitter-beancount.node +0 -0
  14. package/src/grammar.json +149 -560
  15. package/src/node-types.json +10 -11
  16. package/src/parser.c +7615 -9089
  17. package/src/scanner.c +345 -67
  18. package/src/tree_sitter/alloc.h +54 -0
  19. package/src/tree_sitter/array.h +291 -0
  20. package/src/tree_sitter/parser.h +68 -12
  21. package/.clang-format +0 -20
  22. package/.envrc +0 -1
  23. package/.gitattributes +0 -6
  24. package/.github/dependabot.yml +0 -26
  25. package/.github/workflows/cicd.yml +0 -30
  26. package/.github/workflows/release.yml +0 -72
  27. package/CHANGELOG.md +0 -80
  28. package/Cargo.lock +0 -71
  29. package/Cargo.toml +0 -26
  30. package/Package.swift +0 -20
  31. package/bindings/rust/build.rs +0 -39
  32. package/bindings/rust/lib.rs +0 -52
  33. package/flake.lock +0 -141
  34. package/flake.nix +0 -120
  35. package/test/corpus/arithmetic.txt +0 -373
  36. package/test/corpus/comment.txt +0 -992
  37. package/test/corpus/currencies.txt +0 -66
  38. package/test/corpus/entry_types.txt +0 -389
  39. package/test/corpus/markdown_orgmode.txt +0 -60
  40. package/test/corpus/metadata.txt +0 -414
  41. package/test/corpus/multi_line.txt +0 -27
  42. package/test/corpus/orgmode_sections.txt +0 -53
  43. package/test/corpus/parse_lots.txt +0 -417
  44. package/test/corpus/parser_include.txt +0 -23
  45. package/test/corpus/parser_links.txt +0 -32
  46. package/test/corpus/parser_options.txt +0 -39
  47. package/test/corpus/parser_plugin.txt +0 -35
  48. package/test/corpus/push_pop_meta.txt +0 -34
  49. package/test/corpus/push_pop_tag.txt +0 -23
  50. package/test/corpus/transaction.txt +0 -224
  51. package/test/corpus/ugly_bugs.txt +0 -91
package/src/grammar.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
2
3
  "name": "beancount",
3
4
  "word": "identifier",
4
5
  "rules": {
@@ -44,7 +45,7 @@
44
45
  },
45
46
  "_any": {
46
47
  "type": "PATTERN",
47
- "value": ".*"
48
+ "value": "[^\\r\\n]*"
48
49
  },
49
50
  "section": {
50
51
  "type": "SEQ",
@@ -69,21 +70,18 @@
69
70
  {
70
71
  "type": "SYMBOL",
71
72
  "name": "_nl"
73
+ },
74
+ {
75
+ "type": "FIELD",
76
+ "name": "subsection",
77
+ "content": {
78
+ "type": "SYMBOL",
79
+ "name": "section"
80
+ }
72
81
  }
73
82
  ]
74
83
  }
75
84
  },
76
- {
77
- "type": "REPEAT",
78
- "content": {
79
- "type": "FIELD",
80
- "name": "subsection",
81
- "content": {
82
- "type": "SYMBOL",
83
- "name": "section"
84
- }
85
- }
86
- },
87
85
  {
88
86
  "type": "SYMBOL",
89
87
  "name": "_sectionend"
@@ -99,7 +97,7 @@
99
97
  },
100
98
  {
101
99
  "type": "PATTERN",
102
- "value": "\\*+"
100
+ "value": "(\\*|#)+"
103
101
  }
104
102
  ]
105
103
  },
@@ -111,8 +109,11 @@
111
109
  "name": "_org_stars"
112
110
  },
113
111
  {
114
- "type": "PATTERN",
115
- "value": "[ \\t]+"
112
+ "type": "TOKEN",
113
+ "content": {
114
+ "type": "PATTERN",
115
+ "value": "[ \\t]+"
116
+ }
116
117
  },
117
118
  {
118
119
  "type": "CHOICE",
@@ -137,8 +138,11 @@
137
138
  ]
138
139
  },
139
140
  "item": {
140
- "type": "SYMBOL",
141
- "name": "_any"
141
+ "type": "TOKEN",
142
+ "content": {
143
+ "type": "PATTERN",
144
+ "value": "[^\\r\\n]+"
145
+ }
142
146
  },
143
147
  "_indent": {
144
148
  "type": "TOKEN",
@@ -214,7 +218,7 @@
214
218
  "type": "TOKEN",
215
219
  "content": {
216
220
  "type": "PATTERN",
217
- "value": "([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))"
221
+ "value": "([12]\\d{3}[-\\/](0[1-9]|1[0-2])[-\\/](0[1-9]|[12]\\d|3[01]))"
218
222
  }
219
223
  },
220
224
  "account": {
@@ -237,7 +241,7 @@
237
241
  },
238
242
  {
239
243
  "type": "PATTERN",
240
- "value": "[\\p{Lu}\\p{N}][\\p{L}\\p{N}\\-]*"
244
+ "value": "[\\p{Lu}\\p{N}\\u3040-\\u309f\\u30a0-\\u30ff\\u4e00-\\u9fff\\uac00-\\ud7a3][\\p{L}\\p{N}\\u3040-\\u309f\\u30a0-\\u30ff\\u4e00-\\u9fff\\uac00-\\ud7a3\\-]*"
241
245
  }
242
246
  ]
243
247
  }
@@ -249,7 +253,7 @@
249
253
  "type": "TOKEN",
250
254
  "content": {
251
255
  "type": "PATTERN",
252
- "value": "[A-Z][A-Z0-9\\'\\._\\-]{0,22}[A-Z0-9]"
256
+ "value": "[A-Z]([A-Z0-9\\'\\._\\-]{0,22}[A-Z0-9])?"
253
257
  }
254
258
  },
255
259
  "string": {
@@ -698,371 +702,129 @@
698
702
  "name": "incomplete_amount"
699
703
  },
700
704
  "posting": {
701
- "type": "CHOICE",
705
+ "type": "SEQ",
702
706
  "members": [
703
707
  {
704
- "type": "SEQ",
705
- "members": [
706
- {
707
- "type": "SYMBOL",
708
- "name": "_indent"
709
- },
710
- {
711
- "type": "FIELD",
712
- "name": "optflag",
713
- "content": {
714
- "type": "CHOICE",
715
- "members": [
716
- {
717
- "type": "SYMBOL",
718
- "name": "optflag"
719
- },
720
- {
721
- "type": "BLANK"
722
- }
723
- ]
724
- }
725
- },
726
- {
727
- "type": "FIELD",
728
- "name": "account",
729
- "content": {
730
- "type": "SYMBOL",
731
- "name": "account"
732
- }
733
- },
734
- {
735
- "type": "FIELD",
736
- "name": "amount",
737
- "content": {
738
- "type": "CHOICE",
739
- "members": [
740
- {
741
- "type": "SYMBOL",
742
- "name": "incomplete_amount"
743
- },
744
- {
745
- "type": "BLANK"
746
- }
747
- ]
748
- }
749
- },
750
- {
751
- "type": "FIELD",
752
- "name": "cost_spec",
753
- "content": {
754
- "type": "CHOICE",
755
- "members": [
756
- {
757
- "type": "SYMBOL",
758
- "name": "cost_spec"
759
- },
760
- {
761
- "type": "BLANK"
762
- }
763
- ]
764
- }
765
- },
766
- {
767
- "type": "FIELD",
768
- "name": "comment",
769
- "content": {
770
- "type": "CHOICE",
771
- "members": [
772
- {
773
- "type": "SYMBOL",
774
- "name": "comment"
775
- },
776
- {
777
- "type": "BLANK"
778
- }
779
- ]
780
- }
781
- },
782
- {
783
- "type": "SYMBOL",
784
- "name": "_eol"
785
- }
786
- ]
787
- },
788
- {
789
- "type": "SEQ",
790
- "members": [
791
- {
792
- "type": "SYMBOL",
793
- "name": "_indent"
794
- },
795
- {
796
- "type": "FIELD",
797
- "name": "optflag",
798
- "content": {
799
- "type": "CHOICE",
800
- "members": [
801
- {
802
- "type": "SYMBOL",
803
- "name": "optflag"
804
- },
805
- {
806
- "type": "BLANK"
807
- }
808
- ]
809
- }
810
- },
811
- {
812
- "type": "FIELD",
813
- "name": "account",
814
- "content": {
815
- "type": "SYMBOL",
816
- "name": "account"
817
- }
818
- },
819
- {
820
- "type": "FIELD",
821
- "name": "amount",
822
- "content": {
823
- "type": "CHOICE",
824
- "members": [
825
- {
826
- "type": "SYMBOL",
827
- "name": "incomplete_amount"
828
- },
829
- {
830
- "type": "BLANK"
831
- }
832
- ]
833
- }
834
- },
835
- {
836
- "type": "FIELD",
837
- "name": "cost_spec",
838
- "content": {
839
- "type": "CHOICE",
840
- "members": [
841
- {
842
- "type": "SYMBOL",
843
- "name": "cost_spec"
844
- },
845
- {
846
- "type": "BLANK"
847
- }
848
- ]
849
- }
850
- },
851
- {
852
- "type": "SYMBOL",
853
- "name": "at"
854
- },
855
- {
856
- "type": "FIELD",
857
- "name": "price_annotation",
858
- "content": {
859
- "type": "CHOICE",
860
- "members": [
861
- {
862
- "type": "SYMBOL",
863
- "name": "price_annotation"
864
- },
865
- {
866
- "type": "BLANK"
867
- }
868
- ]
869
- }
870
- },
871
- {
872
- "type": "FIELD",
873
- "name": "comment",
874
- "content": {
875
- "type": "CHOICE",
876
- "members": [
877
- {
878
- "type": "SYMBOL",
879
- "name": "comment"
880
- },
881
- {
882
- "type": "BLANK"
883
- }
884
- ]
885
- }
886
- },
887
- {
888
- "type": "SYMBOL",
889
- "name": "_eol"
890
- }
891
- ]
708
+ "type": "SYMBOL",
709
+ "name": "_indent"
892
710
  },
893
711
  {
894
- "type": "SEQ",
895
- "members": [
896
- {
897
- "type": "SYMBOL",
898
- "name": "_indent"
899
- },
900
- {
901
- "type": "FIELD",
902
- "name": "optflag",
903
- "content": {
904
- "type": "CHOICE",
905
- "members": [
906
- {
907
- "type": "SYMBOL",
908
- "name": "optflag"
909
- },
910
- {
911
- "type": "BLANK"
912
- }
913
- ]
914
- }
915
- },
916
- {
917
- "type": "FIELD",
918
- "name": "account",
919
- "content": {
712
+ "type": "FIELD",
713
+ "name": "optflag",
714
+ "content": {
715
+ "type": "CHOICE",
716
+ "members": [
717
+ {
920
718
  "type": "SYMBOL",
921
- "name": "account"
922
- }
923
- },
924
- {
925
- "type": "FIELD",
926
- "name": "amount",
927
- "content": {
928
- "type": "CHOICE",
929
- "members": [
930
- {
931
- "type": "SYMBOL",
932
- "name": "incomplete_amount"
933
- },
934
- {
935
- "type": "BLANK"
936
- }
937
- ]
938
- }
939
- },
940
- {
941
- "type": "FIELD",
942
- "name": "cost_spec",
943
- "content": {
944
- "type": "CHOICE",
945
- "members": [
946
- {
947
- "type": "SYMBOL",
948
- "name": "cost_spec"
949
- },
950
- {
951
- "type": "BLANK"
952
- }
953
- ]
954
- }
955
- },
956
- {
957
- "type": "SYMBOL",
958
- "name": "atat"
959
- },
960
- {
961
- "type": "FIELD",
962
- "name": "price_annotation",
963
- "content": {
964
- "type": "CHOICE",
965
- "members": [
966
- {
967
- "type": "SYMBOL",
968
- "name": "price_annotation"
969
- },
970
- {
971
- "type": "BLANK"
972
- }
973
- ]
974
- }
975
- },
976
- {
977
- "type": "FIELD",
978
- "name": "comment",
979
- "content": {
980
- "type": "CHOICE",
981
- "members": [
982
- {
983
- "type": "SYMBOL",
984
- "name": "comment"
985
- },
986
- {
987
- "type": "BLANK"
988
- }
989
- ]
719
+ "name": "optflag"
720
+ },
721
+ {
722
+ "type": "BLANK"
990
723
  }
991
- },
992
- {
993
- "type": "SYMBOL",
994
- "name": "_eol"
995
- }
996
- ]
724
+ ]
725
+ }
997
726
  },
998
727
  {
999
- "type": "SEQ",
1000
- "members": [
1001
- {
1002
- "type": "SYMBOL",
1003
- "name": "_indent"
1004
- },
1005
- {
1006
- "type": "FIELD",
1007
- "name": "optflag",
1008
- "content": {
1009
- "type": "CHOICE",
1010
- "members": [
1011
- {
1012
- "type": "SYMBOL",
1013
- "name": "optflag"
1014
- },
1015
- {
1016
- "type": "BLANK"
1017
- }
1018
- ]
1019
- }
1020
- },
1021
- {
1022
- "type": "FIELD",
1023
- "name": "account",
1024
- "content": {
728
+ "type": "FIELD",
729
+ "name": "account",
730
+ "content": {
731
+ "type": "SYMBOL",
732
+ "name": "account"
733
+ }
734
+ },
735
+ {
736
+ "type": "FIELD",
737
+ "name": "amount",
738
+ "content": {
739
+ "type": "CHOICE",
740
+ "members": [
741
+ {
1025
742
  "type": "SYMBOL",
1026
- "name": "account"
743
+ "name": "incomplete_amount"
744
+ },
745
+ {
746
+ "type": "BLANK"
1027
747
  }
1028
- },
1029
- {
1030
- "type": "FIELD",
1031
- "name": "amount",
1032
- "content": {
1033
- "type": "CHOICE",
1034
- "members": [
1035
- {
1036
- "type": "SYMBOL",
1037
- "name": "incomplete_amount"
1038
- },
1039
- {
1040
- "type": "BLANK"
1041
- }
1042
- ]
748
+ ]
749
+ }
750
+ },
751
+ {
752
+ "type": "FIELD",
753
+ "name": "cost_spec",
754
+ "content": {
755
+ "type": "CHOICE",
756
+ "members": [
757
+ {
758
+ "type": "SYMBOL",
759
+ "name": "cost_spec"
760
+ },
761
+ {
762
+ "type": "BLANK"
1043
763
  }
1044
- },
764
+ ]
765
+ }
766
+ },
767
+ {
768
+ "type": "CHOICE",
769
+ "members": [
1045
770
  {
1046
- "type": "FIELD",
1047
- "name": "comment",
1048
- "content": {
1049
- "type": "CHOICE",
1050
- "members": [
1051
- {
1052
- "type": "SYMBOL",
1053
- "name": "comment"
1054
- },
1055
- {
1056
- "type": "BLANK"
771
+ "type": "SEQ",
772
+ "members": [
773
+ {
774
+ "type": "CHOICE",
775
+ "members": [
776
+ {
777
+ "type": "SYMBOL",
778
+ "name": "at"
779
+ },
780
+ {
781
+ "type": "SYMBOL",
782
+ "name": "atat"
783
+ }
784
+ ]
785
+ },
786
+ {
787
+ "type": "FIELD",
788
+ "name": "price_annotation",
789
+ "content": {
790
+ "type": "CHOICE",
791
+ "members": [
792
+ {
793
+ "type": "SYMBOL",
794
+ "name": "price_annotation"
795
+ },
796
+ {
797
+ "type": "BLANK"
798
+ }
799
+ ]
1057
800
  }
1058
- ]
1059
- }
801
+ }
802
+ ]
1060
803
  },
1061
804
  {
1062
- "type": "SYMBOL",
1063
- "name": "_eol"
805
+ "type": "BLANK"
1064
806
  }
1065
807
  ]
808
+ },
809
+ {
810
+ "type": "FIELD",
811
+ "name": "comment",
812
+ "content": {
813
+ "type": "CHOICE",
814
+ "members": [
815
+ {
816
+ "type": "SYMBOL",
817
+ "name": "comment"
818
+ },
819
+ {
820
+ "type": "BLANK"
821
+ }
822
+ ]
823
+ }
824
+ },
825
+ {
826
+ "type": "SYMBOL",
827
+ "name": "_eol"
1066
828
  }
1067
829
  ]
1068
830
  },
@@ -2557,17 +2319,20 @@
2557
2319
  ]
2558
2320
  },
2559
2321
  "comment": {
2560
- "type": "SEQ",
2561
- "members": [
2562
- {
2563
- "type": "STRING",
2564
- "value": ";"
2565
- },
2566
- {
2567
- "type": "PATTERN",
2568
- "value": ".*"
2569
- }
2570
- ]
2322
+ "type": "TOKEN",
2323
+ "content": {
2324
+ "type": "SEQ",
2325
+ "members": [
2326
+ {
2327
+ "type": "STRING",
2328
+ "value": ";"
2329
+ },
2330
+ {
2331
+ "type": "PATTERN",
2332
+ "value": "[^\\r\\n]*"
2333
+ }
2334
+ ]
2335
+ }
2571
2336
  },
2572
2337
  "identifier": {
2573
2338
  "type": "PATTERN",
@@ -2585,7 +2350,7 @@
2585
2350
  },
2586
2351
  {
2587
2352
  "type": "PATTERN",
2588
- "value": ".*"
2353
+ "value": "[^\\r\\n]*"
2589
2354
  },
2590
2355
  {
2591
2356
  "type": "SYMBOL",
@@ -2602,7 +2367,7 @@
2602
2367
  },
2603
2368
  {
2604
2369
  "type": "PATTERN",
2605
- "value": ".*"
2370
+ "value": "[^\\r\\n]*"
2606
2371
  },
2607
2372
  {
2608
2373
  "type": "SYMBOL",
@@ -2628,182 +2393,6 @@
2628
2393
  ]
2629
2394
  }
2630
2395
  ]
2631
- },
2632
- "_ASCII": {
2633
- "type": "PATTERN",
2634
- "value": "[\\x00-\\x7f]"
2635
- },
2636
- "_UTF_8_1": {
2637
- "type": "PATTERN",
2638
- "value": "[\\x80-\\xbf]"
2639
- },
2640
- "_UTF_8_2": {
2641
- "type": "SEQ",
2642
- "members": [
2643
- {
2644
- "type": "PATTERN",
2645
- "value": "[\\xc2-\\xdf]"
2646
- },
2647
- {
2648
- "type": "SYMBOL",
2649
- "name": "_UTF_8_1"
2650
- }
2651
- ]
2652
- },
2653
- "_UTF_8_3": {
2654
- "type": "CHOICE",
2655
- "members": [
2656
- {
2657
- "type": "SEQ",
2658
- "members": [
2659
- {
2660
- "type": "PATTERN",
2661
- "value": "\\xe0[\\xa0-\\xbf]"
2662
- },
2663
- {
2664
- "type": "SYMBOL",
2665
- "name": "_UTF_8_1"
2666
- }
2667
- ]
2668
- },
2669
- {
2670
- "type": "SEQ",
2671
- "members": [
2672
- {
2673
- "type": "PATTERN",
2674
- "value": "[\\xe1-\\xec]"
2675
- },
2676
- {
2677
- "type": "SYMBOL",
2678
- "name": "_UTF_8_1"
2679
- },
2680
- {
2681
- "type": "SYMBOL",
2682
- "name": "_UTF_8_1"
2683
- }
2684
- ]
2685
- },
2686
- {
2687
- "type": "SEQ",
2688
- "members": [
2689
- {
2690
- "type": "PATTERN",
2691
- "value": "\\xed[\\x80-\\x9f]"
2692
- },
2693
- {
2694
- "type": "SYMBOL",
2695
- "name": "_UTF_8_1"
2696
- }
2697
- ]
2698
- },
2699
- {
2700
- "type": "SEQ",
2701
- "members": [
2702
- {
2703
- "type": "PATTERN",
2704
- "value": "[\\xee-\\xef]"
2705
- },
2706
- {
2707
- "type": "SYMBOL",
2708
- "name": "_UTF_8_1"
2709
- },
2710
- {
2711
- "type": "SYMBOL",
2712
- "name": "_UTF_8_1"
2713
- }
2714
- ]
2715
- }
2716
- ]
2717
- },
2718
- "_UTF_8_4": {
2719
- "type": "CHOICE",
2720
- "members": [
2721
- {
2722
- "type": "SEQ",
2723
- "members": [
2724
- {
2725
- "type": "PATTERN",
2726
- "value": "\\xf0[\\x90-\\xbf]"
2727
- },
2728
- {
2729
- "type": "SYMBOL",
2730
- "name": "_UTF_8_1"
2731
- },
2732
- {
2733
- "type": "SYMBOL",
2734
- "name": "_UTF_8_1"
2735
- }
2736
- ]
2737
- },
2738
- {
2739
- "type": "SEQ",
2740
- "members": [
2741
- {
2742
- "type": "PATTERN",
2743
- "value": "[\\xf1-\\xf3]"
2744
- },
2745
- {
2746
- "type": "SYMBOL",
2747
- "name": "_UTF_8_1"
2748
- },
2749
- {
2750
- "type": "SYMBOL",
2751
- "name": "_UTF_8_1"
2752
- },
2753
- {
2754
- "type": "SYMBOL",
2755
- "name": "_UTF_8_1"
2756
- }
2757
- ]
2758
- },
2759
- {
2760
- "type": "SEQ",
2761
- "members": [
2762
- {
2763
- "type": "PATTERN",
2764
- "value": "\\xf4[\\x80-\\x8f]"
2765
- },
2766
- {
2767
- "type": "SYMBOL",
2768
- "name": "_UTF_8_1"
2769
- },
2770
- {
2771
- "type": "SYMBOL",
2772
- "name": "_UTF_8_1"
2773
- }
2774
- ]
2775
- }
2776
- ]
2777
- },
2778
- "_UTF_8_ONLY": {
2779
- "type": "CHOICE",
2780
- "members": [
2781
- {
2782
- "type": "SYMBOL",
2783
- "name": "_UTF_8_2"
2784
- },
2785
- {
2786
- "type": "SYMBOL",
2787
- "name": "_UTF_8_3"
2788
- },
2789
- {
2790
- "type": "SYMBOL",
2791
- "name": "_UTF_8_4"
2792
- }
2793
- ]
2794
- },
2795
- "_UTF_8": {
2796
- "type": "CHOICE",
2797
- "members": [
2798
- {
2799
- "type": "SYMBOL",
2800
- "name": "_ASCII"
2801
- },
2802
- {
2803
- "type": "SYMBOL",
2804
- "name": "_UTF_8_ONLY"
2805
- }
2806
- ]
2807
2396
  }
2808
2397
  },
2809
2398
  "extras": [
@@ -2832,6 +2421,6 @@
2832
2421
  "supertypes": [
2833
2422
  "_entry",
2834
2423
  "_directive"
2835
- ]
2836
- }
2837
-
2424
+ ],
2425
+ "reserved": {}
2426
+ }