tree-sitter-ktav 0.2.1 → 0.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/src/grammar.json CHANGED
@@ -24,6 +24,10 @@
24
24
  {
25
25
  "type": "SYMBOL",
26
26
  "name": "object_pair"
27
+ },
28
+ {
29
+ "type": "SYMBOL",
30
+ "name": "top_array_item"
27
31
  }
28
32
  ]
29
33
  },
@@ -36,29 +40,15 @@
36
40
  "value": "\\r?\\n"
37
41
  },
38
42
  "comment": {
39
- "type": "SEQ",
40
- "members": [
41
- {
42
- "type": "STRING",
43
- "value": "#"
44
- },
45
- {
46
- "type": "CHOICE",
47
- "members": [
48
- {
49
- "type": "PATTERN",
50
- "value": "[^\\r\\n]*"
51
- },
52
- {
53
- "type": "BLANK"
54
- }
55
- ]
56
- },
57
- {
58
- "type": "SYMBOL",
59
- "name": "_newline"
43
+ "type": "TOKEN",
44
+ "content": {
45
+ "type": "PREC",
46
+ "value": 1,
47
+ "content": {
48
+ "type": "PATTERN",
49
+ "value": "##[^\\r\\n]*\\r?\\n"
60
50
  }
61
- ]
51
+ }
62
52
  },
63
53
  "object_pair": {
64
54
  "type": "CHOICE",
@@ -78,21 +68,8 @@
78
68
  "type": "FIELD",
79
69
  "name": "separator",
80
70
  "content": {
81
- "type": "CHOICE",
82
- "members": [
83
- {
84
- "type": "SYMBOL",
85
- "name": "sep_raw"
86
- },
87
- {
88
- "type": "SYMBOL",
89
- "name": "sep_int"
90
- },
91
- {
92
- "type": "SYMBOL",
93
- "name": "sep_float"
94
- }
95
- ]
71
+ "type": "SYMBOL",
72
+ "name": "sep_raw"
96
73
  }
97
74
  },
98
75
  {
@@ -111,7 +88,7 @@
111
88
  },
112
89
  {
113
90
  "type": "SYMBOL",
114
- "name": "scalar"
91
+ "name": "raw_scalar"
115
92
  }
116
93
  ]
117
94
  }
@@ -177,28 +154,6 @@
177
154
  }
178
155
  }
179
156
  },
180
- "sep_int": {
181
- "type": "TOKEN",
182
- "content": {
183
- "type": "PREC",
184
- "value": 2,
185
- "content": {
186
- "type": "STRING",
187
- "value": ":i"
188
- }
189
- }
190
- },
191
- "sep_float": {
192
- "type": "TOKEN",
193
- "content": {
194
- "type": "PREC",
195
- "value": 2,
196
- "content": {
197
- "type": "STRING",
198
- "value": ":f"
199
- }
200
- }
201
- },
202
157
  "sep_string": {
203
158
  "type": "TOKEN",
204
159
  "content": {
@@ -215,7 +170,7 @@
215
170
  "members": [
216
171
  {
217
172
  "type": "SYMBOL",
218
- "name": "_key_segment"
173
+ "name": "_spaced_key"
219
174
  },
220
175
  {
221
176
  "type": "SYMBOL",
@@ -223,6 +178,17 @@
223
178
  }
224
179
  ]
225
180
  },
181
+ "_spaced_key": {
182
+ "type": "PREC_LEFT",
183
+ "value": 0,
184
+ "content": {
185
+ "type": "REPEAT1",
186
+ "content": {
187
+ "type": "SYMBOL",
188
+ "name": "_key_segment"
189
+ }
190
+ }
191
+ },
226
192
  "dotted_key": {
227
193
  "type": "PREC_LEFT",
228
194
  "value": 0,
@@ -254,7 +220,7 @@
254
220
  },
255
221
  "_key_segment": {
256
222
  "type": "PATTERN",
257
- "value": "[^\\s\\[\\]\\{\\}:#.\\r\\n]+"
223
+ "value": "[^\\s\\[\\]\\{\\}\\(\\):#,.\\r\\n]+"
258
224
  },
259
225
  "_value_line": {
260
226
  "type": "CHOICE",
@@ -291,10 +257,26 @@
291
257
  "type": "SYMBOL",
292
258
  "name": "empty_double_paren"
293
259
  },
260
+ {
261
+ "type": "SYMBOL",
262
+ "name": "inline_object"
263
+ },
264
+ {
265
+ "type": "SYMBOL",
266
+ "name": "inline_array"
267
+ },
294
268
  {
295
269
  "type": "SYMBOL",
296
270
  "name": "keyword"
297
271
  },
272
+ {
273
+ "type": "SYMBOL",
274
+ "name": "integer"
275
+ },
276
+ {
277
+ "type": "SYMBOL",
278
+ "name": "float"
279
+ },
298
280
  {
299
281
  "type": "SYMBOL",
300
282
  "name": "scalar"
@@ -543,43 +525,342 @@
543
525
  }
544
526
  ]
