Added tree-sitter-json vendor library

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2023-11-07 16:42:29 +0100
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2023-11-07 16:42:29 +0100
Commit 9123016d9d4d6fcc39a46828513f50bb52858458 (patch)
-rw-r--r-- .gitignore 16
-rw-r--r-- Makefile 6
-rw-r--r-- README.md 2
-rw-r--r-- compile_flags.txt 2
-rw-r--r-- main.c 40
-rw-r--r-- vendor/tree-sitter-json/LICENSE 21
-rw-r--r-- vendor/tree-sitter-json/Makefile 114
-rw-r--r-- vendor/tree-sitter-json/src/grammar.json 535
-rw-r--r-- vendor/tree-sitter-json/src/node-types.json 193
-rw-r--r-- vendor/tree-sitter-json/src/parser.c 1086
-rw-r--r-- vendor/tree-sitter-json/src/tree_sitter/parser.h 224
11 files changed, 2236 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
1
TAGS
1
TAGS
2
crep
2
crep
  
3
  
  
4
/target
  
5
*.rs.bk
  
6
*.a
  
7
*.dylib
  
8
*.so
  
9
*.so.[0-9]*
  
10
*.o
  
11
*.obj
  
12
*.exp
  
13
*.lib
  
14
*.wasm
  
15
.swiftpm
  
16
zig-*
diff --git a/Makefile b/Makefile
...
2
	@echo "Check targets"
2
	@echo "Check targets"
3
  
3
  
4
crep:
4
crep:
5
	$(CC) main.c -o crep
5
	$(CC) main.c \
  
6
		-I./vendor/tree-sitter/lib/include \
  
7
		-o crep \
  
8
		./vendor/tree-sitter/libtree-sitter.a \
  
9
		./vendor/tree-sitter-json/libtree-sitter-crep.a
6
  
10
  
7
clean:
11
clean:
8
	rm crep
12
	rm crep
diff --git a/README.md b/README.md
...
13
  
13
  
14
- https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm
14
- https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm
15
- https://github.com/tree-sitter/tree-sitter
15
- https://github.com/tree-sitter/tree-sitter
  
16
- https://tree-sitter.github.io/tree-sitter/playground
  
17
- https://dreampuf.github.io/GraphvizOnline/
diff --git a/compile_flags.txt b/compile_flags.txt
  
1
-std=c99
  
2
-I./vendor/tree-sitter/lib/include
diff --git a/main.c b/main.c
1
#include <stdio.h>
1
#include <stdio.h>
  
2
#include <assert.h>
  
3
#include <string.h>
  
4
#include <tree_sitter/api.h>
  
5
  
  
6
TSLanguage *tree_sitter_json();
2
  
7
  
3
int main() {
8
int main() {
4
  printf("Hi Mark!\n");
9
  printf("Hi, Mark\n");
  
10
  
  
11
  TSParser *parser = ts_parser_new();
  
12
  ts_parser_set_language(parser, tree_sitter_json());
  
13
  
  
14
  const char *source_code = "[1, null, [1,2,3]]";
  
15
  TSTree *tree = ts_parser_parse_string(
  
16
    parser,
  
17
    NULL,
  
18
    source_code,
  
19
    strlen(source_code)
  
20
  );
  
21
  
  
22
  TSNode root_node = ts_tree_root_node(tree);
  
23
  
  
24
  TSNode array_node = ts_node_named_child(root_node, 0);
  
25
  TSNode number_node = ts_node_named_child(array_node, 0);
  
26
  
  
27
  assert(strcmp(ts_node_type(root_node), "document") == 0);
  
28
  assert(strcmp(ts_node_type(array_node), "array") == 0);
  
29
  assert(strcmp(ts_node_type(number_node), "number") == 0);
  
30
  
  
31
  /* assert(ts_node_child_count(root_node) == 1); */
  
32
  /* assert(ts_node_child_count(array_node) == 5); */
  
33
  /* assert(ts_node_named_child_count(array_node) == 2); */
  
34
  /* assert(ts_node_child_count(number_node) == 0); */
  
35
  
  
36
  char *string = ts_node_string(root_node);
  
37
  printf("Syntax tree: %s\n", string);
  
38
  
  
39
  free(string);
  
40
  ts_tree_delete(tree);
  
41
  ts_parser_delete(parser);
  
42
  
5
  return 0;
43
  return 0;
6
}
44
}
diff --git a/vendor/tree-sitter-json/LICENSE b/vendor/tree-sitter-json/LICENSE
  
1
The MIT License (MIT)
  
2
  
  
3
Copyright (c) 2014 Max Brunsfeld
  
4
  
  
5
Permission is hereby granted, free of charge, to any person obtaining a copy
  
6
of this software and associated documentation files (the "Software"), to deal
  
