Merge commit '368736a6137770f785e1e7479a6be29417eb13aa'

pull/315/head
Wilfred Hughes 2022-07-10 23:08:16 +07:00
commit 40f82151f7
10 changed files with 574 additions and 332 deletions

@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-latest, ubuntu-latest, windows-2019]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2

@ -1,10 +1,10 @@
[package]
name = "tree-sitter-json"
description = "json grammar for the tree-sitter parsing library"
version = "0.19.0"
version = "0.20.0"
keywords = ["incremental", "parsing", "json"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-javascript"
repository = "https://github.com/tree-sitter/tree-sitter-json"
edition = "2018"
license = "MIT"
authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"]
@ -21,7 +21,7 @@ include = [
path = "bindings/rust/lib.rs"
[dependencies]
tree-sitter = "0.19"
tree-sitter = "0.20"
[build-dependencies]
cc = "1.0"

@ -34,8 +34,7 @@ pub fn language() -> Language {
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
// Uncomment these to include any queries that this grammar contains
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
pub const HIGHLIGHT_QUERY: &'static str = include_str!("../../queries/highlights.scm");
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");

@ -1,6 +1,6 @@
===================
================================================================================
Arrays
===================
================================================================================
[
345,
@ -13,56 +13,117 @@ Arrays
{ "stuff": "good" }
]
---
--------------------------------------------------------------------------------
(document (array
(number)
(number)
(number)
(number)
(null)
(true)
(false)
(object (pair (string (string_content)) (string (string_content))))))
(document
(array
(number)
(number)
(number)
(number)
(null)
(true)
(false)
(object
(pair
(string
(string_content))
(string
(string_content))))))
=====================
================================================================================
String content
=====================
================================================================================
[
"",
"abc",
"def\n",
"ghi\t",
"jkl\f"
"jkl\f",
"//",
"/**/"
]
----
--------------------------------------------------------------------------------
(document
(array
(string)
(string (string_content))
(string (string_content (escape_sequence)))
(string (string_content (escape_sequence)))
(string (string_content (escape_sequence)))))
(string
(string_content))
(string
(string_content
(escape_sequence)))
(string
(string_content
(escape_sequence)))
(string
(string_content
(escape_sequence)))
(string
(string_content))
(string
(string_content))))
================================
================================================================================
Top-level numbers
================================
================================================================================
-1
---
--------------------------------------------------------------------------------
(document (number))
(document
(number))
================================
================================================================================
Top-level null
================================
================================================================================
null
---
--------------------------------------------------------------------------------
(document
(null))
================================================================================
Comments
================================================================================
{
"a": 1,
// we allow comments, because several
// commonly used tools allow comments in
// files with the extension `.json`
"b": "2",
/*
* Block comments are also ok
*/
"c": 3
}
(document (null))
--------------------------------------------------------------------------------
(document
(object
(pair
(string
(string_content))
(number))
(comment)
(comment)
(comment)
(pair
(string
(string_content))
(string
(string_content)))
(comment)
(pair
(string
(string_content))
(number))))

@ -2,7 +2,8 @@ module.exports = grammar({
name: 'json',
extras: $ => [
/\s/
/\s/,
$.comment,
],
supertypes: $ => [
@ -42,7 +43,7 @@ module.exports = grammar({
),
string_content: $ => repeat1(choice(
token.immediate(/[^\\"\n]+/),
token.immediate(prec(1, /[^\\"\n]+/)),
$.escape_sequence
)),
@ -58,7 +59,7 @@ module.exports = grammar({
)
const decimal_digits = /\d+/
const signed_integer = seq(optional(choice('-','+')), decimal_digits)
const signed_integer = seq(optional(choice('-', '+')), decimal_digits)
const exponent_part = seq(choice('e', 'E'), signed_integer)
const binary_literal = seq(choice('0b', '0B'), /[0-1]+/)
@ -66,7 +67,7 @@ module.exports = grammar({
const octal_literal = seq(choice('0o', '0O'), /[0-7]+/)
const decimal_integer_literal = seq(
optional(choice('-','+')),
optional(choice('-', '+')),
choice(
'0',
seq(/[1-9]/, optional(decimal_digits))
@ -91,14 +92,23 @@ module.exports = grammar({
false: $ => "false",
null: $ => "null"
null: $ => "null",
comment: $ => token(choice(
seq('//', /.*/),
seq(
'/*',
/[^*]*\*+([^/*][^*]*\*+)*/,
'/'
)
)),
}
});
function commaSep1 (rule) {
function commaSep1(rule) {
return seq(rule, repeat(seq(",", rule)))
}
function commaSep (rule) {
function commaSep(rule) {
return optional(commaSep1(rule))
}

@ -1,6 +1,6 @@
{
"name": "tree-sitter-json",
"version": "0.19.0",
"version": "0.20.0",
"description": "JSON grammar for tree-sitter",
"main": "bindings/node",
"keywords": [

@ -1,9 +1,16 @@
(pair
key: (_) @keyword)
key: (_) @string.special.key)
(string) @string
(object
"{" @escape
(_)
"}" @escape)
(number) @number
[
(null)
(true)
(false)
] @constant.builtin
(escape_sequence) @escape
(comment) @comment

@ -207,8 +207,12 @@
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[^\\\\\"\\n]+"
"type": "PREC",
"value": 1,
"content": {
"type": "PATTERN",
"value": "[^\\\\\"\\n]+"
}
}
},
{
@ -643,12 +647,54 @@
"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": [],

@ -158,6 +158,10 @@
"type": "]",
"named": false
},
{
"type": "comment",
"named": true
},
{
"type": "escape_sequence",
"named": true

@ -7,10 +7,10 @@
#define LANGUAGE_VERSION 13
#define STATE_COUNT 32
#define LARGE_STATE_COUNT 2
#define SYMBOL_COUNT 24
#define LARGE_STATE_COUNT 3
#define SYMBOL_COUNT 25
#define ALIAS_COUNT 0
#define TOKEN_COUNT 14
#define TOKEN_COUNT 15
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 2
#define MAX_ALIAS_SEQUENCE_LENGTH 4
@ -30,16 +30,17 @@ enum {
sym_true = 11,
sym_false = 12,
sym_null = 13,
sym_document = 14,
sym__value = 15,
sym_object = 16,
sym_pair = 17,
sym_array = 18,
sym_string = 19,
sym_string_content = 20,
aux_sym_object_repeat1 = 21,
aux_sym_array_repeat1 = 22,
aux_sym_string_content_repeat1 = 23,
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_object_repeat1 = 22,
aux_sym_array_repeat1 = 23,
aux_sym_string_content_repeat1 = 24,
};
static const char * const ts_symbol_names[] = {
@ -57,6 +58,7 @@ static const char * const ts_symbol_names[] = {
[sym_true] = "true",
[sym_false] = "false",
[sym_null] = "null",
[sym_comment] = "comment",
[sym_document] = "document",
[sym__value] = "_value",
[sym_object] = "object",
@ -84,6 +86,7 @@ static const TSSymbol ts_symbol_map[] = {
[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,
@ -153,6 +156,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true,
.named = true,
},
[sym_comment] = {
.visible = true,
.named = true,
},
[sym_document] = {
.visible = true,
.named = true,
@ -230,91 +237,107 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
eof = lexer->eof(lexer);
switch (state) {
case 0:
if (eof) ADVANCE(22);
if (lookahead == '"') ADVANCE(29);
if (eof) ADVANCE(25);
if (lookahead == '"') ADVANCE(32);
if (lookahead == '+' ||
lookahead == '-') ADVANCE(3);
if (lookahead == ',') ADVANCE(24);
if (lookahead == '.') ADVANCE(18);
if (lookahead == '0') ADVANCE(33);
if (lookahead == ':') ADVANCE(26);
if (lookahead == '[') ADVANCE(27);
if (lookahead == '\\') ADVANCE(17);
if (lookahead == ']') ADVANCE(28);
if (lookahead == 'f') ADVANCE(4);
if (lookahead == 'n') ADVANCE(13);
if (lookahead == 't') ADVANCE(10);
if (lookahead == '{') ADVANCE(23);
if (lookahead == '}') ADVANCE(25);
lookahead == '-') ADVANCE(6);
if (lookahead == ',') ADVANCE(27);
if (lookahead == '.') ADVANCE(21);
if (lookahead == '/') ADVANCE(3);
if (lookahead == '0') ADVANCE(39);
if (lookahead == ':') ADVANCE(29);
if (lookahead == '[') ADVANCE(30);
if (lookahead == '\\') ADVANCE(20);
if (lookahead == ']') ADVANCE(31);
if (lookahead == 'f') ADVANCE(7);
if (lookahead == 'n') ADVANCE(16);
if (lookahead == 't') ADVANCE(13);
if (lookahead == '{') ADVANCE(26);
if (lookahead == '}') ADVANCE(28);
if (lookahead == '\t' ||
lookahead == '\n' ||
lookahead == '\r' ||
lookahead == ' ') SKIP(21)
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(35);
lookahead == ' ') SKIP(24)
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(41);
END_STATE();
case 1:
if (lookahead == '\n') SKIP(2)
if (lookahead == '"') ADVANCE(29);
if (lookahead == '\\') ADVANCE(17);
if (lookahead == '"') ADVANCE(32);
if (lookahead == '/') ADVANCE(33);
if (lookahead == '\\') ADVANCE(20);
if (lookahead == '\t' ||
lookahead == '\r' ||
lookahead == ' ') ADVANCE(30);
if (lookahead != 0) ADVANCE(31);
lookahead == ' ') ADVANCE(36);
if (lookahead != 0) ADVANCE(37);
END_STATE();
case 2:
if (lookahead == '"') ADVANCE(29);
if (lookahead == '"') ADVANCE(32);
if (lookahead == '/') ADVANCE(3);
if (lookahead == '\t' ||
lookahead == '\n' ||
lookahead == '\r' ||
lookahead == ' ') SKIP(2)
END_STATE();
case 3:
if (lookahead == '0') ADVANCE(34);
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(35);
if (lookahead == '*') ADVANCE(5);
if (lookahead == '/') ADVANCE(51);
END_STATE();
case 4:
if (lookahead == 'a') ADVANCE(7);
if (lookahead == '*') ADVANCE(4);
if (lookahead == '/') ADVANCE(50);
if (lookahead != 0) ADVANCE(5);
END_STATE();
case 5:
if (lookahead == 'e') ADVANCE(41);
if (lookahead == '*') ADVANCE(4);
if (lookahead != 0) ADVANCE(5);
END_STATE();
case 6:
if (lookahead == 'e') ADVANCE(42);
if (lookahead == '0') ADVANCE(40);
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(41);
END_STATE();
case 7:
if (lookahead == 'l') ADVANCE(11);
if (lookahead == 'a') ADVANCE(10);
END_STATE();
case 8:
if (lookahead == 'l') ADVANCE(43);
if (lookahead == 'e') ADVANCE(47);
END_STATE();
case 9:
if (lookahead == 'l') ADVANCE(8);
if (lookahead == 'e') ADVANCE(48);
END_STATE();
case 10:
if (lookahead == 'r') ADVANCE(12);
if (lookahead == 'l') ADVANCE(14);
END_STATE();
case 11:
if (lookahead == 's') ADVANCE(6);
if (lookahead == 'l') ADVANCE(49);
END_STATE();
case 12:
if (lookahead == 'u') ADVANCE(5);
if (lookahead == 'l') ADVANCE(11);
END_STATE();
case 13:
if (lookahead == 'u') ADVANCE(9);
if (lookahead == 'r') ADVANCE(15);
END_STATE();
case 14:
if (lookahead == '+' ||
lookahead == '-') ADVANCE(19);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(39);
if (lookahead == 's') ADVANCE(9);
END_STATE();
case 15:
if (lookahead == '0' ||
lookahead == '1') ADVANCE(37);
if (lookahead == 'u') ADVANCE(8);
END_STATE();
case 16:
if (('0' <= lookahead && lookahead <= '7')) ADVANCE(38);
if (lookahead == 'u') ADVANCE(12);
END_STATE();
case 17:
if (lookahead == '+' ||
lookahead == '-') ADVANCE(22);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(45);
END_STATE();
case 18:
if (lookahead == '0' ||
lookahead == '1') ADVANCE(43);
END_STATE();
case 19:
if (('0' <= lookahead && lookahead <= '7')) ADVANCE(44);
END_STATE();
case 20:
if (lookahead == '"' ||
lookahead == '/' ||
lookahead == '\\' ||
@ -323,144 +346,180 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
lookahead == 'n' ||
lookahead == 'r' ||
lookahead == 't' ||
lookahead == 'u') ADVANCE(32);
lookahead == 'u') ADVANCE(38);
END_STATE();
case 18:
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(36);
case 21:
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(42);
END_STATE();
case 19:
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(39);
case 22:
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(45);
END_STATE();
case 20:
case 23:
if (('0' <= lookahead && lookahead <= '9') ||
('A' <= lookahead && lookahead <= 'F') ||
('a' <= lookahead && lookahead <= 'f')) ADVANCE(40);
('a' <= lookahead && lookahead <= 'f')) ADVANCE(46);
END_STATE();
case 21:
if (eof) ADVANCE(22);
if (lookahead == '"') ADVANCE(29);
case 24:
if (eof) ADVANCE(25);
if (lookahead == '"') ADVANCE(32);
if (lookahead == '+' ||
lookahead == '-') ADVANCE(3);
if (lookahead == ',') ADVANCE(24);
if (lookahead == '.') ADVANCE(18);
if (lookahead == '0') ADVANCE(33);
if (lookahead == ':') ADVANCE(26);
if (lookahead == '[') ADVANCE(27);
if (lookahead == ']') ADVANCE(28);
if (lookahead == 'f') ADVANCE(4);
if (lookahead == 'n') ADVANCE(13);
if (lookahead == 't') ADVANCE(10);
if (lookahead == '{') ADVANCE(23);
if (lookahead == '}') ADVANCE(25);
lookahead == '-') ADVANCE(6);
if (lookahead == ',') ADVANCE(27);
if (lookahead == '.') ADVANCE(21);
if (lookahead == '/') ADVANCE(3);
if (lookahead == '0') ADVANCE(39);
if (lookahead == ':') ADVANCE(29);
if (lookahead == '[') ADVANCE(30);
if (lookahead == ']') ADVANCE(31);
if (lookahead == 'f') ADVANCE(7);
if (lookahead == 'n') ADVANCE(16);
if (lookahead == 't') ADVANCE(13);
if (lookahead == '{') ADVANCE(26);
if (lookahead == '}') ADVANCE(28);
if (lookahead == '\t' ||
lookahead == '\n' ||
lookahead == '\r' ||
lookahead == ' ') SKIP(21)
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(35);
lookahead == ' ') SKIP(24)
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(41);
END_STATE();
case 22:
case 25:
ACCEPT_TOKEN(ts_builtin_sym_end);
END_STATE();
case 23:
case 26:
ACCEPT_TOKEN(anon_sym_LBRACE);
END_STATE();
case 24:
case 27:
ACCEPT_TOKEN(anon_sym_COMMA);
END_STATE();
case 25:
case 28:
ACCEPT_TOKEN(anon_sym_RBRACE);
END_STATE();
case 26:
case 29:
ACCEPT_TOKEN(anon_sym_COLON);
END_STATE();
case 27:
case 30:
ACCEPT_TOKEN(anon_sym_LBRACK);
END_STATE();
case 28:
case 31:
ACCEPT_TOKEN(anon_sym_RBRACK);
END_STATE();
case 29:
case 32:
ACCEPT_TOKEN(anon_sym_DQUOTE);
END_STATE();
case 30:
case 33:
ACCEPT_TOKEN(aux_sym_string_content_token1);
if (lookahead == '*') ADVANCE(35);
if (lookahead == '/') ADVANCE(37);
if (lookahead != 0 &&
lookahead != '\n' &&
lookahead != '"' &&
lookahead != '\\') ADVANCE(37);
END_STATE();
case 34:
ACCEPT_TOKEN(aux_sym_string_content_token1);
if (lookahead == '*') ADVANCE(34);
if (lookahead == '/') ADVANCE(37);
if (lookahead != 0 &&
lookahead != '\n' &&
lookahead != '"' &&
lookahead != '\\') ADVANCE(35);
END_STATE();
case 35:
ACCEPT_TOKEN(aux_sym_string_content_token1);
if (lookahead == '*') ADVANCE(34);
if (lookahead != 0 &&
lookahead != '\n' &&
lookahead != '"' &&
lookahead != '\\') ADVANCE(35);
END_STATE();
case 36:
ACCEPT_TOKEN(aux_sym_string_content_token1);
if (lookahead == '/') ADVANCE(33);
if (lookahead == '\t' ||
lookahead == '\r' ||
lookahead == ' ') ADVANCE(30);
lookahead == ' ') ADVANCE(36);
if (lookahead != 0 &&
lookahead != '\n' &&
lookahead != '"' &&
lookahead != '\\') ADVANCE(31);
lookahead != '\\') ADVANCE(37);
END_STATE();
case 31:
case 37:
ACCEPT_TOKEN(aux_sym_string_content_token1);
if (lookahead != 0 &&
lookahead != '\n' &&
lookahead != '"' &&
lookahead != '\\') ADVANCE(31);
lookahead != '\\') ADVANCE(37);
END_STATE();
case 32:
case 38:
ACCEPT_TOKEN(sym_escape_sequence);
END_STATE();
case 33:
case 39:
ACCEPT_TOKEN(sym_number);
if (lookahead == '.') ADVANCE(36);
if (lookahead == '.') ADVANCE(42);
if (lookahead == 'B' ||
lookahead == 'b') ADVANCE(15);
lookahead == 'b') ADVANCE(18);
if (lookahead == 'E' ||
lookahead == 'e') ADVANCE(14);
lookahead == 'e') ADVANCE(17);
if (lookahead == 'O' ||
lookahead == 'o') ADVANCE(16);
lookahead == 'o') ADVANCE(19);
if (lookahead == 'X' ||
lookahead == 'x') ADVANCE(20);
lookahead == 'x') ADVANCE(23);
END_STATE();
case 34:
case 40:
ACCEPT_TOKEN(sym_number);
if (lookahead == '.') ADVANCE(36);
if (lookahead == '.') ADVANCE(42);
if (lookahead == 'E' ||
lookahead == 'e') ADVANCE(14);
lookahead == 'e') ADVANCE(17);
END_STATE();
case 35:
case 41:
ACCEPT_TOKEN(sym_number);
if (lookahead == '.') ADVANCE(36);
if (lookahead == '.') ADVANCE(42);
if (lookahead == 'E' ||
lookahead == 'e') ADVANCE(14);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(35);
lookahead == 'e') ADVANCE(17);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(41);
END_STATE();
case 36:
case 42:
ACCEPT_TOKEN(sym_number);
if (lookahead == 'E' ||
lookahead == 'e') ADVANCE(14);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(36);
lookahead == 'e') ADVANCE(17);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(42);
END_STATE();
case 37:
case 43:
ACCEPT_TOKEN(sym_number);
if (lookahead == '0' ||
lookahead == '1') ADVANCE(37);
lookahead == '1') ADVANCE(43);
END_STATE();
case 38:
case 44:
ACCEPT_TOKEN(sym_number);
if (('0' <= lookahead && lookahead <= '7')) ADVANCE(38);
if (('0' <= lookahead && lookahead <= '7')) ADVANCE(44);
END_STATE();
case 39:
case 45:
ACCEPT_TOKEN(sym_number);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(39);
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(45);
END_STATE();
case 40:
case 46:
ACCEPT_TOKEN(sym_number);
if (('0' <= lookahead && lookahead <= '9') ||
('A' <= lookahead && lookahead <= 'F') ||
('a' <= lookahead && lookahead <= 'f')) ADVANCE(40);
('a' <= lookahead && lookahead <= 'f')) ADVANCE(46);
END_STATE();
case 41:
case 47:
ACCEPT_TOKEN(sym_true);
END_STATE();
case 42:
case 48:
ACCEPT_TOKEN(sym_false);
END_STATE();
case 43:
case 49:
ACCEPT_TOKEN(sym_null);
END_STATE();
case 50:
ACCEPT_TOKEN(sym_comment);
END_STATE();
case 51:
ACCEPT_TOKEN(sym_comment);
if (lookahead != 0 &&
lookahead != '\n') ADVANCE(51);
END_STATE();
default:
return false;
}
@ -516,6 +575,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_true] = ACTIONS(1),
[sym_false] = ACTIONS(1),
[sym_null] = ACTIONS(1),
[sym_comment] = ACTIONS(3),
},
[1] = {
[sym_document] = STATE(28),
@ -523,43 +583,41 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_object] = STATE(12),
[sym_array] = STATE(12),
[sym_string] = STATE(12),
[anon_sym_LBRACE] = ACTIONS(3),
[anon_sym_LBRACK] = ACTIONS(5),
[anon_sym_DQUOTE] = ACTIONS(7),
[sym_number] = ACTIONS(9),
[sym_true] = ACTIONS(9),
[sym_false] = ACTIONS(9),
[sym_null] = ACTIONS(9),
[anon_sym_LBRACE] = ACTIONS(5),
[anon_sym_LBRACK] = ACTIONS(7),
[anon_sym_DQUOTE] = ACTIONS(9),
[sym_number] = ACTIONS(11),
[sym_true] = ACTIONS(11),
[sym_false] = ACTIONS(11),
[sym_null] = ACTIONS(11),
[sym_comment] = ACTIONS(3),
},
[2] = {
[sym__value] = STATE(21),
[sym_object] = STATE(12),
[sym_array] = STATE(12),
[sym_string] = STATE(12),
[anon_sym_LBRACE] = ACTIONS(5),
[anon_sym_LBRACK] = ACTIONS(7),
[anon_sym_RBRACK] = ACTIONS(13),
[anon_sym_DQUOTE] = ACTIONS(9),
[sym_number] = ACTIONS(11),
[sym_true] = ACTIONS(11),
[sym_false] = ACTIONS(11),
[sym_null] = ACTIONS(11),
[sym_comment] = ACTIONS(3),
},
};
static const uint16_t ts_small_parse_table[] = {
[0] = 7,
ACTIONS(3), 1,
anon_sym_LBRACE,
sym_comment,
ACTIONS(5), 1,
anon_sym_LBRACK,
ACTIONS(7), 1,
anon_sym_DQUOTE,
ACTIONS(11), 1,
anon_sym_RBRACK,
STATE(21), 1,
sym__value,
STATE(12), 3,
sym_object,
sym_array,
sym_string,
ACTIONS(9), 4,
sym_number,
sym_true,
sym_false,
sym_null,
[27] = 6,
ACTIONS(3), 1,
anon_sym_LBRACE,
ACTIONS(5), 1,
anon_sym_LBRACK,
ACTIONS(7), 1,
anon_sym_LBRACK,
ACTIONS(9), 1,
anon_sym_DQUOTE,
STATE(27), 1,
sym__value,
@ -567,17 +625,19 @@ static const uint16_t ts_small_parse_table[] = {
sym_object,
sym_array,
sym_string,
ACTIONS(9), 4,
ACTIONS(11), 4,
sym_number,
sym_true,
sym_false,
sym_null,
[51] = 6,
[27] = 7,
ACTIONS(3), 1,
anon_sym_LBRACE,
sym_comment,
ACTIONS(5), 1,
anon_sym_LBRACK,
anon_sym_LBRACE,
ACTIONS(7), 1,
anon_sym_LBRACK,
ACTIONS(9), 1,
anon_sym_DQUOTE,
STATE(25), 1,
sym__value,
@ -585,254 +645,309 @@ static const uint16_t ts_small_parse_table[] = {
sym_object,
sym_array,
sym_string,
ACTIONS(9), 4,
ACTIONS(11), 4,
sym_number,
sym_true,
sym_false,
sym_null,
[75] = 1,
ACTIONS(13), 5,
[54] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(15), 5,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_COLON,
anon_sym_RBRACK,
[83] = 5,
ACTIONS(7), 1,
[65] = 6,
ACTIONS(3), 1,
sym_comment,
ACTIONS(9), 1,
anon_sym_DQUOTE,
ACTIONS(15), 1,
anon_sym_RBRACE,
ACTIONS(17), 1,
anon_sym_RBRACE,
ACTIONS(19), 1,
sym_number,
STATE(20), 1,
sym_pair,
STATE(29), 1,
sym_string,
[99] = 4,
ACTIONS(19), 1,
[84] = 5,
ACTIONS(21), 1,
anon_sym_DQUOTE,
ACTIONS(25), 1,
sym_comment,
STATE(11), 1,
aux_sym_string_content_repeat1,
STATE(30), 1,
sym_string_content,
ACTIONS(21), 2,
ACTIONS(23), 2,
aux_sym_string_content_token1,
sym_escape_sequence,
[113] = 1,
ACTIONS(23), 5,
[101] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(27), 5,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_COLON,
anon_sym_RBRACK,
[121] = 1,
ACTIONS(25), 4,
[112] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(29), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[128] = 1,
ACTIONS(27), 4,
[122] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(31), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[135] = 3,
ACTIONS(29), 1,
[132] = 4,
ACTIONS(25), 1,
sym_comment,
ACTIONS(33), 1,
anon_sym_DQUOTE,
STATE(17), 1,
aux_sym_string_content_repeat1,
ACTIONS(31), 2,
ACTIONS(35), 2,
aux_sym_string_content_token1,
sym_escape_sequence,
[146] = 1,
ACTIONS(33), 4,
[146] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(37), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[153] = 4,
ACTIONS(7), 1,
[156] = 5,
ACTIONS(3), 1,
sym_comment,
ACTIONS(9), 1,
anon_sym_DQUOTE,
ACTIONS(17), 1,
ACTIONS(19), 1,
sym_number,
STATE(26), 1,
sym_pair,
STATE(29), 1,
sym_string,
[166] = 1,
ACTIONS(35), 4,
[172] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(39), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[173] = 1,
ACTIONS(37), 4,
[182] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(41), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[180] = 1,
ACTIONS(39), 4,
[192] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(43), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[187] = 3,
ACTIONS(41), 1,
[202] = 4,
ACTIONS(25), 1,
sym_comment,
ACTIONS(45), 1,
anon_sym_DQUOTE,
STATE(17), 1,
aux_sym_string_content_repeat1,
ACTIONS(43), 2,
ACTIONS(47), 2,
aux_sym_string_content_token1,
sym_escape_sequence,
[198] = 1,
ACTIONS(46), 4,
[216] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(50), 4,
ts_builtin_sym_end,
anon_sym_COMMA,
anon_sym_RBRACE,
anon_sym_RBRACK,
[205] = 3,
ACTIONS(48), 1,
[226] = 4,
ACTIONS(3), 1,
sym_comment,
ACTIONS(52), 1,
anon_sym_COMMA,
ACTIONS(51), 1,
ACTIONS(55), 1,
anon_sym_RBRACE,
STATE(19), 1,
aux_sym_object_repeat1,
[215] = 3,
ACTIONS(53), 1,
[239] = 4,
ACTIONS(3), 1,
sym_comment,
ACTIONS(57), 1,
anon_sym_COMMA,
ACTIONS(55), 1,
ACTIONS(59), 1,
anon_sym_RBRACE,
STATE(23), 1,
aux_sym_object_repeat1,
[225] = 3,
ACTIONS(57), 1,
[252] = 4,
ACTIONS(3), 1,
sym_comment,
ACTIONS(61), 1,
anon_sym_COMMA,
ACTIONS(59), 1,
ACTIONS(63), 1,
anon_sym_RBRACK,
STATE(24), 1,
aux_sym_array_repeat1,
[235] = 3,
ACTIONS(61), 1,
[265] = 4,
ACTIONS(3), 1,
sym_comment,
ACTIONS(65), 1,
anon_sym_COMMA,
ACTIONS(64), 1,
ACTIONS(68), 1,
anon_sym_RBRACK,
STATE(22), 1,
aux_sym_array_repeat1,
[245] = 3,
ACTIONS(53), 1,
[278] = 4,
ACTIONS(3), 1,
sym_comment,
ACTIONS(57), 1,
anon_sym_COMMA,
ACTIONS(66), 1,
ACTIONS(70), 1,
anon_sym_RBRACE,
STATE(19), 1,
aux_sym_object_repeat1,
[255] = 3,
ACTIONS(57), 1,
[291] = 4,
ACTIONS(3), 1,
sym_comment,
ACTIONS(61), 1,
anon_sym_COMMA,
ACTIONS(68), 1,
ACTIONS(72), 1,
anon_sym_RBRACK,
STATE(22), 1,
aux_sym_array_repeat1,
[265] = 1,
ACTIONS(70), 2,
[304] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(74), 2,
anon_sym_COMMA,
anon_sym_RBRACE,
[270] = 1,
ACTIONS(51), 2,
[312] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(55), 2,
anon_sym_COMMA,
anon_sym_RBRACE,
[275] = 1,
ACTIONS(64), 2,
[320] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(68), 2,
anon_sym_COMMA,
anon_sym_RBRACK,
[280] = 1,
ACTIONS(72), 1,
[328] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(76), 1,
ts_builtin_sym_end,
[284] = 1,
ACTIONS(74), 1,
[335] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(78), 1,
anon_sym_COLON,
[288] = 1,
ACTIONS(76), 1,
[342] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(80), 1,
anon_sym_DQUOTE,
[292] = 1,
ACTIONS(78), 1,
[349] = 2,
ACTIONS(3), 1,
sym_comment,
ACTIONS(82), 1,
ts_builtin_sym_end,
};
static const uint32_t ts_small_parse_table_map[] = {
[SMALL_STATE(2)] = 0,
[SMALL_STATE(3)] = 27,
[SMALL_STATE(4)] = 51,
[SMALL_STATE(5)] = 75,
[SMALL_STATE(6)] = 83,
[SMALL_STATE(7)] = 99,
[SMALL_STATE(8)] = 113,
[SMALL_STATE(9)] = 121,
[SMALL_STATE(10)] = 128,
[SMALL_STATE(11)] = 135,
[SMALL_STATE(3)] = 0,
[SMALL_STATE(4)] = 27,
[SMALL_STATE(5)] = 54,
[SMALL_STATE(6)] = 65,
[SMALL_STATE(7)] = 84,
[SMALL_STATE(8)] = 101,
[SMALL_STATE(9)] = 112,
[SMALL_STATE(10)] = 122,
[SMALL_STATE(11)] = 132,
[SMALL_STATE(12)] = 146,
[SMALL_STATE(13)] = 153,
[SMALL_STATE(14)] = 166,
[SMALL_STATE(15)] = 173,
[SMALL_STATE(16)] = 180,
[SMALL_STATE(17)] = 187,
[SMALL_STATE(18)] = 198,
[SMALL_STATE(19)] = 205,
[SMALL_STATE(20)] = 215,
[SMALL_STATE(21)] = 225,
[SMALL_STATE(22)] = 235,
[SMALL_STATE(23)] = 245,
[SMALL_STATE(24)] = 255,
[SMALL_STATE(25)] = 265,
[SMALL_STATE(26)] = 270,
[SMALL_STATE(27)] = 275,
[SMALL_STATE(28)] = 280,
[SMALL_STATE(29)] = 284,
[SMALL_STATE(30)] = 288,
[SMALL_STATE(31)] = 292,
[SMALL_STATE(13)] = 156,
[SMALL_STATE(14)] = 172,
[SMALL_STATE(15)] = 182,
[SMALL_STATE(16)] = 192,
[SMALL_STATE(17)] = 202,
[SMALL_STATE(18)] = 216,
[SMALL_STATE(19)] = 226,
[SMALL_STATE(20)] = 239,
[SMALL_STATE(21)] = 252,
[SMALL_STATE(22)] = 265,
[SMALL_STATE(23)] = 278,
[SMALL_STATE(24)] = 291,
[SMALL_STATE(25)] = 304,
[SMALL_STATE(26)] = 312,
[SMALL_STATE(27)] = 320,
[SMALL_STATE(28)] = 328,
[SMALL_STATE(29)] = 335,
[SMALL_STATE(30)] = 342,
[SMALL_STATE(31)] = 349,
};
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(6),
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
[7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),
[9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12),
[11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10),
[13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2),
[15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9),
[17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29),
[19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5),
[21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11),
[23] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3),
[25] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 2),
[27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2),
[29] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string_content, 1),
[31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17),
[33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value, 1),
[35] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 3),
[37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 4),
[39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3),
[41] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_string_content_repeat1, 2),
[43] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_content_repeat1, 2), SHIFT_REPEAT(17),
[46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 4),
[48] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2), SHIFT_REPEAT(13),
[51] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2),
[53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13),
[55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14),
[57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),
[59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16),
[61] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(3),
[64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2),
[66] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18),
[68] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15),
[70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 3, .production_id = 1),
[72] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
[74] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
[76] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8),
[78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1),
[3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6),
[7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
[9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),
[11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12),
[13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10),
[15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2),
[17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9),
[19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29),
[21] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5),
[23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11),
[25] = {.entry = {.count = 1, .reusable = false}}, SHIFT_EXTRA(),
[27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3),
[29] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 2),
[31] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2),
[33] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string_content, 1),
[35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17),
[37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value, 1),
[39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 3),
[41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 4),
[43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3),
[45] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_string_content_repeat1, 2),
[47] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_content_repeat1, 2), SHIFT_REPEAT(17),
[50] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 4),
[52] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2), SHIFT_REPEAT(13),
[55] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2),
[57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13),
[59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14),
[61] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),
[63] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16),
[65] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(3),
[68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2),
[70] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18),
[72] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15),
[74] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 3, .production_id = 1),
[76] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
[78] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
[80] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8),
[82] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1),
};
#ifdef __cplusplus