545
527
  },
546
- "array_item": {
547
- "type": "CHOICE",
528
+ "inline_object": {
529
+ "type": "SEQ",
548
530
  "members": [
549
531
  {
550
- "type": "SEQ",
532
+ "type": "STRING",
533
+ "value": "{"
534
+ },
535
+ {
536
+ "type": "CHOICE",
551
537
  "members": [
552
538
  {
553
- "type": "FIELD",
554
- "name": "marker",
555
- "content": {
556
- "type": "SYMBOL",
557
- "name": "sep_raw"
558
- }
539
+ "type": "SYMBOL",
540
+ "name": "_inline_pair_list"
559
541
  },
542
+ {
543
+ "type": "BLANK"
544
+ }
545
+ ]
546
+ },
547
+ {
548
+ "type": "STRING",
549
+ "value": "}"
550
+ },
551
+ {
552
+ "type": "SYMBOL",
553
+ "name": "_newline"
554
+ }
555
+ ]
556
+ },
557
+ "inline_array": {
558
+ "type": "SEQ",
559
+ "members": [
560
+ {
561
+ "type": "STRING",
562
+ "value": "["
563
+ },
564
+ {
565
+ "type": "CHOICE",
566
+ "members": [
560
567
  {
561
568
  "type": "SYMBOL",
562
- "name": "_marker_ws"
569
+ "name": "_inline_item_list"
570
+ },
571
+ {
572
+ "type": "BLANK"
573
+ }
574
+ ]
575
+ },
576
+ {
577
+ "type": "STRING",
578
+ "value": "]"
579
+ },
580
+ {
581
+ "type": "SYMBOL",
582
+ "name": "_newline"
583
+ }
584
+ ]
585
+ },
586
+ "_inline_pair_list": {
587
+ "type": "SEQ",
588
+ "members": [
589
+ {
590
+ "type": "SYMBOL",
591
+ "name": "inline_pair"
592
+ },
593
+ {
594
+ "type": "REPEAT",
595
+ "content": {
596
+ "type": "SEQ",
597
+ "members": [
598
+ {
599
+ "type": "STRING",
600
+ "value": ","
601
+ },
602
+ {
603
+ "type": "SYMBOL",
604
+ "name": "inline_pair"
605
+ }
606
+ ]
607
+ }
608
+ },
609
+ {
610
+ "type": "CHOICE",
611
+ "members": [
612
+ {
613
+ "type": "STRING",
614
+ "value": ","
563
615
  },
616
+ {
617
+ "type": "BLANK"
618
+ }
619
+ ]
620
+ }
621
+ ]
622
+ },
623
+ "inline_pair": {
624
+ "type": "SEQ",
625
+ "members": [
626
+ {
627
+ "type": "FIELD",
628
+ "name": "key",
629
+ "content": {
630
+ "type": "SYMBOL",
631
+ "name": "key"
632
+ }
633
+ },
634
+ {
635
+ "type": "FIELD",
636
+ "name": "separator",
637
+ "content": {
638
+ "type": "CHOICE",
639
+ "members": [
640
+ {
641
+ "type": "SYMBOL",
642
+ "name": "sep_raw"
643
+ },
644
+ {
645
+ "type": "SYMBOL",
646
+ "name": "sep_string"
647
+ }
648
+ ]
649
+ }
650
+ },
651
+ {
652
+ "type": "CHOICE",
653
+ "members": [
564
654
  {
565
655
  "type": "FIELD",
566
656
  "name": "value",
567
657
  "content": {
568
- "type": "CHOICE",
569
- "members": [
570
- {
571
- "type": "SYMBOL",
572
- "name": "empty_value"
573
- },
574
- {
575
- "type": "SYMBOL",
576
- "name": "scalar"
577
- }
578
- ]
658
+ "type": "SYMBOL",
659
+ "name": "inline_value"
660
+ }
661
+ },
662
+ {
663
+ "type": "BLANK"
664
+ }
665
+ ]
666
+ }
667
+ ]
668
+ },
669
+ "_inline_item_list": {
670
+ "type": "SEQ",
671
+ "members": [
672
+ {
673
+ "type": "SYMBOL",
674
+ "name": "inline_value"
675
+ },
676
+ {
677
+ "type": "REPEAT",
678
+ "content": {
679
+ "type": "SEQ",
680
+ "members": [
681
+ {
682
+ "type": "STRING",
683
+ "value": ","
684
+ },
685
+ {
686
+ "type": "SYMBOL",
687
+ "name": "inline_value"
579
688
  }
689
+ ]
690
+ }
691
+ },
692
+ {
693
+ "type": "CHOICE",
694
+ "members": [
695
+ {
696
+ "type": "STRING",
697
+ "value": ","
698
+ },
699
+ {
700
+ "type": "BLANK"
701
+ }
702
+ ]
703
+ }
704
+ ]
705
+ },
706
+ "inline_value": {
707
+ "type": "CHOICE",
708
+ "members": [
709
+ {
710
+ "type": "SYMBOL",
711
+ "name": "nested_inline_object"
712
+ },
713
+ {
714
+ "type": "SYMBOL",
715
+ "name": "nested_inline_array"
716
+ },
717
+ {
718
+ "type": "SYMBOL",
719
+ "name": "inline_scalar"
720
+ }
721
+ ]
722
+ },
723
+ "nested_inline_object": {
724
+ "type": "SEQ",
725
+ "members": [
726
+ {
727
+ "type": "STRING",
728
+ "value": "{"
729
+ },
730
+ {
731
+ "type": "CHOICE",
732
+ "members": [
733
+ {
734
+ "type": "SYMBOL",
735
+ "name": "_inline_pair_list"
736
+ },
737
+ {
738
+ "type": "BLANK"
580
739
  }
581
740
  ]
582
741
  },
742
+ {
743
+ "type": "STRING",
744
+ "value": "}"
745
+ }
746
+ ]
747
+ },
748
+ "nested_inline_array": {
749
+ "type": "SEQ",
750
+ "members": [
751
+ {
752
+ "type": "STRING",
753
+ "value": "["
754
+ },
755
+ {
756
+ "type": "CHOICE",
757
+ "members": [
758
+ {
759
+ "type": "SYMBOL",
760
+ "name": "_inline_item_list"
761
+ },
762
+ {
763
+ "type": "BLANK"
764
+ }
765
+ ]
766
+ },
767
+ {
768
+ "type": "STRING",
769
+ "value": "]"
770
+ }
771
+ ]
772
+ },
773
+ "inline_scalar": {
774
+ "type": "SEQ",
775
+ "members": [
776
+ {
777
+ "type": "CHOICE",
778
+ "members": [
779
+ {
780
+ "type": "SYMBOL",
781
+ "name": "escape_sequence"
782
+ },
783
+ {
784
+ "type": "SYMBOL",
785
+ "name": "_inline_scalar_head"
786
+ }
787
+ ]
788
+ },
789
+ {
790
+ "type": "REPEAT",
791
+ "content": {
792
+ "type": "CHOICE",
793
+ "members": [
794
+ {
795
+ "type": "SYMBOL",
796
+ "name": "escape_sequence"
797
+ },
798
+ {
799
+ "type": "SYMBOL",
800
+ "name": "_inline_scalar_text"
801
+ }
802
+ ]
803
+ }
804
+ }
805
+ ]
806
+ },
807
+ "escape_sequence": {
808
+ "type": "TOKEN",
809
+ "content": {
810
+ "type": "CHOICE",
811
+ "members": [
812
+ {
813
+ "type": "STRING",
814
+ "value": "\\\\"
815
+ },
816
+ {
817
+ "type": "STRING",
818
+ "value": "\\,"
819
+ },
820
+ {
821
+ "type": "STRING",
822
+ "value": "\\}"
823
+ },
824
+ {
825
+ "type": "STRING",
826
+ "value": "\\]"
827
+ },
828
+ {
829
+ "type": "STRING",
830
+ "value": "\\{"
831
+ },
832
+ {
833
+ "type": "STRING",
834
+ "value": "\\["
835
+ },
836
+ {
837
+ "type": "STRING",
838
+ "value": "\\n"
839
+ },
840
+ {
841
+ "type": "STRING",
842
+ "value": "\\r"
843
+ }
844
+ ]
845
+ }
846
+ },
847
+ "_inline_scalar_head": {
848
+ "type": "TOKEN",
849
+ "content": {
850
+ "type": "PATTERN",
851
+ "value": "[^\\s\\\\,\\{\\[\\}\\]\\r\\n][^\\\\,\\}\\]\\r\\n]*"
852
+ }
853
+ },
854
+ "_inline_scalar_text": {
855
+ "type": "TOKEN",
856
+ "content": {
857
+ "type": "PATTERN",
858
+ "value": "[^\\\\,\\}\\]\\r\\n]+"
859
+ }
860
+ },
861
+ "array_item": {
862
+ "type": "CHOICE",
863
+ "members": [
583
864
  {
584
865
  "type": "SEQ",
585
866
  "members": [
@@ -588,7 +869,7 @@
588
869
  "name": "marker",
589
870
  "content": {
590
871
  "type": "SYMBOL",
591
- "name": "sep_int"
872
+ "name": "sep_raw"
592
873
  }
593
874
  },
594
875
  {
@@ -607,13 +888,26 @@
607
888
  },
608
889
  {
609
890
  "type": "SYMBOL",
610
- "name": "scalar"
891
+ "name": "raw_scalar"
611
892
  }
612
893
  ]
613
894
  }
614
895
  }
615
896
  ]