7
in the Software without restriction, including without limitation the rights
  
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  
9
copies of the Software, and to permit persons to whom the Software is
  
10
furnished to do so, subject to the following conditions:
  
11
  
  
12
The above copyright notice and this permission notice shall be included in all
  
13
copies or substantial portions of the Software.
  
14
  
  
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  
18
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  
20
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  
21
SOFTWARE.
diff --git a/vendor/tree-sitter-json/Makefile b/vendor/tree-sitter-json/Makefile
  
1
VERSION := 0.19.0
  
2
  
  
3
# Repository
  
4
SRC_DIR := src
  
5
  
  
6
PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin )
  
7
  
  
8
ifeq (, $(PARSER_NAME))
  
9
	PARSER_NAME := $(shell basename $(PARSER_REPO_URL))
  
10
	PARSER_NAME := $(subst tree-sitter-,,$(PARSER_NAME))
  
11
	PARSER_NAME := $(subst .git,,$(PARSER_NAME))
  
12
endif
  
13
  
  
14
ifeq (, $(PARSER_URL))
  
15
	PARSER_URL := $(subst :,/,$(PARSER_REPO_URL))
  
16
	PARSER_URL := $(subst git@,https://,$(PARSER_URL))
  
17
	PARSER_URL := $(subst .git,,$(PARSER_URL))
  
18
endif
  
19
  
  
20
UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z )
  
21
  
  
22
# install directory layout
  
23
PREFIX ?= /usr/local
  
24
INCLUDEDIR ?= $(PREFIX)/include
  
25
LIBDIR ?= $(PREFIX)/lib
  
26
PCLIBDIR ?= $(LIBDIR)/pkgconfig
  
27
  
  
28
# collect C++ sources, and link if necessary
  
