diff options
Diffstat (limited to 'vendor/tree-sitter-json')
| -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 |
6 files changed, 2173 insertions, 0 deletions
diff --git a/vendor/tree-sitter-json/LICENSE b/vendor/tree-sitter-json/LICENSE new file mode 100644 index 0000000..4b52d19 --- /dev/null +++ b/vendor/tree-sitter-json/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/tree-sitter-json/Makefile b/vendor/tree-sitter-json/Makefile new file mode 100644 index 0000000..5772f7a --- /dev/null +++ b/vendor/tree-sitter-json/Makefile @@ -0,0 +1,114 @@ +VERSION := 0.19.0 + +# Repository +SRC_DIR := src + +PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin ) + +ifeq (, $(PARSER_NAME)) + PARSER_NAME := $(shell basename $(PARSER_REPO_URL)) + PARSER_NAME := $(subst tree-sitter-,,$(PARSER_NAME)) + PARSER_NAME := $(subst .git,,$(PARSER_NAME)) +endif + +ifeq (, $(PARSER_URL)) + PARSER_URL := $(subst :,/,$(PARSER_REPO_URL)) + PARSER_URL := $(subst git@,https://,$(PARSER_URL)) + PARSER_URL := $(subst .git,,$(PARSER_URL)) +endif + +UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z ) + +# install directory layout +PREFIX ?= /usr/local +INCLUDEDIR ?= $(PREFIX)/include +LIBDIR ?= $(PREFIX)/lib +PCLIBDIR ?= $(LIBDIR)/pkgconfig + +# collect C++ sources, and link if necessary +CPPSRC := $(wildcard $(SRC_DIR)/*.cc) + +ifeq (, $(CPPSRC)) + ADDITIONALLIBS := +else + ADDITIONALLIBS := -lc++ +endif + +# collect sources +SRC := $(wildcard $(SRC_DIR)/*.c) +SRC += $(CPPSRC) +OBJ := $(addsuffix .o,$(basename $(SRC))) + +# ABI versioning +SONAME_MAJOR := 0 +SONAME_MINOR := 0 + +CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) +CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) +override CFLAGS += -std=gnu99 -fPIC +override CXXFLAGS += -fPIC + +# OS-specific bits +ifeq ($(shell uname),Darwin) + SOEXT = dylib + SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib + SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib + LINKSHARED := $(LINKSHARED)-dynamiclib -Wl, + ifneq ($(ADDITIONALLIBS),) + LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), + endif + LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/libtree-sitter-$(PARSER_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks +else + SOEXT = so + SOEXTVER_MAJOR = so.$(SONAME_MAJOR) + SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR) + LINKSHARED := $(LINKSHARED)-shared -Wl, + ifneq ($(ADDITIONALLIBS),) + LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), + endif + LINKSHARED := $(LINKSHARED)-soname,libtree-sitter-$(PARSER_NAME).so.$(SONAME_MAJOR) +endif +ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly)) + PCLIBDIR := $(PREFIX)/libdata/pkgconfig +endif + +all: libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXTVER) bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc + +libtree-sitter-$(PARSER_NAME).a: $(OBJ) + $(AR) rcs $@ $^ + +libtree-sitter-$(PARSER_NAME).$(SOEXTVER): $(OBJ) + $(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ + ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXT) + ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) + +bindings/c/$(PARSER_NAME).h: + sed -e 's|@UPPER_PARSERNAME@|$(UPPER_PARSER_NAME)|' \ + -e 's|@PARSERNAME@|$(PARSER_NAME)|' \ + bindings/c/tree-sitter.h.in > $@ + +bindings/c/tree-sitter-$(PARSER_NAME).pc: + sed -e 's|@LIBDIR@|$(LIBDIR)|;s|@INCLUDEDIR@|$(INCLUDEDIR)|;s|@VERSION@|$(VERSION)|' \ + -e 's|=$(PREFIX)|=$${prefix}|' \ + -e 's|@PREFIX@|$(PREFIX)|' \ + -e 's|@ADDITIONALLIBS@|$(ADDITIONALLIBS)|' \ + -e 's|@PARSERNAME@|$(PARSER_NAME)|' \ + -e 's|@PARSERURL@|$(PARSER_URL)|' \ + bindings/c/tree-sitter.pc.in > $@ + +install: all + install -d '$(DESTDIR)$(LIBDIR)' + install -m755 libtree-sitter-$(PARSER_NAME).a '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).a + install -m755 libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER) + ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) + ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXT) + install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter + install -m644 bindings/c/$(PARSER_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/ + install -d '$(DESTDIR)$(PCLIBDIR)' + install -m644 bindings/c/tree-sitter-$(PARSER_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/ + +clean: + rm -f $(OBJ) libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXT) libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) libtree-sitter-$(PARSER_NAME).$(SOEXTVER) + rm -f bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc + +.PHONY: all install clean diff --git a/vendor/tree-sitter-json/src/grammar.json b/vendor/tree-sitter-json/src/grammar.json new file mode 100644 index 0000000..8bb8329 --- /dev/null +++ b/vendor/tree-sitter-json/src/grammar.json @@ -0,0 +1,535 @@ +{ + "name": "json", + "rules": { + "document": { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_value" + } + }, + "_value": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "object" + }, + { + "type": "SYMBOL", + "name": "array" + }, + { + "type": "SYMBOL", + "name": "number" + }, + { + "type": "SYMBOL", + "name": "string" + }, + { + "type": "SYMBOL", + "name": "true" + }, + { + "type": "SYMBOL", + "name": "false" + }, + { + "type": "SYMBOL", + "name": "null" + } + ] + }, + "object": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "pair" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "pair" + } + ] + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "pair": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "key", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "string" + }, + { + "type": "SYMBOL", + "name": "number" + } + ] + } + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_value" + } + } + ] + }, + "array": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "[" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_value" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "_value" + } + ] + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "]" + } + ] + }, + "string": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "\"" + }, + { + "type": "STRING", + "value": "\"" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "\"" + }, + { + "type": "SYMBOL", + "name": "string_content" + }, + { + "type": "STRING", + "value": "\"" + } + ] + } + ] + }, + "string_content": { + "type": "REPEAT1", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "PATTERN", + "value": "[^\\\\\"\\n]+" + } + } + }, + { + "type": "SYMBOL", + "name": "escape_sequence" + } + ] + } + }, + "escape_sequence": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "\\" + }, + { + "type": "PATTERN", + "value": "(\\\"|\\\\|\\/|b|f|n|r|t|u)" + } + ] + } + }, + "number": { + "type": "TOKEN", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "-" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "0" + }, + { + "type": "SEQ", + "members": [ + { + "type": "PATTERN", + "value": "[1-9]" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "\\d+" + }, + { + "type": "BLANK" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "STRING", + "value": "." + }, + { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "\\d+" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "e" + }, + { + "type": "STRING", + "value": "E" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "-" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "PATTERN", + "value": "\\d+" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "-" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "0" + }, + { + "type": "SEQ", + "members": [ + { + "type": "PATTERN", + "value": "[1-9]" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "\\d+" + }, + { + "type": "BLANK" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "e" + }, + { + "type": "STRING", + "value": "E" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "-" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "PATTERN", + "value": "\\d+" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + } + ] + } + }, + "true": { + "type": "STRING", + "value": "true" + }, + "false": { + "type": "STRING", + "value": "false" + }, + "null": { + "type": "STRING", + "value": "null" + }, + "comment": { + "type": "TOKEN", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "//" + }, + { + "type": "PATTERN", + "value": ".*" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "/*" + }, + { + "type": "PATTERN", + "value": "[^*]*\\*+([^/*][^*]*\\*+)*" + }, + { + "type": "STRING", + "value": "/" + } + ] + } + ] + } + } + }, + "extras": [ + { + "type": "PATTERN", + "value": "\\s" + }, + { + "type": "SYMBOL", + "name": "comment" + } + ], + "conflicts": [], + "precedences": [], + "externals": [], + "inline": [], + "supertypes": [ + "_value" + ] +} + diff --git a/vendor/tree-sitter-json/src/node-types.json b/vendor/tree-sitter-json/src/node-types.json new file mode 100644 index 0000000..bfb2688 --- /dev/null +++ b/vendor/tree-sitter-json/src/node-types.json @@ -0,0 +1,193 @@ +[ + { + "type": "_value", + "named": true, + "subtypes": [ + { + "type": "array", + "named": true + }, + { + "type": "false", + "named": true + }, + { + "type": "null", + "named": true + }, + { + "type": "number", + "named": true + }, + { + "type": "object", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "true", + "named": true + } + ] + }, + { + "type": "array", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "_value", + "named": true + } + ] + } + }, + { + "type": "document", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "_value", + "named": true + } + ] + } + }, + { + "type": "object", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "pair", + "named": true + } + ] + } + }, + { + "type": "pair", + "named": true, + "fields": { + "key": { + "multiple": false, + "required": true, + "types": [ + { + "type": "number", + "named": true + }, + { + "type": "string", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_value", + "named": true + } + ] + } + } + }, + { + "type": "string", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "string_content", + "named": true + } + ] + } + }, + { + "type": "string_content", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "escape_sequence", + "named": true + } + ] + } + }, + { + "type": "\"", + "named": false + }, + { + "type": ",", + "named": false + }, + { + "type": ":", + "named": false + }, + { + "type": "[", + "named": false + }, + { + "type": "]", + "named": false + }, + { + "type": "comment", + "named": true + }, + { + "type": "escape_sequence", + "named": true + }, + { + "type": "false", + "named": true + }, + { + "type": "null", + "named": true + }, + { + "type": "number", + "named": true + }, + { + "type": "true", + "named": true + }, + { + "type": "{", + "named": false + }, + { + "type": "}", + "named": false + } +]
\ No newline at end of file diff --git a/vendor/tree-sitter-json/src/parser.c b/vendor/tree-sitter-json/src/parser.c new file mode 100644 index 0000000..1c036f0 --- /dev/null +++ b/vendor/tree-sitter-json/src/parser.c @@ -0,0 +1,1086 @@ +#include "tree_sitter/parser.h" + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#define LANGUAGE_VERSION 14 +#define STATE_COUNT 33 +#define LARGE_STATE_COUNT 4 +#define SYMBOL_COUNT 26 +#define ALIAS_COUNT 0 +#define TOKEN_COUNT 15 +#define EXTERNAL_TOKEN_COUNT 0 +#define FIELD_COUNT 2 +#define MAX_ALIAS_SEQUENCE_LENGTH 4 +#define PRODUCTION_ID_COUNT 2 + +enum ts_symbol_identifiers { + anon_sym_LBRACE = 1, + anon_sym_COMMA = 2, + anon_sym_RBRACE = 3, + anon_sym_COLON = 4, + anon_sym_LBRACK = 5, + anon_sym_RBRACK = 6, + anon_sym_DQUOTE = 7, + aux_sym_string_content_token1 = 8, + sym_escape_sequence = 9, + sym_number = 10, + sym_true = 11, + sym_false = 12, + sym_null = 13, + sym_comment = 14, + sym_document = 15, + sym__value = 16, + sym_object = 17, + sym_pair = 18, + sym_array = 19, + sym_string = 20, + sym_string_content = 21, + aux_sym_document_repeat1 = 22, + aux_sym_object_repeat1 = 23, + aux_sym_array_repeat1 = 24, + aux_sym_string_content_repeat1 = 25, +}; + +static const char * const ts_symbol_names[] = { + [ts_builtin_sym_end] = "end", + [anon_sym_LBRACE] = "{", + [anon_sym_COMMA] = ",", + [anon_sym_RBRACE] = "}", + [anon_sym_COLON] = ":", + [anon_sym_LBRACK] = "[", + [anon_sym_RBRACK] = "]", + [anon_sym_DQUOTE] = "\"", + [aux_sym_string_content_token1] = "string_content_token1", + [sym_escape_sequence] = "escape_sequence", + [sym_number] = "number", + [sym_true] = "true", + [sym_false] = "false", + [sym_null] = "null", + [sym_comment] = "comment", + [sym_document] = "document", + [sym__value] = "_value", + [sym_object] = "object", + [sym_pair] = "pair", + [sym_array] = "array", + [sym_string] = "string", + [sym_string_content] = "string_content", + [aux_sym_document_repeat1] = "document_repeat1", + [aux_sym_object_repeat1] = "object_repeat1", + [aux_sym_array_repeat1] = "array_repeat1", + [aux_sym_string_content_repeat1] = "string_content_repeat1", +}; + +static const TSSymbol ts_symbol_map[] = { + [ts_builtin_sym_end] = ts_builtin_sym_end, + [anon_sym_LBRACE] = anon_sym_LBRACE, + [anon_sym_COMMA] = anon_sym_COMMA, + [anon_sym_RBRACE] = anon_sym_RBRACE, + [anon_sym_COLON] = anon_sym_COLON, + [anon_sym_LBRACK] = anon_sym_LBRACK, + [anon_sym_RBRACK] = anon_sym_RBRACK, + [anon_sym_DQUOTE] = anon_sym_DQUOTE, + [aux_sym_string_content_token1] = aux_sym_string_content_token1, + [sym_escape_sequence] = sym_escape_sequence, + [sym_number] = sym_number, + [sym_true] = sym_true, + [sym_false] = sym_false, + [sym_null] = sym_null, + [sym_comment] = sym_comment, + [sym_document] = sym_document, + [sym__value] = sym__value, + [sym_object] = sym_object, + [sym_pair] = sym_pair, + [sym_array] = sym_array, + [sym_string] = sym_string, + [sym_string_content] = sym_string_content, + [aux_sym_document_repeat1] = aux_sym_document_repeat1, + [aux_sym_object_repeat1] = aux_sym_object_repeat1, + [aux_sym_array_repeat1] = aux_sym_array_repeat1, + [aux_sym_string_content_repeat1] = aux_sym_string_content_repeat1, +}; + +static const TSSymbolMetadata ts_symbol_metadata[] = { + [ts_builtin_sym_end] = { + .visible = false, + .named = true, + }, + [anon_sym_LBRACE] = { + .visible = true, + .named = false, + }, + [anon_sym_COMMA] = { + .visible = true, + .named = false, + }, + [anon_sym_RBRACE] = { + .visible = true, + .named = false, + }, + [anon_sym_COLON] = { + .visible = true, + .named = false, + }, + [anon_sym_LBRACK] = { + .visible = true, + .named = false, + }, + [anon_sym_RBRACK] = { + .visible = true, + .named = false, + }, + [anon_sym_DQUOTE] = { + .visible = true, + .named = false, + }, + [aux_sym_string_content_token1] = { + .visible = false, + .named = false, + }, + [sym_escape_sequence] = { + .visible = true, + .named = true, + }, + [sym_number] = { + .visible = true, + .named = true, + }, + [sym_true] = { + .visible = true, + .named = true, + }, + [sym_false] = { + .visible = true, + .named = true, + }, + [sym_null] = { + .visible = true, + .named = true, + }, + [sym_comment] = { + .visible = true, + .named = true, + }, + [sym_document] = { + .visible = true, + .named = true, + }, + [sym__value] = { + .visible = false, + .named = true, + .supertype = true, + }, + [sym_object] = { + .visible = true, + .named = true, + }, + [sym_pair] = { + .visible = true, + .named = true, + }, + [sym_array] = { + .visible = true, + .named = true, + }, + [sym_string] = { + .visible = true, + .named = true, + }, + [sym_string_content] = { + .visible = true, + .named = true, + }, + [aux_sym_document_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_object_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_array_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_string_content_repeat1] = { + .visible = false, + .named = false, + }, +}; + +enum ts_field_identifiers { + field_key = 1, + field_value = 2, +}; + +static const char * const ts_field_names[] = { + [0] = NULL, + [field_key] = "key", + [field_value] = "value", +}; + +static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { + [1] = {.index = 0, .length = 2}, +}; + +static const TSFieldMapEntry ts_field_map_entries[] = { + [0] = + {field_key, 0}, + {field_value, 2}, +}; + +static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { + [0] = {0}, +}; + +static const uint16_t ts_non_terminal_alias_map[] = { + 0, +}; + +static const TSStateId ts_primary_state_ids[STATE_COUNT] = { + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 5, + [6] = 6, + [7] = 7, + [8] = 8, + [9] = 9, + [10] = 10, + [11] = 11, + [12] = 12, + [13] = 13, + [14] = 14, + [15] = 15, + [16] = 16, + [17] = 17, + [18] = 18, + [19] = 19, + [20] = 20, + [21] = 21, + [22] = 22, + [23] = 23, + [24] = 24, + [25] = 25, + [26] = 26, + [27] = 27, + [28] = 28, + [29] = 29, + [30] = 30, + [31] = 31, + [32] = 32, +}; + +static bool ts_lex(TSLexer *lexer, TSStateId state) { + START_LEXER(); + switch (state) { + case 0: + if (eof) ADVANCE(21); + if (lookahead == '"') ADVANCE(28); + if (lookahead == ',') ADVANCE(23); + if (lookahead == '-') ADVANCE(7); + if (lookahead == '/') ADVANCE(3); + if (lookahead == '0') ADVANCE(35); + if (lookahead == ':') ADVANCE(25); + if (lookahead == '[') ADVANCE(26); + if (lookahead == '\\') ADVANCE(18); + if (lookahead == ']') ADVANCE(27); + if (lookahead == 'f') ADVANCE(8); + if (lookahead == 'n') ADVANCE(17); + if (lookahead == 't') ADVANCE(14); + if (lookahead == '{') ADVANCE(22); + if (lookahead == '}') ADVANCE(24); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(20) + if (('1' <= lookahead && lookahead <= '9')) ADVANCE(36); + END_STATE(); + case 1: + if (lookahead == '\n') SKIP(2) + if (lookahead == '"') ADVANCE(28); + if (lookahead == '/') ADVANCE(29); + if (lookahead == '\\') ADVANCE(18); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') ADVANCE(32); + if (lookahead != 0) ADVANCE(33); + END_STATE(); + case 2: + if (lookahead == '"') ADVANCE(28); + if (lookahead == '/') ADVANCE(3); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(2) + END_STATE(); + case 3: + if (lookahead == '*') ADVANCE(5); + if (lookahead == '/') ADVANCE(43); + END_STATE(); + case 4: + if (lookahead == '*') ADVANCE(4); + if (lookahead == '/') ADVANCE(42); + if (lookahead != 0) ADVANCE(5); + END_STATE(); + case 5: + if (lookahead == '*') ADVANCE(4); + if (lookahead != 0) ADVANCE(5); + END_STATE(); + case 6: + if (lookahead == '-') ADVANCE(19); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(38); + END_STATE(); + case 7: + if (lookahead == '0') ADVANCE(35); + if (('1' <= lookahead && lookahead <= '9')) ADVANCE(36); + END_STATE(); + case 8: + if (lookahead == 'a') ADVANCE(11); + END_STATE(); + case 9: + if (lookahead == 'e') ADVANCE(39); + END_STATE(); + case 10: + if (lookahead == 'e') ADVANCE(40); + END_STATE(); + case 11: + if (lookahead == 'l') ADVANCE(15); + END_STATE(); + case 12: + if (lookahead == 'l') ADVANCE(41); + END_STATE(); + case 13: + if (lookahead == 'l') ADVANCE(12); + END_STATE(); + case 14: + if (lookahead == 'r') ADVANCE(16); + END_STATE(); + case 15: + if (lookahead == 's') ADVANCE(10); + END_STATE(); + case 16: + if (lookahead == 'u') ADVANCE(9); + END_STATE(); + case 17: + if (lookahead == 'u') ADVANCE(13); + END_STATE(); + case 18: + if (lookahead == '"' || + lookahead == '/' || + lookahead == '\\' || + lookahead == 'b' || + lookahead == 'f' || + lookahead == 'n' || + lookahead == 'r' || + lookahead == 't' || + lookahead == 'u') ADVANCE(34); + END_STATE(); + case 19: + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(38); + END_STATE(); + case 20: + if (eof) ADVANCE(21); + if (lookahead == '"') ADVANCE(28); + if (lookahead == ',') ADVANCE(23); + if (lookahead == '-') ADVANCE(7); + if (lookahead == '/') ADVANCE(3); + if (lookahead == '0') ADVANCE(35); + if (lookahead == ':') ADVANCE(25); + if (lookahead == '[') ADVANCE(26); + if (lookahead == ']') ADVANCE(27); + if (lookahead == 'f') ADVANCE(8); + if (lookahead == 'n') ADVANCE(17); + if (lookahead == 't') ADVANCE(14); + if (lookahead == '{') ADVANCE(22); + if (lookahead == '}') ADVANCE(24); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(20) + if (('1' <= lookahead && lookahead <= '9')) ADVANCE(36); + END_STATE(); + case 21: + ACCEPT_TOKEN(ts_builtin_sym_end); + END_STATE(); + case 22: + ACCEPT_TOKEN(anon_sym_LBRACE); + END_STATE(); + case 23: + ACCEPT_TOKEN(anon_sym_COMMA); + END_STATE(); + case 24: + ACCEPT_TOKEN(anon_sym_RBRACE); + END_STATE(); + case 25: + ACCEPT_TOKEN(anon_sym_COLON); + END_STATE(); + case 26: + ACCEPT_TOKEN(anon_sym_LBRACK); + END_STATE(); + case 27: + ACCEPT_TOKEN(anon_sym_RBRACK); + END_STATE(); + case 28: + ACCEPT_TOKEN(anon_sym_DQUOTE); + END_STATE(); + case 29: + ACCEPT_TOKEN(aux_sym_string_content_token1); + if (lookahead == '*') ADVANCE(31); + if (lookahead == '/') ADVANCE(33); + if (lookahead != 0 && + lookahead != '\n' && + lookahead != '"' && + lookahead != '\\') ADVANCE(33); + END_STATE(); + case 30: + ACCEPT_TOKEN(aux_sym_string_content_token1); + if (lookahead == '*') ADVANCE(30); + if (lookahead == '/') ADVANCE(33); + if (lookahead != 0 && + lookahead != '\n' && + lookahead != '"' && + lookahead != '\\') ADVANCE(31); + END_STATE(); + case 31: + ACCEPT_TOKEN(aux_sym_string_content_token1); + if (lookahead == '*') ADVANCE(30); + if (lookahead != 0 && + lookahead != '\n' && + lookahead != '"' && + lookahead != '\\') ADVANCE(31); + END_STATE(); + case 32: + ACCEPT_TOKEN(aux_sym_string_content_token1); + if (lookahead == '/') ADVANCE(29); + if (lookahead == '\t' || + (11 <= lookahead && lookahead <= '\r') || + lookahead == ' ') ADVANCE(32); + if (lookahead != 0 && + lookahead != '\n' && + lookahead != '"' && + lookahead != '\\') ADVANCE(33); + END_STATE(); + case 33: + ACCEPT_TOKEN(aux_sym_string_content_token1); + if (lookahead != 0 && + lookahead != '\n' && + lookahead != '"' && + lookahead != '\\') ADVANCE(33); + END_STATE(); + case 34: + ACCEPT_TOKEN(sym_escape_sequence); + END_STATE(); + case 35: + ACCEPT_TOKEN(sym_number); + if (lookahead == '.') ADVANCE(37); + if (lookahead == 'E' || + lookahead == 'e') ADVANCE(6); + END_STATE(); + case 36: + ACCEPT_TOKEN(sym_number); + if (lookahead == '.') ADVANCE(37); + if (lookahead == 'E' || + lookahead == 'e') ADVANCE(6); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(36); + END_STATE(); + case 37: + ACCEPT_TOKEN(sym_number); + if (lookahead == 'E' || + lookahead == 'e') ADVANCE(6); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(37); + END_STATE(); + case 38: + ACCEPT_TOKEN(sym_number); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(38); + END_STATE(); + case 39: + ACCEPT_TOKEN(sym_true); + END_STATE(); + case 40: + ACCEPT_TOKEN(sym_false); + END_STATE(); + case 41: + ACCEPT_TOKEN(sym_null); + END_STATE(); + case 42: + ACCEPT_TOKEN(sym_comment); + END_STATE(); + case 43: + ACCEPT_TOKEN(sym_comment); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(43); + END_STATE(); + default: + return false; + } +} + +static const TSLexMode ts_lex_modes[STATE_COUNT] = { + [0] = {.lex_state = 0}, + [1] = {.lex_state = 0}, + [2] = {.lex_state = 0}, + [3] = {.lex_state = 0}, + [4] = {.lex_state = 0}, + [5] = {.lex_state = 0}, + [6] = {.lex_state = 0}, + [7] = {.lex_state = 0}, + [8] = {.lex_state = 0}, + [9] = {.lex_state = 0}, + [10] = {.lex_state = 0}, + [11] = {.lex_state = 0}, + [12] = {.lex_state = 0}, + [13] = {.lex_state = 0}, + [14] = {.lex_state = 0}, + [15] = {.lex_state = 0}, + [16] = {.lex_state = 1}, + [17] = {.lex_state = 0}, + [18] = {.lex_state = 1}, + [19] = {.lex_state = 1}, + [20] = {.lex_state = 0}, + [21] = {.lex_state = 0}, + [22] = {.lex_state = 0}, + [23] = {.lex_state = 0}, + [24] = {.lex_state = 0}, + [25] = {.lex_state = 0}, + [26] = {.lex_state = 0}, + [27] = {.lex_state = 0}, + [28] = {.lex_state = 0}, + [29] = {.lex_state = 0}, + [30] = {.lex_state = 0}, + [31] = {.lex_state = 0}, + [32] = {.lex_state = 0}, +}; + +static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { + [0] = { + [ts_builtin_sym_end] = ACTIONS(1), + [anon_sym_LBRACE] = ACTIONS(1), + [anon_sym_COMMA] = ACTIONS(1), + [anon_sym_RBRACE] = ACTIONS(1), + [anon_sym_COLON] = ACTIONS(1), + [anon_sym_LBRACK] = ACTIONS(1), + [anon_sym_RBRACK] = ACTIONS(1), + [anon_sym_DQUOTE] = ACTIONS(1), + [sym_escape_sequence] = ACTIONS(1), + [sym_number] = ACTIONS(1), + [sym_true] = ACTIONS(1), + [sym_false] = ACTIONS(1), + [sym_null] = ACTIONS(1), + [sym_comment] = ACTIONS(3), + }, + [1] = { + [sym_document] = STATE(30), + [sym__value] = STATE(2), + [sym_object] = STATE(8), + [sym_array] = STATE(8), + [sym_string] = STATE(8), + [aux_sym_document_repeat1] = STATE(2), + [ts_builtin_sym_end] = ACTIONS(5), + [anon_sym_LBRACE] = ACTIONS(7), + [anon_sym_LBRACK] = ACTIONS(9), + [anon_sym_DQUOTE] = ACTIONS(11), + [sym_number] = ACTIONS(13), + [sym_true] = ACTIONS(13), + [sym_false] = ACTIONS(13), + [sym_null] = ACTIONS(13), + [sym_comment] = ACTIONS(3), + }, + [2] = { + [sym__value] = STATE(3), + [sym_object] = STATE(8), + [sym_array] = STATE(8), + [sym_string] = STATE(8), + [aux_sym_document_repeat1] = STATE(3), + [ts_builtin_sym_end] = ACTIONS(15), + [anon_sym_LBRACE] = ACTIONS(7), + [anon_sym_LBRACK] = ACTIONS(9), + [anon_sym_DQUOTE] = ACTIONS(11), + [sym_number] = ACTIONS(13), + [sym_true] = ACTIONS(13), + [sym_false] = ACTIONS(13), + [sym_null] = ACTIONS(13), + [sym_comment] = ACTIONS(3), + }, + [3] = { + [sym__value] = STATE(3), + [sym_object] = STATE(8), + [sym_array] = STATE(8), + [sym_string] = STATE(8), + [aux_sym_document_repeat1] = STATE(3), + [ts_builtin_sym_end] = ACTIONS(17), + [anon_sym_LBRACE] = ACTIONS(19), + [anon_sym_LBRACK] = ACTIONS(22), + [anon_sym_DQUOTE] = ACTIONS(25), + [sym_number] = ACTIONS(28), + [sym_true] = ACTIONS(28), + [sym_false] = ACTIONS(28), + [sym_null] = ACTIONS(28), + [sym_comment] = ACTIONS(3), + }, +}; + +static const uint16_t ts_small_parse_table[] = { + [0] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(31), 12, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [18] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(33), 12, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [36] = 8, + ACTIONS(3), 1, + sym_comment, + ACTIONS(7), 1, + anon_sym_LBRACE, + ACTIONS(9), 1, + anon_sym_LBRACK, + ACTIONS(11), 1, + anon_sym_DQUOTE, + ACTIONS(35), 1, + anon_sym_RBRACK, + STATE(21), 1, + sym__value, + STATE(8), 3, + sym_object, + sym_array, + sym_string, + ACTIONS(13), 4, + sym_number, + sym_true, + sym_false, + sym_null, + [66] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(37), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [83] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(39), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [100] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(41), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [117] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(43), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [134] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(45), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [151] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(47), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [168] = 7, + ACTIONS(3), 1, + sym_comment, + ACTIONS(7), 1, + anon_sym_LBRACE, + ACTIONS(9), 1, + anon_sym_LBRACK, + ACTIONS(11), 1, + anon_sym_DQUOTE, + STATE(27), 1, + sym__value, + STATE(8), 3, + sym_object, + sym_array, + sym_string, + ACTIONS(13), 4, + sym_number, + sym_true, + sym_false, + sym_null, + [195] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(49), 11, + ts_builtin_sym_end, + anon_sym_LBRACE, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_DQUOTE, + sym_number, + sym_true, + sym_false, + sym_null, + [212] = 7, + ACTIONS(3), 1, + sym_comment, + ACTIONS(7), 1, + anon_sym_LBRACE, + ACTIONS(9), 1, + anon_sym_LBRACK, + ACTIONS(11), 1, + anon_sym_DQUOTE, + STATE(29), 1, + sym__value, + STATE(8), 3, + sym_object, + sym_array, + sym_string, + ACTIONS(13), 4, + sym_number, + sym_true, + sym_false, + sym_null, + [239] = 5, + ACTIONS(51), 1, + anon_sym_DQUOTE, + ACTIONS(55), 1, + sym_comment, + STATE(19), 1, + aux_sym_string_content_repeat1, + STATE(31), 1, + sym_string_content, + ACTIONS(53), 2, + aux_sym_string_content_token1, + sym_escape_sequence, + [256] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + anon_sym_DQUOTE, + ACTIONS(57), 1, + anon_sym_RBRACE, + ACTIONS(59), 1, + sym_number, + STATE(24), 1, + sym_pair, + STATE(32), 1, + sym_string, + [275] = 4, + ACTIONS(55), 1, + sym_comment, + ACTIONS(61), 1, + anon_sym_DQUOTE, + STATE(18), 1, + aux_sym_string_content_repeat1, + ACTIONS(63), 2, + aux_sym_string_content_token1, + sym_escape_sequence, + [289] = 4, + ACTIONS(55), 1, + sym_comment, + ACTIONS(66), 1, + anon_sym_DQUOTE, + STATE(18), 1, + aux_sym_string_content_repeat1, + ACTIONS(68), 2, + aux_sym_string_content_token1, + sym_escape_sequence, + [303] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + anon_sym_DQUOTE, + ACTIONS(59), 1, + sym_number, + STATE(28), 1, + sym_pair, + STATE(32), 1, + sym_string, + [319] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(70), 1, + anon_sym_COMMA, + ACTIONS(72), 1, + anon_sym_RBRACK, + STATE(23), 1, + aux_sym_array_repeat1, + [332] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(74), 1, + anon_sym_COMMA, + ACTIONS(76), 1, + anon_sym_RBRACE, + STATE(25), 1, + aux_sym_object_repeat1, + [345] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(70), 1, + anon_sym_COMMA, + ACTIONS(78), 1, + anon_sym_RBRACK, + STATE(26), 1, + aux_sym_array_repeat1, + [358] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(74), 1, + anon_sym_COMMA, + ACTIONS(80), 1, + anon_sym_RBRACE, + STATE(22), 1, + aux_sym_object_repeat1, + [371] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(82), 1, + anon_sym_COMMA, + ACTIONS(85), 1, + anon_sym_RBRACE, + STATE(25), 1, + aux_sym_object_repeat1, + [384] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(87), 1, + anon_sym_COMMA, + ACTIONS(90), 1, + anon_sym_RBRACK, + STATE(26), 1, + aux_sym_array_repeat1, + [397] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(92), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [405] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(85), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [413] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(90), 2, + anon_sym_COMMA, + anon_sym_RBRACK, + [421] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(94), 1, + ts_builtin_sym_end, + [428] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(96), 1, + anon_sym_DQUOTE, + [435] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(98), 1, + anon_sym_COLON, +}; + +static const uint32_t ts_small_parse_table_map[] = { + [SMALL_STATE(4)] = 0, + [SMALL_STATE(5)] = 18, + [SMALL_STATE(6)] = 36, + [SMALL_STATE(7)] = 66, + [SMALL_STATE(8)] = 83, + [SMALL_STATE(9)] = 100, + [SMALL_STATE(10)] = 117, + [SMALL_STATE(11)] = 134, + [SMALL_STATE(12)] = 151, + [SMALL_STATE(13)] = 168, + [SMALL_STATE(14)] = 195, + [SMALL_STATE(15)] = 212, + [SMALL_STATE(16)] = 239, + [SMALL_STATE(17)] = 256, + [SMALL_STATE(18)] = 275, + [SMALL_STATE(19)] = 289, + [SMALL_STATE(20)] = 303, + [SMALL_STATE(21)] = 319, + [SMALL_STATE(22)] = 332, + [SMALL_STATE(23)] = 345, + [SMALL_STATE(24)] = 358, + [SMALL_STATE(25)] = 371, + [SMALL_STATE(26)] = 384, + [SMALL_STATE(27)] = 397, + [SMALL_STATE(28)] = 405, + [SMALL_STATE(29)] = 413, + [SMALL_STATE(30)] = 421, + [SMALL_STATE(31)] = 428, + [SMALL_STATE(32)] = 435, +}; + +static const TSParseActionEntry ts_parse_actions[] = { + [0] = {.entry = {.count = 0, .reusable = false}}, + [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), + [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), + [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 0), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), + [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), + [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1), + [17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), + [19] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(17), + [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(6), + [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(16), + [28] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(8), + [31] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3), + [33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2), + [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3), + [39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value, 1), + [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 4), + [43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 2), + [45] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 4), + [47] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2), + [49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 3), + [51] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5), + [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [55] = {.entry = {.count = 1, .reusable = false}}, SHIFT_EXTRA(), + [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [61] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_string_content_repeat1, 2), + [63] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_content_repeat1, 2), SHIFT_REPEAT(18), + [66] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string_content, 1), + [68] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), + [70] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [72] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [74] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), + [76] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), + [78] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [80] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), + [82] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2), SHIFT_REPEAT(20), + [85] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2), + [87] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(15), + [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), + [92] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 3, .production_id = 1), + [94] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [96] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [98] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), +}; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef _WIN32 +#define extern __declspec(dllexport) +#endif + +extern const TSLanguage *tree_sitter_json(void) { + static const TSLanguage language = { + .version = LANGUAGE_VERSION, + .symbol_count = SYMBOL_COUNT, + .alias_count = ALIAS_COUNT, + .token_count = TOKEN_COUNT, + .external_token_count = EXTERNAL_TOKEN_COUNT, + .state_count = STATE_COUNT, + .large_state_count = LARGE_STATE_COUNT, + .production_id_count = PRODUCTION_ID_COUNT, + .field_count = FIELD_COUNT, + .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, + .parse_table = &ts_parse_table[0][0], + .small_parse_table = ts_small_parse_table, + .small_parse_table_map = ts_small_parse_table_map, + .parse_actions = ts_parse_actions, + .symbol_names = ts_symbol_names, + .field_names = ts_field_names, + .field_map_slices = ts_field_map_slices, + .field_map_entries = ts_field_map_entries, + .symbol_metadata = ts_symbol_metadata, + .public_symbol_map = ts_symbol_map, + .alias_map = ts_non_terminal_alias_map, + .alias_sequences = &ts_alias_sequences[0][0], + .lex_modes = ts_lex_modes, + .lex_fn = ts_lex, + .primary_state_ids = ts_primary_state_ids, + }; + return &language; +} +#ifdef __cplusplus +} +#endif diff --git a/vendor/tree-sitter-json/src/tree_sitter/parser.h b/vendor/tree-sitter-json/src/tree_sitter/parser.h new file mode 100644 index 0000000..d210325 --- /dev/null +++ b/vendor/tree-sitter-json/src/tree_sitter/parser.h @@ -0,0 +1,224 @@ +#ifndef TREE_SITTER_PARSER_H_ +#define TREE_SITTER_PARSER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> + +#define ts_builtin_sym_error ((TSSymbol)-1) +#define ts_builtin_sym_end 0 +#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 + +#ifndef TREE_SITTER_API_H_ +typedef uint16_t TSStateId; +typedef uint16_t TSSymbol; +typedef uint16_t TSFieldId; +typedef struct TSLanguage TSLanguage; +#endif + +typedef struct { + TSFieldId field_id; + uint8_t child_index; + bool inherited; +} TSFieldMapEntry; + +typedef struct { + uint16_t index; + uint16_t length; +} TSFieldMapSlice; + +typedef struct { + bool visible; + bool named; + bool supertype; +} TSSymbolMetadata; + +typedef struct TSLexer TSLexer; + +struct TSLexer { + int32_t lookahead; + TSSymbol result_symbol; + void (*advance)(TSLexer *, bool); + void (*mark_end)(TSLexer *); + uint32_t (*get_column)(TSLexer *); + bool (*is_at_included_range_start)(const TSLexer *); + bool (*eof)(const TSLexer *); +}; + +typedef enum { + TSParseActionTypeShift, + TSParseActionTypeReduce, + TSParseActionTypeAccept, + TSParseActionTypeRecover, +} TSParseActionType; + +typedef union { + struct { + uint8_t type; + TSStateId state; + bool extra; + bool repetition; + } shift; + struct { + uint8_t type; + uint8_t child_count; + TSSymbol symbol; + int16_t dynamic_precedence; + uint16_t production_id; + } reduce; + uint8_t type; +} TSParseAction; + +typedef struct { + uint16_t lex_state; + uint16_t external_lex_state; +} TSLexMode; + +typedef union { + TSParseAction action; + struct { + uint8_t count; + bool reusable; + } entry; +} TSParseActionEntry; + +struct TSLanguage { + uint32_t version; + uint32_t symbol_count; + uint32_t alias_count; + uint32_t token_count; + uint32_t external_token_count; + uint32_t state_count; + uint32_t large_state_count; + uint32_t production_id_count; + uint32_t field_count; + uint16_t max_alias_sequence_length; + const uint16_t *parse_table; + const uint16_t *small_parse_table; + const uint32_t *small_parse_table_map; + const TSParseActionEntry *parse_actions; + const char * const *symbol_names; + const char * const *field_names; + const TSFieldMapSlice *field_map_slices; + const TSFieldMapEntry *field_map_entries; + const TSSymbolMetadata *symbol_metadata; + const TSSymbol *public_symbol_map; + const uint16_t *alias_map; + const TSSymbol *alias_sequences; + const TSLexMode *lex_modes; + bool (*lex_fn)(TSLexer *, TSStateId); + bool (*keyword_lex_fn)(TSLexer *, TSStateId); + TSSymbol keyword_capture_token; + struct { + const bool *states; + const TSSymbol *symbol_map; + void *(*create)(void); + void (*destroy)(void *); + bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); + unsigned (*serialize)(void *, char *); + void (*deserialize)(void *, const char *, unsigned); + } external_scanner; + const TSStateId *primary_state_ids; +}; + +/* + * Lexer Macros + */ + +#define START_LEXER() \ + bool result = false; \ + bool skip = false; \ + bool eof = false; \ + int32_t lookahead; \ + goto start; \ + next_state: \ + lexer->advance(lexer, skip); \ + start: \ + skip = false; \ + lookahead = lexer->lookahead; \ + eof = lexer->eof(lexer); + +#define ADVANCE(state_value) \ + { \ + state = state_value; \ + goto next_state; \ + } + +#define SKIP(state_value) \ + { \ + skip = true; \ + state = state_value; \ + goto next_state; \ + } + +#define ACCEPT_TOKEN(symbol_value) \ + result = true; \ + lexer->result_symbol = symbol_value; \ + lexer->mark_end(lexer); + +#define END_STATE() return result; + +/* + * Parse Table Macros + */ + +#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT) + +#define STATE(id) id + +#define ACTIONS(id) id + +#define SHIFT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = (state_value) \ + } \ + }} + +#define SHIFT_REPEAT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = (state_value), \ + .repetition = true \ + } \ + }} + +#define SHIFT_EXTRA() \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .extra = true \ + } \ + }} + +#define REDUCE(symbol_val, child_count_val, ...) \ + {{ \ + .reduce = { \ + .type = TSParseActionTypeReduce, \ + .symbol = symbol_val, \ + .child_count = child_count_val, \ + __VA_ARGS__ \ + }, \ + }} + +#define RECOVER() \ + {{ \ + .type = TSParseActionTypeRecover \ + }} + +#define ACCEPT_INPUT() \ + {{ \ + .type = TSParseActionTypeAccept \ + }} + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_PARSER_H_ |