616
897
  },
898
+ {
899
+ "type": "FIELD",
900
+ "name": "value",
901
+ "content": {
902
+ "type": "SYMBOL",
903
+ "name": "_value_line"
904
+ }
905
+ }
906
+ ]
907
+ },
908
+ "top_array_item": {
909
+ "type": "CHOICE",
910
+ "members": [
617
911
  {
618
912
  "type": "SEQ",
619
913
  "members": [
@@ -622,7 +916,7 @@
622
916
  "name": "marker",
623
917
  "content": {
624
918
  "type": "SYMBOL",
625
- "name": "sep_float"
919
+ "name": "sep_raw"
626
920
  }
627
921
  },
628
922
  {
@@ -641,7 +935,7 @@
641
935
  },
642
936
  {
643
937
  "type": "SYMBOL",
644
- "name": "scalar"
938
+ "name": "raw_scalar"
645
939
  }
646
940
  ]
647
941
  }
@@ -653,11 +947,126 @@
653
947
  "name": "value",
654
948
  "content": {
655
949
  "type": "SYMBOL",
656
- "name": "_value_line"
950
+ "name": "compound_object"
951
+ }
952
+ },
953
+ {
954
+ "type": "FIELD",
955
+ "name": "value",
956
+ "content": {
957
+ "type": "SYMBOL",
958
+ "name": "compound_array"
959
+ }
960
+ },
961
+ {
962
+ "type": "FIELD",
963
+ "name": "value",
964
+ "content": {
965
+ "type": "SYMBOL",
966
+ "name": "multiline_stripped"
967
+ }
968
+ },
969
+ {
970
+ "type": "FIELD",
971
+ "name": "value",
972
+ "content": {
973
+ "type": "SYMBOL",
974
+ "name": "multiline_verbatim"
975
+ }
976
+ },
977
+ {
978
+ "type": "FIELD",
979
+ "name": "value",
980
+ "content": {
981
+ "type": "SYMBOL",
982
+ "name": "empty_object"
983
+ }
984
+ },
985
+ {
986
+ "type": "FIELD",
987
+ "name": "value",
988
+ "content": {
989
+ "type": "SYMBOL",
990
+ "name": "empty_array"
991
+ }
992
+ },
993
+ {
994
+ "type": "FIELD",
995
+ "name": "value",
996
+ "content": {
997
+ "type": "SYMBOL",
998
+ "name": "empty_paren"
999
+ }
1000
+ },
1001
+ {
1002
+ "type": "FIELD",
1003
+ "name": "value",
1004
+ "content": {
1005
+ "type": "SYMBOL",
1006
+ "name": "empty_double_paren"
1007
+ }
1008
+ },
1009
+ {
1010
+ "type": "FIELD",
1011
+ "name": "value",
1012
+ "content": {
1013
+ "type": "SYMBOL",
1014
+ "name": "inline_object"
1015
+ }
1016
+ },
1017
+ {
1018
+ "type": "FIELD",
1019
+ "name": "value",
1020
+ "content": {
1021
+ "type": "SYMBOL",
1022
+ "name": "inline_array"
1023
+ }
1024
+ },
1025
+ {
1026
+ "type": "FIELD",
1027
+ "name": "value",
1028
+ "content": {
1029
+ "type": "SYMBOL",
1030
+ "name": "keyword"
1031
+ }
1032
+ },
1033
+ {
1034
+ "type": "FIELD",
1035
+ "name": "value",
1036
+ "content": {
1037
+ "type": "SYMBOL",
1038
+ "name": "integer"
1039
+ }
1040
+ },
1041
+ {
1042
+ "type": "FIELD",
1043
+ "name": "value",
1044
+ "content": {
1045
+ "type": "SYMBOL",
1046
+ "name": "float"
1047
+ }
1048
+ },
1049
+ {
1050
+ "type": "FIELD",
1051
+ "name": "value",
1052
+ "content": {
1053
+ "type": "SYMBOL",
1054
+ "name": "top_scalar"
657
1055
  }
658
1056
  }