29
CPPSRC := $(wildcard $(SRC_DIR)/*.cc)
  
30
  
  
31
ifeq (, $(CPPSRC))
  
32
	ADDITIONALLIBS := 
  
33
else
  
34
	ADDITIONALLIBS := -lc++
  
35
endif
  
36
  
  
37
# collect sources
  
38
SRC := $(wildcard $(SRC_DIR)/*.c)
  
39
SRC += $(CPPSRC)
  
40
OBJ := $(addsuffix .o,$(basename $(SRC)))
  
41
  
  
42
# ABI versioning
  
43
SONAME_MAJOR := 0
  
44
SONAME_MINOR := 0
  
45
  
  
46
CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR)
  
47
CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR)
  
48
override CFLAGS += -std=gnu99 -fPIC
  
49
override CXXFLAGS += -fPIC
  
50
  
  
51
# OS-specific bits
  
52
ifeq ($(shell uname),Darwin)
  
53
	SOEXT = dylib
  
54
	SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib
  
55
	SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib
  
56
	LINKSHARED := $(LINKSHARED)-dynamiclib -Wl,
  
57
	ifneq ($(ADDITIONALLIBS),)
  
58
	LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS),
  
59
	endif
  
60
	LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/libtree-sitter-$(PARSER_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks
  
61
else
  
62
	SOEXT = so
  
63
	SOEXTVER_MAJOR = so.$(SONAME_MAJOR)
  
64
	SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR)
  
65
	LINKSHARED := $(LINKSHARED)-shared -Wl,
  
66
	ifneq ($(ADDITIONALLIBS),)
  
67
	LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS),
  
68
	endif
  
69
	LINKSHARED := $(LINKSHARED)-soname,libtree-sitter-$(PARSER_NAME).so.$(SONAME_MAJOR)
  
70
endif
  
71
ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
  
72
	PCLIBDIR := $(PREFIX)/libdata/pkgconfig
  
73
endif
  
74
  
  
75
all: libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXTVER) bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc
  
76
  
  
77
libtree-sitter-$(PARSER_NAME).a: $(OBJ)
  
78
	$(AR) rcs $@ $^
  
79
  
  
80
libtree-sitter-$(PARSER_NAME).$(SOEXTVER): $(OBJ)
  
81
	$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
  
82
	ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXT)
  
83
	ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR)
  
84
  
  
85
bindings/c/$(PARSER_NAME).h:
  
86
	sed -e 's|@UPPER_PARSERNAME@|$(UPPER_PARSER_NAME)|' \
  
87
		-e 's|@PARSERNAME@|$(PARSER_NAME)|' \
  
88
		bindings/c/tree-sitter.h.in > $@
  
89
  
  
90
bindings/c/tree-sitter-$(PARSER_NAME).pc:
  
91
	sed -e 's|@LIBDIR@|$(LIBDIR)|;s|@INCLUDEDIR@|$(INCLUDEDIR)|;s|@VERSION@|$(VERSION)|' \
  
92
		-e 's|=$(PREFIX)|=$${prefix}|' \
  
93
		-e 's|@PREFIX@|$(PREFIX)|' \
  
94
		-e 's|@ADDITIONALLIBS@|$(ADDITIONALLIBS)|' \
  
95
		-e 's|@PARSERNAME@|$(PARSER_NAME)|' \
  
96
		-e 's|@PARSERURL@|$(PARSER_URL)|' \
  
97
		bindings/c/tree-sitter.pc.in > $@
  
98
  
  
99
install: all
  
100
	install -d '$(DESTDIR)$(LIBDIR)'
  
101
	install -m755 libtree-sitter-$(PARSER_NAME).a '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).a
  
102
	install -m755 libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER)
  
103
	ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR)
  
104
	ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXT)
  
105
	install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter
  
106
	install -m644 bindings/c/$(PARSER_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/
  
107
	install -d '$(DESTDIR)$(PCLIBDIR)'
  
108
	install -m644 bindings/c/tree-sitter-$(PARSER_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/
  
109
  
  
110
clean:
  
111
	rm -f $(OBJ) libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXT) libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) libtree-sitter-$(PARSER_NAME).$(SOEXTVER)
  
112
	rm -f bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc
  
113
  
  
114
.PHONY: all install clean
diff --git a/vendor/tree-sitter-json/src/grammar.json b/vendor/tree-sitter-json/src/grammar.json
  
1
{
  
2
  "name": "json",
  
3
  "rules": {
  
4
    "document": {
  
5
      "type": "REPEAT",
  
6
      "content": {
  
7
        "type": "SYMBOL",
  
8
        "name": "_value"
  
9
      }
  
10
    },
  
11
    "_value": {
  
12
      "type": "CHOICE",
  
13
      "members": [
  
14
        {
  
15
          "type": "SYMBOL",
  
16
          "name": "object"
  
17
        },
  
18
        {
  
19
          "type": "SYMBOL",
  
20
          "name": "array"
  
21
        },
  
22
        {
  
23
          "type": "SYMBOL",
  
24
          "name": "number"
  
25
        },
  
26
        {
  
27
          "type": "SYMBOL",
  
28
          "name": "string"
  
29
        },
  
30
        {
  
31
          "type": "SYMBOL",
  
32
          "name": "true"
  
33
        },
  
34
        {
  
35
          "type": "SYMBOL",
  
36
          "name": "false"
  
37
        },
  
38
        {
  
39
          "type": "SYMBOL",
  
40
          "name": "null"
  
41
        }
  
42
      ]
  
43
    },
  
44
    "object": {
  
45
      "type": "SEQ",
  
46
      "members": [
  
47
        {
  
48
          "type": "STRING",
  
49
          "value": "{"
  
50
        },
  
51
        {
  
52
          "type": "CHOICE",
  
53
          "members": [
  
54
            {
  
55
              "type": "SEQ",
  
56
              "members": [
  
57
                {
  
58
                  "type": "SYMBOL",
  
59
                  "name": "pair"
  
60
                },
  
61
                {
  
62
                  "type": "REPEAT",
  
63
                  "content": {
  
64
                    "type": "SEQ",
  
65
                    "members": [
  
66
                      {
  
67
                        "type": "STRING",
  
68
                        "value": ","
  
69
                      },
  
70
                      {
  
71
                        "type": "SYMBOL",
  
72
                        "name": "pair"
  
73
                      }
  
74
                    ]
  
75
                  }
  
76
                }
  
77
              ]
  
78
            },
  
79
            {
  
80
              "type": "BLANK"
  
81
            }
  
82
          ]
  
83
        },
  
84
        {
  
85
          "type": "STRING",
  
86
          "value": "}"
  
87
        }
  
88
      ]
  
89
    },
  
90
    "pair": {
  
91
      "type": "SEQ",
  
92
      "members": [
  
93
        {
  
94
          "type": "FIELD",
  
95
          "name": "key",
  
96
          "content": {
  
97
            "type": "CHOICE",
  
98
            "members": [
  
99
              {
  
100
                "type": "SYMBOL",
  
101
                "name": "string"
  
102
              },
  
103
              {
  
104
                "type": "SYMBOL",
  
105
                "name": "number"
  
106
              }
  
107
            ]
  
108
          }
  
109
        },
  
110
        {
  
111
          "type": "STRING",
  
112
          "value": ":"
  
113
        },
  
114
        {
  
115
          "type": "FIELD",
  
116
          "name": "value",
  
117
          "content": {
  
118
            "type": "SYMBOL",
  
119
            "name": "_value"
  
120
          }
  
121
        }
  
122
      ]
  
123
    },
  
124
    "array": {
  
125
      "type": "SEQ",
  
126
      "members": [
  
127
        {
  
128
          "type": "STRING",
  
129
          "value": "["
  
130
        },
  
131
        {
  
132
          "type": "CHOICE",
  
133
          "members": [
  
134
            {
  
135
              "type": "SEQ",
  
136
              "members": [
  
137
                {
  
138
                  "type": "SYMBOL",
  
139
                  "name": "_value"
  
140
                },
  
141
                {
  
142
                  "type": "REPEAT",
  
143
                  "content": {
  
144
                    "type": "SEQ",
  
145
                    "members": [
  
146
                      {
  
147
                        "type": "STRING",
  
148
                        "value": ","
  
149
                      },
  
150
                      {
  
151
                        "type": "SYMBOL",
  
152
                        "name": "_value"
  
153
                      }
  
154
                    ]
  
155
                  }
  
156
                }
  
157
              ]
  
158
            },
  
159
            {
  
160
              "type": "BLANK"
  
161
            }
  
162
          ]
  
163
        },
  
164
        {
  
165
          "type": "STRING",
  
166
          "value": "]"
  
167
        }
  
168
      ]
  
169
    },
  
170
    "string": {
  
171
      "type": "CHOICE",
  
172
      "members": [
  
173
        {
  
174
          "type": "SEQ",
  
175
          "members": [
  
176
            {
  
177
              "type": "STRING",
  
178
              "value": "\""
  
179
            },
  
180
            {
  
181
              "type": "STRING",
  
182
              "value": "\""
  
183
            }
  
184
          ]
  
185
        },
  
186
        {
  
187
          "type": "SEQ",
  
188
          "members": [
  
189
            {
  
190
              "type": "STRING",
  
191
              "value": "\""
  
192
            },
  
193
            {
  
194
              "type": "SYMBOL",
  
195
              "name": "string_content"
  
196
            },
  
197
            {
  
198
              "type": "STRING",
  
199
              "value": "\""
  
200
            }
  
201
          ]
  
202
        }
  
203
      ]
  
204
    },
  
205
    "string_content": {
  
206
      "type": "REPEAT1",
  
207
      "content": {
  
208
        "type": "CHOICE",
  
209
        "members": [
  
210
          {
  
211
            "type": "IMMEDIATE_TOKEN",
  
212
            "content": {
  
213
              "type": "PREC",
  
214
              "value": 1,
  
215
              "content": {
  
216
                "type": "PATTERN",
  
217
                "value": "[^\\\\\"\\n]+"
  
218
              }
  
219
            }
  
220
          },
  
221
          {
  
222
            "type": "SYMBOL",
  
223
            "name": "escape_sequence"
  
224
          }
  
225
        ]
  
226
      }
  
227
    },
  
228
    "escape_sequence": {
  
229
      "type": "IMMEDIATE_TOKEN",
  
230
      "content": {
  
231
        "type": "SEQ",
  
232
        "members": [
  
233
          {
  
234
            "type": "STRING",
  
235
            "value": "\\"
  
236
          },
  
237
          {
  
238
            "type": "PATTERN",
  
239
            "value": "(\\\"|\\\\|\\/|b|f|n|r|t|u)"
  
240
          }
  
241
        ]
  
242
      }
  
243
    },
  
244
    "number": {
  
245
      "type": "TOKEN",
  
246
      "content": {
  
247
        "type": "CHOICE",
  
248
        "members": [
  
249
          {
  
250
            "type": "SEQ",
  
251
            "members": [
  
252
              {
  
253
                "type": "SEQ",
  
254
                "members": [
  
255
                  {
  
256
                    "type": "CHOICE",
  
257
                    "members": [
  
258
                      {
  
259
                        "type": "STRING",
  
260
                        "value": "-"
  
261
                      },
  
262
                      {
  
263
                        "type": "BLANK"
  
264
                      }
  
265
                    ]
  
266
                  },
  
267
                  {
  
268
                    "type": "CHOICE",
  
269
                    "members": [
  
270
                      {
  
271
                        "type": "STRING",
  
272
                        "value": "0"
  
273
                      },
  
274
                      {
  
275
                        "type": "SEQ",
  
276
                        "members": [
  
277
                          {
  
278
                            "type": "PATTERN",
  
279
                            "value": "[1-9]"
  
280
                          },
  
281
                          {
  
282
                            "type": "CHOICE",
  
283
                            "members": [
  
284
                              {
  
285
                                "type": "PATTERN",
  
286
                                "value": "\\d+"
  
287
                              },
  
288
                              {
  
289
                                "type": "BLANK"
  
290
                              }
  
291
                            ]
  
292
                          }
  
293
                        ]
  
294
                      }
  
295
                    ]
  
296
                  }
  
297
                ]
  
298
              },
  
299
              {
  
300
                "type": "STRING",
  
301
                "value": "."
  
302
              },
  
303
              {
  
304
                "type": "CHOICE",
  
305
                "members": [
  
306
                  {
  
307
                    "type": "PATTERN",
  
308
                    "value": "\\d+"
  
309
                  },
  
310
                  {
  
311
                    "type": "BLANK"
  
312
                  }
  
313
                ]
  
314
              },
  
315
              {
  
316
                "type": "CHOICE",
  
317
                "members": [
  
318
                  {
  
319
                    "type": "SEQ",
  
320
                    "members": [
  
321
                      {
  
322
                        "type": "CHOICE",
  
323
                        "members": [
  
324
                          {
  
325
                            "type": "STRING",
  
326
                            "value": "e"
  
327
                          },
  
328
                          {
  
329
                            "type": "STRING",
  
330
                            "value": "E"
  
331
                          }
  
332
                        ]
  
333
                      },
  
334
                      {
  
335
                        "type": "SEQ",
  
336
                        "members": [
  
337
                          {
  
338
                            "type": "CHOICE",
  
339
                            "members": [
  
340
                              {
  
341
                                "type": "STRING",
  
342
                                "value": "-"
  
343
                              },
  
344
                              {
  
345
                                "type": "BLANK"
  
346
                              }
  
347
                            ]
  
348
                          },
  
349
                          {
  
350
                            "type": "PATTERN",
  
351
                            "value": "\\d+"
  
352
                          }
  
353
                        ]
  
354
                      }
  
355
                    ]
  
356
                  },
  
357
                  {
  
358
                    "type": "BLANK"
  
359
                  }
  
360
                ]
  
361
              }
  
362
            ]
  
363
          },
  
364
          {
  
365
            "type": "SEQ",
  
366
            "members": [
  
367
              {
  
368
                "type": "SEQ",
  
369
                "members": [
  
370
                  {
  
371
                    "type": "CHOICE",
  
372
                    "members": [
  
373
                      {
  
374
                        "type": "STRING",
  
375
                        "value": "-"
  
376
                      },
  
377
                      {
  
378
                        "type": "BLANK"
  
379
                      }
  
380
                    ]
  
381
                  },
  
382
                  {
  
383
                    "type": "CHOICE",
  
384
                    "members": [
  
385
                      {
  
386
                        "type": "STRING",
  
387
                        "value": "0"
  
388
                      },
  
389
                      {
  
390
                        "type": "SEQ",
  
391
                        "members": [
  
392
                          {
  
393
                            "type": "PATTERN",
  
394
                            "value": "[1-9]"
  
395
                          },
  
396
                          {
  
397
                            "type": "CHOICE",
  
398
                            "members": [
  
399
                              {
  
400
                                "type": "PATTERN",
  
401
                                "value": "\\d+"
  
402
                              },
  
403
                              {
  
404
                                "type": "BLANK"
  
405
                              }
  
406
                            ]
  
407
                          }
  
408
                        ]
  
409
                      }
  
410
                    ]
  
411
                  }
  
412
                ]
  
413
              },
  
414
              {
  
415
                "type": "CHOICE",
  
416
                "members": [
  
417
                  {
  
418
                    "type": "SEQ",
  
419
                    "members": [
  
420
                      {
  
421
                        "type": "CHOICE",
  
422
                        "members": [
  
423
                          {
  
424
                            "type": "STRING",
  
425
                            "value": "e"
  
426
                          },
  
427
                          {
  
428
                            "type": "STRING",
  
429
                            "value": "E"
  
430
                          }
  
431
                        ]
  
432
                      },
  
433
                      {
  
434
                        "type": "SEQ",
  
435
                        "members": [
  
436
                          {
  
437
                            "type": "CHOICE",
  
438
                            "members": [
  
439
                              {
  
440
                                "type": "STRING",
  
441
                                "value": "-"
  
442
                              },
  
443
                              {
  
444
                                "type": "BLANK"
  
445
                              }
  
446
                            ]
  
447
                          },
  
448
                          {
  
449
                            "type": "PATTERN",
  
450
                            "value": "\\d+"
  
451
                          }
  
452
                        ]
  
453
                      }
  
454
                    ]
  
455
                  },
  
456
                  {
  
457
                    "type": "BLANK"
  
458
                  }
  
459
                ]
  
460
              }
  
461
            ]
  
462
          }
  
463
        ]
  
464
      }
  
465
    },
  
466
    "true": {
  
467
      "type": "STRING",
  
468
      "value": "true"
  
469
    },
  
470
    "false": {
  
471
      "type": "STRING",
  
472
      "value": "false"
  
473
    },
  
474
    "null": {
  
475
      "type": "STRING",
  
476
      "value": "null"
  
477
    },
  
478
    "comment": {
  
479
      "type": "TOKEN",
  
480
      "content": {
  
481
        "type": "CHOICE",
  
482
        "members": [
  
483
          {
  
484
            "type": "SEQ",
  
485
            "members": [
  
486
              {
  
487
                "type": "STRING",
  
488
                "value": "//"
  
489
              },
  
490
              {
  
491
                "type": "PATTERN",
  
492
                "value": ".*"
  
493
              }
  
494
            ]
  
495
          },
  
496
          {
  
497
            "type": "SEQ",
  
498
            "members": [
  
499
              {
  
500
                "type": "STRING",
  
501
                "value": "/*"
  
502
              },
  
503
              {
  
504
                "type": "PATTERN",
  
505
                "value": "[^*]*\\*+([^/*][^*]*\\*+)*"
  
506
              },
  
507
              {
  
508
                "type": "STRING",
  
509
                "value": "/"
  
510
              }
  
511
            ]
  
512
          }
  
513
        ]
  
514
      }
  
515
    }
  
516
  },
  
517
  "extras": [
  
518
    {
  
519
      "type": "PATTERN",
  
520
      "value": "\\s"
  
521
    },
  
522
    {
  
523
      "type": "SYMBOL",
  
524
      "name": "comment"
  
525
    }
  
526
  ],
  
527
  "conflicts": [],
  
528
  "precedences": [],
  
529
  "externals": [],
  
530
  "inline": [],
  
531
  "supertypes": [
  
532
    "_value"
  
533
  ]
  
534
}
  
535
  
diff --git a/vendor/tree-sitter-json/src/node-types.json b/vendor/tree-sitter-json/src/node-types.json
  
1
[
  
2
  {
  
3
    "type": "_value",
  
4
    "named": true,
  
5
    "subtypes": [
  
6
      {
  
7
        "type": "array",
  
8
        "named": true
  
9
      },
  
10
      {
  
11
        "type": "false",
  
12
        "named": true
  
13
      },
  
14
      {
  
15
        "type": "null",
  
16
        "named": true
  
17
      },
  
18
      {
  
19
        "type": "number",
  
20
        "named": true
  
21
      },
  
22
      {
  
23
        "type": "object",
  
24
        "named": true
  
25
      },
  
26
      {
  
27
        "type": "string",
  
28
        "named": true
  
29
      },
  
30
      {
  
31
        "type": "true",
  
32
        "named": true
  
33
      }
  
34
    ]
  
35
  },
  
36
  {
  
37
    "type": "array",
  
38
    "named": true,
  
39
    "fields": {},
  
40
    "children": {
  
41
      "multiple": true,
  
42
      "required": false,
  
43
      "types": [
  
44
        {
  
45
          "type": "_value",
  
46
          "named": true
  
47
        }
  
48
      ]
  
49
    }
  
50
  },
  
51
  {
  
52
    "type": "document",
  
53
    "named": true,
  
54
    "fields": {},
  
55
    "children": {
  
56
      "multiple": true,
  
57
      "required": false,
  
58
      "types": [
  
59
        {
  
60
          "type": "_value",
  
61
          "named": true
  
62
        }
  
63
      ]
  
64
    }
  
65
  },
  
66
  {
  
67
    "type": "object",
  
68
    "named": true,
  
69
    "fields": {},
  
70
    "children": {
  
71
      "multiple": true,
  
72
      "required": false,
  
73
      "types": [
  
74
        {
  
75
          "type": "pair",
  
76
          "named": true
  
77
        }
  
78
      ]
  
79
    }
  
80
  },
  
81
  {
  
82
    "type": "pair",
  
83
    "named": true,
  
84
    "fields": {
  
85
      "key": {
  
86
        "multiple": false,
  
87
        "required": true,
  
88
        "types": [
  
89
          {
  
90
            "type": "number",
  
91
            "named": true
  
92
          },
  
93
          {
  
94
            "type": "string",
  
95
            "named": true
  
96
          }
  
97
        ]
  
98
      },
  
99
      "value": {
  
100
        "multiple": false,
  
101
        "required": true,
  
102
        "types": [
  
103
          {
  
104
            "type": "_value",
  
105
            "named": true
  
106
          }
  
107
        ]
  
108
      }
  
109
    }
  
110
  },
  
111
  {
  
112
    "type": "string",
  
113
    "named": true,
  
114
    "fields": {},
  
115
    "children": {
  
116
      "multiple": false,
  
117
      "required": false,
  
118
      "types": [
  
119
        {
  
120
          "type": "string_content",
  
121
          "named": true
  
122
        }
  
123
      ]
  
124
    }
  
125
  },
  
126
  {
  
127
    "type": "string_content",
  
128
    "named": true,
  
129
    "fields": {},
  
130
    "children": {
  
131
      "multiple": true,
  
132
      "required": false,
  
133
      "types": [
  
134
        {
  
135
          "type": "escape_sequence",
  
136
          "named": true
  
137
        }
  
138
      ]
  
139
    }
  
140
  },
  
141
  {
  
142
    "type": "\"",
  
143
    "named": false
  
144
  },
  
145
  {
  
146
    "type": ",",
  
147
    "named": false
  
148
  },
  
149
  {
  
150
    "type": ":",
  
151
    "named": false
  
152
  },
  
153
  {
  
154
    "type": "[",
  
155
    "named": false
  
156
  },
  
157
  {
  
158
    "type": "]",
  
159
    "named": false
  
160
  },
  
161
  {
  
162
    "type": "comment",
  
163
    "named": true
  
164
  },
  
165
  {
  
166
    "type": "escape_sequence",
  
167
    "named": true
  
168
  },
  
169
  {
  
170
    "type": "false",
  
171
    "named": true
  
172
  },
  
173
  {
  
174
    "type": "null",
  
175
    "named": true
  
176
  },
  
177
  {
  
178
    "type": "number",
  
179
    "named": true
  
180
  },
  
181
  {
  
182
    "type": "true",
  
183
    "named": true
  
184
  },
  
185
  {
  
186
    "type": "{",
  
187
    "named": false
  
188
  },
  
189
  {
  
190
    "type": "}",
  
191
    "named": false
  
192
  }
  
193
]
diff --git a/vendor/tree-sitter-json/src/parser.c b/vendor/tree-sitter-json/src/parser.c
Changes too big to display
diff --git a/vendor/tree-sitter-json/src/tree_sitter/parser.h b/vendor/tree-sitter-json/src/tree_sitter/parser.h
  
1
#ifndef TREE_SITTER_PARSER_H_
  
2
#define TREE_SITTER_PARSER_H_
  
3
  
  
4
#ifdef __cplusplus
  
5
extern "C" {
  
6
#endif
  
7
  
  
8
#include <stdbool.h>
  
9
#include <stdint.h>
  
10
#include <stdlib.h>
  
11
  
  
12
#define ts_builtin_sym_error ((TSSymbol)-1)
  
13
#define ts_builtin_sym_end 0
  
14
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
  
15
  
  
16
#ifndef TREE_SITTER_API_H_
  
17
typedef uint16_t TSStateId;
  
18
typedef uint16_t TSSymbol;
  
19
typedef uint16_t TSFieldId;
  
20
typedef struct TSLanguage TSLanguage;
  
21
#endif
  
22
  
  
23
typedef struct {
  
24
  TSFieldId field_id;
  
25
  uint8_t child_index;
  
26
  bool inherited;
  
27
} TSFieldMapEntry;
  
28
  
  
29
typedef struct {
  
30
  uint16_t index;
  
31
  uint16_t length;
  
32
} TSFieldMapSlice;
  
33
  
  
34
typedef struct {
  
35
  bool visible;
  
36
  bool named;
  
37
  bool supertype;
  
38
} TSSymbolMetadata;
  
39
  
  
40
typedef struct TSLexer TSLexer;
  
41
  
  
42
struct TSLexer {
  
43
  int32_t lookahead;
  
44
  TSSymbol result_symbol;
  
45
  void (*advance)(TSLexer *, bool);
  
46
  void (*mark_end)(TSLexer *);
  
47
  uint32_t (*get_column)(TSLexer *);
  
48
  bool (*is_at_included_range_start)(const TSLexer *);
  
49
  bool (*eof)(const TSLexer *);
  
50
};
  
51
  
  
52
typedef enum {
  
53
  TSParseActionTypeShift,
  
54
  TSParseActionTypeReduce,
  
55
  TSParseActionTypeAccept,
  
56
  TSParseActionTypeRecover,
  
57
} TSParseActionType;
  
58
  
  
59
typedef union {
  
60
  struct {
  
61
    uint8_t type;
  
62
    TSStateId state;
  
63
    bool extra;
  
64
    bool repetition;
  
65
  } shift;
  
66
  struct {
  
67
    uint8_t type;
  
68
    uint8_t child_count;
  
69
    TSSymbol symbol;
  
70
    int16_t dynamic_precedence;
  
71
    uint16_t production_id;
  
72
  } reduce;
  
73
  uint8_t type;
  
74
} TSParseAction;
  
75
  
  
76
typedef struct {
  
77
  uint16_t lex_state;
  
78
  uint16_t external_lex_state;
  
79
} TSLexMode;
  
80
  
  
81
typedef union {
  
82
  TSParseAction action;
  
83
  struct {
  
84
    uint8_t count;
  
85
    bool reusable;
  
86
  } entry;
  
87
} TSParseActionEntry;
  
88
  
  
89
struct TSLanguage {
  
90
  uint32_t version;
  
91
  uint32_t symbol_count;
  
92
  uint32_t alias_count;
  
93
  uint32_t token_count;
  
94
  uint32_t external_token_count;
  
95
  uint32_t state_count;
  
96
  uint32_t large_state_count;
  
97
  uint32_t production_id_count;
  
98
  uint32_t field_count;
  
99
  uint16_t max_alias_sequence_length;
  
100
  const uint16_t *parse_table;
  
101
  const uint16_t *small_parse_table;
  
102
  const uint32_t *small_parse_table_map;
  
103
  const TSParseActionEntry *parse_actions;
  
104
  const char * const *symbol_names;
  
105
  const char * const *field_names;
  
106
  const TSFieldMapSlice *field_map_slices;
  
107
  const TSFieldMapEntry *field_map_entries;
  
108
  const TSSymbolMetadata *symbol_metadata;
  
109
  const TSSymbol *public_symbol_map;
  
110
  const uint16_t *alias_map;
  
111
  const TSSymbol *alias_sequences;
  
112
  const TSLexMode *lex_modes;
  
113
  bool (*lex_fn)(TSLexer *, TSStateId);
  
114
  bool (*keyword_lex_fn)(TSLexer *, TSStateId);
  
115
  TSSymbol keyword_capture_token;
  
116
  struct {
  
117
    const bool *states;
  
118
    const TSSymbol *symbol_map;
  
119
    void *(*create)(void);
  
120
    void (*destroy)(void *);
  
121
    bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
  
122
    unsigned (*serialize)(void *, char *);
  
123
    void (*deserialize)(void *, const char *, unsigned);
  
124
  } external_scanner;
  
125
  const TSStateId *primary_state_ids;
  
126
};
  
127
  
  
128
/*
  
129
 *  Lexer Macros
  
130
 */
  
131
  
  
132
#define START_LEXER()           \
  
133
  bool result = false;          \
  
134
  bool skip = false;            \
  
135
  bool eof = false;             \
  
136
  int32_t lookahead;            \
  
137
  goto start;                   \
  
138
  next_state:                   \
  
139
  lexer->advance(lexer, skip);  \
  
140
  start:                        \
  
141
  skip = false;                 \
  
142
  lookahead = lexer->lookahead; \
  
143
  eof = lexer->eof(lexer);
  
144
  
  
145
#define ADVANCE(state_value) \
  
146
  {                          \
  
147
    state = state_value;     \
  
148
    goto next_state;         \
  
149
  }
  
150
  
  
151
#define SKIP(state_value) \
  
152
  {                       \
  
153
    skip = true;          \
  
154
    state = state_value;  \
  
155
    goto next_state;      \
  
156
  }
  
157
  
  
158
#define ACCEPT_TOKEN(symbol_value)     \
  
159
  result = true;                       \
  
160
  lexer->result_symbol = symbol_value; \
  
161
  lexer->mark_end(lexer);
  
162
  
  
163
#define END_STATE() return result;
  
164
  
  
165
/*
  
166
 *  Parse Table Macros
  
167
 */
  
168
  
  
169
#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
  
170
  
  
171
#define STATE(id) id
  
172
  
  
173
#define ACTIONS(id) id
  
174
  
  
175
#define SHIFT(state_value)            \
  
176
  {{                                  \
  
177
    .shift = {                        \
  
178
      .type = TSParseActionTypeShift, \
  
179
      .state = (state_value)          \
  
180
    }                                 \
  
181
  }}
  
182
  
  
183
#define SHIFT_REPEAT(state_value)     \
  
184
  {{                                  \
  
185
    .shift = {                        \
  
186
      .type = TSParseActionTypeShift, \
  
187
      .state = (state_value),         \
  
188
      .repetition = true              \
  
189
    }                                 \
  
190
  }}
  
191
  
  
192
#define SHIFT_EXTRA()                 \
  
193
  {{                                  \
  
194
    .shift = {                        \
  
195
      .type = TSParseActionTypeShift, \
  
196
      .extra = true                   \
  
197
    }                                 \
  
198
  }}
  
199
  
  
200
#define REDUCE(symbol_val, child_count_val, ...) \
  
201
  {{                                             \
  
202
    .reduce = {                                  \
  
203
      .type = TSParseActionTypeReduce,           \
  
204
      .symbol = symbol_val,                      \
  
205
      .child_count = child_count_val,            \
  
206
      __VA_ARGS__                                \
  
207
    },                                           \
  
208
  }}
  
209
  
  
210
#define RECOVER()                    \
  
211
  {{                                 \
  
212
    .type = TSParseActionTypeRecover \
  
213
  }}
  
214
  
  
215
#define ACCEPT_INPUT()              \
  
216
  {{                                \
  
217
    .type = TSParseActionTypeAccept \
  
218
  }}
  
219
  
  
220
#ifdef __cplusplus
  
221
}
  
222
#endif
  
223
  
  
224
#endif  // TREE_SITTER_PARSER_H_