Merge commit '203e239408d642be83edde8988d6e7b20a19f0e8'

pull/70/head
Wilfred Hughes 2021-11-19 23:56:23 +07:00
commit 153cc5eeca
6 changed files with 32 additions and 29 deletions

@ -2,7 +2,7 @@
### Parsing
Updated C parser to latest upstream version.
Updated C and JSON parsers to the latest upstream versions.
No changes.

@ -33,7 +33,8 @@ String content
"",
"abc",
"def\n",
"ghi\t"
"ghi\t",
"jkl\f"
]
----
@ -43,6 +44,7 @@ String content
(string)
(string (string_content))
(string (string_content (escape_sequence)))
(string (string_content (escape_sequence)))
(string (string_content (escape_sequence)))))
================================

@ -48,7 +48,7 @@ module.exports = grammar({
escape_sequence: $ => token.immediate(seq(
'\\',
/(\"|\\|\/|b|n|r|t|u)/
/(\"|\\|\/|b|f|n|r|t|u)/
)),
number: $ => {

@ -229,7 +229,7 @@
},
{
"type": "PATTERN",
"value": "(\\\"|\\\\|\\/|b|n|r|t|u)"
"value": "(\\\"|\\\\|\\/|b|f|n|r|t|u)"
}
]
}

@ -42,7 +42,7 @@ enum {
aux_sym_string_content_repeat1 = 23,
};
static const char *ts_symbol_names[] = {
static const char * const ts_symbol_names[] = {
[ts_builtin_sym_end] = "end",
[anon_sym_LBRACE] = "{",
[anon_sym_COMMA] = ",",
@ -69,7 +69,7 @@ static const char *ts_symbol_names[] = {
[aux_sym_string_content_repeat1] = "string_content_repeat1",
};
static TSSymbol ts_symbol_map[] = {
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,
@ -201,7 +201,7 @@ enum {
field_value = 2,
};
static const char *ts_field_names[] = {
static const char * const ts_field_names[] = {
[0] = NULL,
[field_key] = "key",
[field_value] = "value",
@ -217,11 +217,11 @@ static const TSFieldMapEntry ts_field_map_entries[] = {
{field_value, 2},
};
static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
[0] = {0},
};
static uint16_t ts_non_terminal_alias_map[] = {
static const uint16_t ts_non_terminal_alias_map[] = {
0,
};
@ -239,7 +239,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
if (lookahead == '0') ADVANCE(33);
if (lookahead == ':') ADVANCE(26);
if (lookahead == '[') ADVANCE(27);
if (lookahead == '\\') ADVANCE(16);
if (lookahead == '\\') ADVANCE(17);
if (lookahead == ']') ADVANCE(28);
if (lookahead == 'f') ADVANCE(4);
if (lookahead == 'n') ADVANCE(13);
@ -255,7 +255,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
case 1:
if (lookahead == '\n') SKIP(2)
if (lookahead == '"') ADVANCE(29);
if (lookahead == '\\') ADVANCE(16);
if (lookahead == '\\') ADVANCE(17);
if (lookahead == '\t' ||
lookahead == '\r' ||
lookahead == ' ') ADVANCE(30);
@ -312,18 +312,19 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
lookahead == '1') ADVANCE(37);
END_STATE();
case 16:
if (('0' <= lookahead && lookahead <= '7')) ADVANCE(38);
END_STATE();
case 17:
if (lookahead == '"' ||
lookahead == '/' ||
lookahead == '\\' ||
lookahead == 'b' ||
lookahead == 'f' ||
lookahead == 'n' ||
lookahead == 'r' ||
lookahead == 't' ||
lookahead == 'u') ADVANCE(32);
END_STATE();
case 17:
if (('0' <= lookahead && lookahead <= '7')) ADVANCE(38);
END_STATE();
case 18:
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(36);
END_STATE();
@ -409,7 +410,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
if (lookahead == 'E' ||
lookahead == 'e') ADVANCE(14);
if (lookahead == 'O' ||
lookahead == 'o') ADVANCE(17);
lookahead == 'o') ADVANCE(16);
if (lookahead == 'X' ||
lookahead == 'x') ADVANCE(20);
END_STATE();
@ -465,7 +466,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
}
}
static TSLexMode ts_lex_modes[STATE_COUNT] = {
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
[0] = {.lex_state = 0},
[1] = {.lex_state = 0},
[2] = {.lex_state = 0},
@ -500,7 +501,7 @@ static TSLexMode ts_lex_modes[STATE_COUNT] = {
[31] = {.lex_state = 0},
};
static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[0] = {
[ts_builtin_sym_end] = ACTIONS(1),
[anon_sym_LBRACE] = ACTIONS(1),
@ -532,7 +533,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
},
};
static uint16_t ts_small_parse_table[] = {
static const uint16_t ts_small_parse_table[] = {
[0] = 7,
ACTIONS(3), 1,
anon_sym_LBRACE,
@ -759,7 +760,7 @@ static uint16_t ts_small_parse_table[] = {
ts_builtin_sym_end,
};
static uint32_t ts_small_parse_table_map[] = {
static const uint32_t ts_small_parse_table_map[] = {
[SMALL_STATE(2)] = 0,
[SMALL_STATE(3)] = 27,
[SMALL_STATE(4)] = 51,
@ -792,7 +793,7 @@ static uint32_t ts_small_parse_table_map[] = {
[SMALL_STATE(31)] = 292,
};
static TSParseActionEntry ts_parse_actions[] = {
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),
@ -842,7 +843,7 @@ extern "C" {
#endif
extern const TSLanguage *tree_sitter_json(void) {
static TSLanguage language = {
static const TSLanguage language = {
.version = LANGUAGE_VERSION,
.symbol_count = SYMBOL_COUNT,
.alias_count = ALIAS_COUNT,
@ -853,18 +854,18 @@ extern const TSLanguage *tree_sitter_json(void) {
.production_id_count = PRODUCTION_ID_COUNT,
.field_count = FIELD_COUNT,
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
.parse_table = (const uint16_t *)ts_parse_table,
.small_parse_table = (const uint16_t *)ts_small_parse_table,
.small_parse_table_map = (const uint32_t *)ts_small_parse_table_map,
.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 = (const TSFieldMapSlice *)ts_field_map_slices,
.field_map_entries = (const TSFieldMapEntry *)ts_field_map_entries,
.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 = (const TSSymbol *)ts_alias_sequences,
.alias_sequences = &ts_alias_sequences[0][0],
.lex_modes = ts_lex_modes,
.lex_fn = ts_lex,
};

@ -102,8 +102,8 @@ struct TSLanguage {
const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map;
const TSParseActionEntry *parse_actions;
const char **symbol_names;
const char **field_names;
const char * const *symbol_names;
const char * const *field_names;
const TSFieldMapSlice *field_map_slices;
const TSFieldMapEntry *field_map_entries;
const TSSymbolMetadata *symbol_metadata;