659
1057
  ]
660
1058
  },
1059
+ "top_scalar": {
1060
+ "type": "SYMBOL",
1061
+ "name": "_top_scalar_text"
1062
+ },
1063
+ "_top_scalar_text": {
1064
+ "type": "TOKEN",
1065
+ "content": {
1066
+ "type": "PATTERN",
1067
+ "value": "[^\\s:\\{\\[\\(\\r\\n][^:\\r\\n]*\\r?\\n"
1068
+ }
1069
+ },
661
1070
  "multiline_stripped": {
662
1071
  "type": "SEQ",
663
1072
  "members": [
@@ -722,10 +1131,49 @@
722
1131
  }
723
1132
  ]
724
1133
  },
725
- "_scalar_text": {
1134
+ "raw_scalar": {
1135
+ "type": "SEQ",
1136
+ "members": [
1137
+ {
1138
+ "type": "SYMBOL",
1139
+ "name": "_raw_scalar_text"
1140
+ },
1141
+ {
1142
+ "type": "SYMBOL",
1143
+ "name": "_newline"
1144
+ }
1145
+ ]
1146
+ },
1147
+ "_raw_scalar_text": {
726
1148
  "type": "PATTERN",
727
1149
  "value": "[^\\s\\r\\n][^\\r\\n]*"
728
1150
  },
1151
+ "_scalar_text": {
1152
+ "type": "PATTERN",
1153
+ "value": "[^\\s\\{\\[\\(\\r\\n][^\\r\\n]*"
1154
+ },
1155
+ "integer": {
1156
+ "type": "TOKEN",
1157
+ "content": {
1158
+ "type": "PREC",
1159
+ "value": 2,
1160
+ "content": {
1161
+ "type": "PATTERN",
1162
+ "value": "[+-]?(0x[0-9a-fA-F]([_]?[0-9a-fA-F])*|0o[0-7]([_]?[0-7])*|0b[01]([_]?[01])*|[0-9]([_]?[0-9])*)[ \\t]*\\r?\\n"
1163
+ }
1164
+ }
1165
+ },
1166
+ "float": {
1167
+ "type": "TOKEN",
1168
+ "content": {
1169
+ "type": "PREC",
1170
+ "value": 3,
1171
+ "content": {
1172
+ "type": "PATTERN",
1173
+ "value": "([+-]?[0-9]([_]?[0-9])*\\.[0-9]([_]?[0-9])*([eE][+-]?[0-9]([_]?[0-9])*)?|[+-]?[0-9]([_]?[0-9])*[eE][+-]?[0-9]([_]?[0-9])*)[ \\t]*\\r?\\n"
1174
+ }
1175
+ }
1176
+ },
729
1177
  "keyword": {
730
1178
  "type": "SEQ",
731
1179
  "members": [