diff --git a/grammar.js b/grammar.js index 4806320..9bf29b3 100644 --- a/grammar.js +++ b/grammar.js @@ -2,80 +2,58 @@ module.exports = grammar({ name: 'norg_meta', rules: { - metadata: $ => repeat( - choice( - $.pair, - $.delimiter - ) - ), - - pair: $ => seq( - $._key, - token.immediate(/[ \t\v]*/), - choice( - $.value, - $.object, - $.array, - token.immediate('\n'), - ), - ), + metadata: $ => repeat(choice( + $.pair, + $.delimiter, + )), - key: $ => /[^\s:]+/, - - _key: $ => seq( - $.key, - $._separator - ), + key: _ => /[^\-\s:][^\s:]*/, value: $ => seq( + /[^\s\[\]\{\}][^\n\[\]\{\}(\~\n)]*/, optional( - repeat($._text_with_trailing_modifier) - ), - $._text_till_eol - ), - - object: $ => seq( - "{", - repeat( - $.pair, - ), - "}", + seq( + "~\n", + alias($.value, "_value") + ) + ) ), array: $ => seq( - "[", + '[', repeat( - field("item", $.value), + choice( + $.array, + $.value, + $.object, + ), ), - "]", + ']', ), - delimiter: $ => choice( - $._delimiter, - $.named_delimiter + object: $ => seq( + '{', + repeat($.pair), + '}', ), - _delimiter: $ => /---+\n/, - - named_delimiter: $ => prec(3, seq( - /---+\s*/, - prec.left(2, - seq( - field("title", /[^-]+/), - /\s*/ - ) + pair: $ => seq( + $.key, + token.immediate(':'), + /[\t\v ]*/, + seq( + choice( + $.array, + $.value, + $.object, + '\n', + ), ), - $._delimiter, - )), - - _separator: $ => ":", - - _text_till_eol: $ => /[^(\~\n)]+/, + ), - _text_with_trailing_modifier: $ => seq( - $._text_till_eol, - "\~\n" + delimiter: _ => seq( + "-", + /[^\n]*/, ) - } }); diff --git a/package.json b/package.json index 609ac89..ff13d3e 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ }, "tree-sitter": [ { - "scope": "document.norg", + "scope": "document.norg_meta", "file-types": [ - "norg" + "norg_meta" ] } ] diff --git a/src/grammar.json b/src/grammar.json index 94095b2..9e71d05 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -17,84 +17,75 @@ ] } }, - "pair": { + "key": { + "type": "PATTERN", + "value": "[^\\-\\s:][^\\s:]*" + }, + "value": { "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "_key" - }, - { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "PATTERN", - "value": "[ \\t\\v]*" - } + "type": "PATTERN", + "value": "[^\\s\\[\\]\\{\\}][^\\n\\[\\]\\{\\}(\\~\\n)]*" }, { "type": "CHOICE", "members": [ { - "type": "SYMBOL", - "name": "value" - }, - { - "type": "SYMBOL", - "name": "object" - }, - { - "type": "SYMBOL", - "name": "array" + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "~\n" + }, + { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "value" + }, + "named": false, + "value": "_value" + } + ] }, { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "STRING", - "value": "\n" - } + "type": "BLANK" } ] } ] }, - "key": { - "type": "PATTERN", - "value": "[^\\s:]+" - }, - "_key": { + "array": { "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "key" + "type": "STRING", + "value": "[" }, { - "type": "SYMBOL", - "name": "_separator" - } - ] - }, - "value": { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "REPEAT", - "content": { + "type": "REPEAT", + "content": { + "type": "CHOICE", + "members": [ + { "type": "SYMBOL", - "name": "_text_with_trailing_modifier" + "name": "array" + }, + { + "type": "SYMBOL", + "name": "value" + }, + { + "type": "SYMBOL", + "name": "object" } - }, - { - "type": "BLANK" - } - ] + ] + } }, { - "type": "SYMBOL", - "name": "_text_till_eol" + "type": "STRING", + "value": "]" } ] }, @@ -118,103 +109,62 @@ } ] }, - "array": { + "pair": { "type": "SEQ", "members": [ { - "type": "STRING", - "value": "[" + "type": "SYMBOL", + "name": "key" }, { - "type": "REPEAT", + "type": "IMMEDIATE_TOKEN", "content": { - "type": "FIELD", - "name": "item", - "content": { - "type": "SYMBOL", - "name": "value" - } + "type": "STRING", + "value": ":" } }, { - "type": "STRING", - "value": "]" - } - ] - }, - "delimiter": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "_delimiter" + "type": "PATTERN", + "value": "[\\t\\v ]*" }, { - "type": "SYMBOL", - "name": "named_delimiter" - } - ] - }, - "_delimiter": { - "type": "PATTERN", - "value": "---+\\n" - }, - "named_delimiter": { - "type": "PREC", - "value": 3, - "content": { - "type": "SEQ", - "members": [ - { - "type": "PATTERN", - "value": "---+\\s*" - }, - { - "type": "PREC_LEFT", - "value": 2, - "content": { - "type": "SEQ", + "type": "SEQ", + "members": [ + { + "type": "CHOICE", "members": [ { - "type": "FIELD", - "name": "title", - "content": { - "type": "PATTERN", - "value": "[^-]+" - } + "type": "SYMBOL", + "name": "array" }, { - "type": "PATTERN", - "value": "\\s*" + "type": "SYMBOL", + "name": "value" + }, + { + "type": "SYMBOL", + "name": "object" + }, + { + "type": "STRING", + "value": "\n" } ] } - }, - { - "type": "SYMBOL", - "name": "_delimiter" - } - ] - } - }, - "_separator": { - "type": "STRING", - "value": ":" - }, - "_text_till_eol": { - "type": "PATTERN", - "value": "[^(\\~\\n)]+" + ] + } + ] }, - "_text_with_trailing_modifier": { + "delimiter": { "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "_text_till_eol" + "type": "STRING", + "value": "-" }, { - "type": "STRING", - "value": "~\n" + "type": "PATTERN", + "value": "[^\\n]*" } ] } diff --git a/src/node-types.json b/src/node-types.json index 73740be..0155ffd 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -1,35 +1,37 @@ [ { - "type": "array", - "named": true, - "fields": { - "item": { - "multiple": true, - "required": false, - "types": [ - { - "type": "value", - "named": true - } - ] - } - } + "type": "_value", + "named": false, + "fields": {} }, { - "type": "delimiter", + "type": "array", "named": true, "fields": {}, "children": { - "multiple": false, + "multiple": true, "required": false, "types": [ { - "type": "named_delimiter", + "type": "array", + "named": true + }, + { + "type": "object", + "named": true + }, + { + "type": "value", "named": true } ] } }, + { + "type": "delimiter", + "named": true, + "fields": {} + }, { "type": "metadata", "named": true, @@ -49,11 +51,6 @@ ] } }, - { - "type": "named_delimiter", - "named": true, - "fields": {} - }, { "type": "object", "named": true, @@ -105,6 +102,14 @@ "type": "\n", "named": false }, + { + "type": "-", + "named": false + }, + { + "type": ":", + "named": false + }, { "type": "[", "named": false diff --git a/src/parser.c b/src/parser.c index 25d976a..5e7f915 100644 --- a/src/parser.c +++ b/src/parser.c @@ -6,106 +6,91 @@ #endif #define LANGUAGE_VERSION 13 -#define STATE_COUNT 49 +#define STATE_COUNT 50 #define LARGE_STATE_COUNT 2 -#define SYMBOL_COUNT 28 -#define ALIAS_COUNT 0 -#define TOKEN_COUNT 15 +#define SYMBOL_COUNT 22 +#define ALIAS_COUNT 1 +#define TOKEN_COUNT 13 #define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 2 +#define FIELD_COUNT 0 #define MAX_ALIAS_SEQUENCE_LENGTH 4 -#define PRODUCTION_ID_COUNT 5 +#define PRODUCTION_ID_COUNT 2 enum { - aux_sym_pair_token1 = 1, - anon_sym_LF = 2, - sym_key = 3, - anon_sym_LBRACE = 4, - anon_sym_RBRACE = 5, - anon_sym_LBRACK = 6, - anon_sym_RBRACK = 7, - sym__delimiter = 8, - aux_sym_named_delimiter_token1 = 9, - aux_sym_named_delimiter_token2 = 10, - aux_sym_named_delimiter_token3 = 11, - sym__separator = 12, - sym__text_till_eol = 13, - anon_sym_TILDE_LF = 14, - sym_metadata = 15, - sym_pair = 16, - sym__key = 17, - sym_value = 18, - sym_object = 19, - sym_array = 20, - sym_delimiter = 21, - sym_named_delimiter = 22, - sym__text_with_trailing_modifier = 23, - aux_sym_metadata_repeat1 = 24, - aux_sym_value_repeat1 = 25, - aux_sym_object_repeat1 = 26, - aux_sym_array_repeat1 = 27, + sym_key = 1, + aux_sym_value_token1 = 2, + anon_sym_TILDE_LF = 3, + anon_sym_LBRACK = 4, + anon_sym_RBRACK = 5, + anon_sym_LBRACE = 6, + anon_sym_RBRACE = 7, + anon_sym_COLON = 8, + aux_sym_pair_token1 = 9, + anon_sym_LF = 10, + anon_sym_DASH = 11, + aux_sym_delimiter_token1 = 12, + sym_metadata = 13, + sym_value = 14, + sym_array = 15, + sym_object = 16, + sym_pair = 17, + sym_delimiter = 18, + aux_sym_metadata_repeat1 = 19, + aux_sym_array_repeat1 = 20, + aux_sym_object_repeat1 = 21, + anon_alias_sym__value = 22, }; static const char * const ts_symbol_names[] = { [ts_builtin_sym_end] = "end", - [aux_sym_pair_token1] = "pair_token1", - [anon_sym_LF] = "\n", [sym_key] = "key", - [anon_sym_LBRACE] = "{", - [anon_sym_RBRACE] = "}", + [aux_sym_value_token1] = "value_token1", + [anon_sym_TILDE_LF] = "~\n", [anon_sym_LBRACK] = "[", [anon_sym_RBRACK] = "]", - [sym__delimiter] = "_delimiter", - [aux_sym_named_delimiter_token1] = "named_delimiter_token1", - [aux_sym_named_delimiter_token2] = "named_delimiter_token2", - [aux_sym_named_delimiter_token3] = "named_delimiter_token3", - [sym__separator] = "_separator", - [sym__text_till_eol] = "_text_till_eol", - [anon_sym_TILDE_LF] = "~\n", + [anon_sym_LBRACE] = "{", + [anon_sym_RBRACE] = "}", + [anon_sym_COLON] = ":", + [aux_sym_pair_token1] = "pair_token1", + [anon_sym_LF] = "\n", + [anon_sym_DASH] = "-", + [aux_sym_delimiter_token1] = "delimiter_token1", [sym_metadata] = "metadata", - [sym_pair] = "pair", - [sym__key] = "_key", [sym_value] = "value", - [sym_object] = "object", [sym_array] = "array", + [sym_object] = "object", + [sym_pair] = "pair", [sym_delimiter] = "delimiter", - [sym_named_delimiter] = "named_delimiter", - [sym__text_with_trailing_modifier] = "_text_with_trailing_modifier", [aux_sym_metadata_repeat1] = "metadata_repeat1", - [aux_sym_value_repeat1] = "value_repeat1", - [aux_sym_object_repeat1] = "object_repeat1", [aux_sym_array_repeat1] = "array_repeat1", + [aux_sym_object_repeat1] = "object_repeat1", + [anon_alias_sym__value] = "_value", }; static const TSSymbol ts_symbol_map[] = { [ts_builtin_sym_end] = ts_builtin_sym_end, - [aux_sym_pair_token1] = aux_sym_pair_token1, - [anon_sym_LF] = anon_sym_LF, [sym_key] = sym_key, - [anon_sym_LBRACE] = anon_sym_LBRACE, - [anon_sym_RBRACE] = anon_sym_RBRACE, + [aux_sym_value_token1] = aux_sym_value_token1, + [anon_sym_TILDE_LF] = anon_sym_TILDE_LF, [anon_sym_LBRACK] = anon_sym_LBRACK, [anon_sym_RBRACK] = anon_sym_RBRACK, - [sym__delimiter] = sym__delimiter, - [aux_sym_named_delimiter_token1] = aux_sym_named_delimiter_token1, - [aux_sym_named_delimiter_token2] = aux_sym_named_delimiter_token2, - [aux_sym_named_delimiter_token3] = aux_sym_named_delimiter_token3, - [sym__separator] = sym__separator, - [sym__text_till_eol] = sym__text_till_eol, - [anon_sym_TILDE_LF] = anon_sym_TILDE_LF, + [anon_sym_LBRACE] = anon_sym_LBRACE, + [anon_sym_RBRACE] = anon_sym_RBRACE, + [anon_sym_COLON] = anon_sym_COLON, + [aux_sym_pair_token1] = aux_sym_pair_token1, + [anon_sym_LF] = anon_sym_LF, + [anon_sym_DASH] = anon_sym_DASH, + [aux_sym_delimiter_token1] = aux_sym_delimiter_token1, [sym_metadata] = sym_metadata, - [sym_pair] = sym_pair, - [sym__key] = sym__key, [sym_value] = sym_value, - [sym_object] = sym_object, [sym_array] = sym_array, + [sym_object] = sym_object, + [sym_pair] = sym_pair, [sym_delimiter] = sym_delimiter, - [sym_named_delimiter] = sym_named_delimiter, - [sym__text_with_trailing_modifier] = sym__text_with_trailing_modifier, [aux_sym_metadata_repeat1] = aux_sym_metadata_repeat1, - [aux_sym_value_repeat1] = aux_sym_value_repeat1, - [aux_sym_object_repeat1] = aux_sym_object_repeat1, [aux_sym_array_repeat1] = aux_sym_array_repeat1, + [aux_sym_object_repeat1] = aux_sym_object_repeat1, + [anon_alias_sym__value] = anon_alias_sym__value, }; static const TSSymbolMetadata ts_symbol_metadata[] = { @@ -113,75 +98,63 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = true, }, - [aux_sym_pair_token1] = { + [sym_key] = { + .visible = true, + .named = true, + }, + [aux_sym_value_token1] = { .visible = false, .named = false, }, - [anon_sym_LF] = { + [anon_sym_TILDE_LF] = { .visible = true, .named = false, }, - [sym_key] = { + [anon_sym_LBRACK] = { .visible = true, - .named = true, + .named = false, }, - [anon_sym_LBRACE] = { + [anon_sym_RBRACK] = { .visible = true, .named = false, }, - [anon_sym_RBRACE] = { + [anon_sym_LBRACE] = { .visible = true, .named = false, }, - [anon_sym_LBRACK] = { + [anon_sym_RBRACE] = { .visible = true, .named = false, }, - [anon_sym_RBRACK] = { + [anon_sym_COLON] = { .visible = true, .named = false, }, - [sym__delimiter] = { - .visible = false, - .named = true, - }, - [aux_sym_named_delimiter_token1] = { + [aux_sym_pair_token1] = { .visible = false, .named = false, }, - [aux_sym_named_delimiter_token2] = { - .visible = false, + [anon_sym_LF] = { + .visible = true, .named = false, }, - [aux_sym_named_delimiter_token3] = { - .visible = false, + [anon_sym_DASH] = { + .visible = true, .named = false, }, - [sym__separator] = { + [aux_sym_delimiter_token1] = { .visible = false, - .named = true, - }, - [sym__text_till_eol] = { - .visible = false, - .named = true, - }, - [anon_sym_TILDE_LF] = { - .visible = true, .named = false, }, [sym_metadata] = { .visible = true, .named = true, }, - [sym_pair] = { + [sym_value] = { .visible = true, .named = true, }, - [sym__key] = { - .visible = false, - .named = true, - }, - [sym_value] = { + [sym_array] = { .visible = true, .named = true, }, @@ -189,7 +162,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym_array] = { + [sym_pair] = { .visible = true, .named = true, }, @@ -197,19 +170,11 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym_named_delimiter] = { - .visible = true, - .named = true, - }, - [sym__text_with_trailing_modifier] = { - .visible = false, - .named = true, - }, [aux_sym_metadata_repeat1] = { .visible = false, .named = false, }, - [aux_sym_value_repeat1] = { + [aux_sym_array_repeat1] = { .visible = false, .named = false, }, @@ -217,375 +182,272 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = false, }, - [aux_sym_array_repeat1] = { - .visible = false, + [anon_alias_sym__value] = { + .visible = true, .named = false, }, }; -enum { - field_item = 1, - field_title = 2, -}; - -static const char * const ts_field_names[] = { - [0] = NULL, - [field_item] = "item", - [field_title] = "title", -}; - -static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { - [1] = {.index = 0, .length = 1}, - [2] = {.index = 1, .length = 1}, - [3] = {.index = 2, .length = 1}, - [4] = {.index = 3, .length = 2}, -}; - -static const TSFieldMapEntry ts_field_map_entries[] = { - [0] = - {field_title, 1}, - [1] = - {field_item, 0}, - [2] = - {field_item, 1, .inherited = true}, - [3] = - {field_item, 0, .inherited = true}, - {field_item, 1, .inherited = true}, -}; - static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { [0] = {0}, + [1] = { + [2] = anon_alias_sym__value, + }, }; static const uint16_t ts_non_terminal_alias_map[] = { + sym_value, 2, + sym_value, + anon_alias_sym__value, 0, }; +static const TSStateId ts_primary_state_ids[STATE_COUNT] = { + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 3, + [6] = 4, + [7] = 4, + [8] = 3, + [9] = 9, + [10] = 9, + [11] = 11, + [12] = 12, + [13] = 13, + [14] = 14, + [15] = 13, + [16] = 16, + [17] = 17, + [18] = 16, + [19] = 17, + [20] = 16, + [21] = 17, + [22] = 22, + [23] = 23, + [24] = 24, + [25] = 25, + [26] = 26, + [27] = 24, + [28] = 28, + [29] = 26, + [30] = 22, + [31] = 23, + [32] = 13, + [33] = 25, + [34] = 34, + [35] = 23, + [36] = 24, + [37] = 37, + [38] = 22, + [39] = 28, + [40] = 25, + [41] = 26, + [42] = 37, + [43] = 37, + [44] = 44, + [45] = 45, + [46] = 46, + [47] = 47, + [48] = 44, + [49] = 47, +}; + static bool ts_lex(TSLexer *lexer, TSStateId state) { START_LEXER(); eof = lexer->eof(lexer); switch (state) { case 0: - if (eof) ADVANCE(16); - if (lookahead == '-') ADVANCE(8); - if (lookahead == ':') ADVANCE(39); - if (lookahead == '[') ADVANCE(28); - if (lookahead == ']') ADVANCE(30); - if (lookahead == '{') ADVANCE(24); - if (lookahead == '}') ADVANCE(26); + if (eof) ADVANCE(8); + if (lookahead == '-') ADVANCE(23); + if (lookahead == ':') ADVANCE(19); + if (lookahead == '[') ADVANCE(14); + if (lookahead == ']') ADVANCE(15); + if (lookahead == '{') ADVANCE(16); + if (lookahead == '}') ADVANCE(17); if (lookahead == '~') ADVANCE(1); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(0) + lookahead == ' ') SKIP(6) END_STATE(); case 1: - if (lookahead == '\n') ADVANCE(44); + if (lookahead == '\n') ADVANCE(13); END_STATE(); case 2: - if (lookahead == '\n') ADVANCE(18); - if (lookahead == '[') ADVANCE(29); - if (lookahead == '{') ADVANCE(25); + if (lookahead == '\n') ADVANCE(22); + if (lookahead == '[') ADVANCE(14); + if (lookahead == '{') ADVANCE(16); if (lookahead == '\t' || lookahead == '\r' || - lookahead == ' ') ADVANCE(40); + lookahead == ' ') SKIP(2) if (lookahead != 0 && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); + lookahead != ']' && + lookahead != '}') ADVANCE(12); END_STATE(); case 3: - if (lookahead == '\n') SKIP(3) - if (lookahead == ']') ADVANCE(31); - if (lookahead == '~') ADVANCE(1); - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(41); - if (lookahead != 0 && - lookahead != '(' && - lookahead != ')') ADVANCE(43); - END_STATE(); - case 4: - if (lookahead == '\n') SKIP(4) - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(42); - if (lookahead != 0 && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); - END_STATE(); - case 5: - if (lookahead == '\n') ADVANCE(32); - if (lookahead == '-') ADVANCE(5); - END_STATE(); - case 6: - if (lookahead == '-') ADVANCE(34); - END_STATE(); - case 7: - if (lookahead == '-') ADVANCE(5); - END_STATE(); - case 8: - if (lookahead == '-') ADVANCE(6); - END_STATE(); - case 9: - if (lookahead == '-') ADVANCE(7); - END_STATE(); - case 10: - if (lookahead == '-') ADVANCE(9); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(10) - END_STATE(); - case 11: - if (lookahead == '}') ADVANCE(27); - if (lookahead == '~') ADVANCE(19); + if (lookahead == '[') ADVANCE(14); + if (lookahead == ']') ADVANCE(15); + if (lookahead == '{') ADVANCE(16); + if (lookahead == '~') ADVANCE(11); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(11) + lookahead == ' ') SKIP(3) if (lookahead != 0 && - lookahead != ':') ADVANCE(23); + lookahead != '}') ADVANCE(12); END_STATE(); - case 12: - if (lookahead == '}') ADVANCE(27); + case 4: + if (lookahead == '[') ADVANCE(14); + if (lookahead == ']') ADVANCE(15); + if (lookahead == '{') ADVANCE(16); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(12) + lookahead == ' ') SKIP(4) if (lookahead != 0 && - lookahead != ':') ADVANCE(23); + lookahead != '}') ADVANCE(12); END_STATE(); - case 13: + case 5: + if (lookahead == '}') ADVANCE(18); + if (lookahead == '~') ADVANCE(9); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') ADVANCE(36); + lookahead == ' ') SKIP(5) if (lookahead != 0 && - lookahead != '-') ADVANCE(37); + lookahead != '-' && + lookahead != ':') ADVANCE(10); END_STATE(); - case 14: - if (eof) ADVANCE(16); - if (lookahead == '-') ADVANCE(22); - if (lookahead == '~') ADVANCE(19); + case 6: + if (eof) ADVANCE(8); + if (lookahead == '-') ADVANCE(23); + if (lookahead == '[') ADVANCE(14); + if (lookahead == ']') ADVANCE(15); + if (lookahead == '{') ADVANCE(16); + if (lookahead == '}') ADVANCE(17); + if (lookahead == '~') ADVANCE(1); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(14) - if (lookahead != 0 && - lookahead != ':') ADVANCE(23); + lookahead == ' ') SKIP(6) END_STATE(); - case 15: - if (eof) ADVANCE(16); - if (lookahead == '-') ADVANCE(22); + case 7: + if (eof) ADVANCE(8); + if (lookahead == '-') ADVANCE(23); + if (lookahead == '~') ADVANCE(9); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(15) + lookahead == ' ') SKIP(7) if (lookahead != 0 && - lookahead != ':') ADVANCE(23); + lookahead != ':') ADVANCE(10); END_STATE(); - case 16: + case 8: ACCEPT_TOKEN(ts_builtin_sym_end); END_STATE(); - case 17: - ACCEPT_TOKEN(aux_sym_pair_token1); - if (lookahead == '\t' || - lookahead == 11 || - lookahead == ' ') ADVANCE(17); - END_STATE(); - case 18: - ACCEPT_TOKEN(anon_sym_LF); - END_STATE(); - case 19: + case 9: ACCEPT_TOKEN(sym_key); - if (lookahead == '\n') ADVANCE(44); + if (lookahead == '\n') ADVANCE(13); if (lookahead != 0 && lookahead != '\t' && lookahead != '\r' && lookahead != ' ' && - lookahead != ':') ADVANCE(23); - END_STATE(); - case 20: - ACCEPT_TOKEN(sym_key); - if (lookahead == '\n') ADVANCE(33); - if (lookahead == '-') ADVANCE(20); - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(35); - if (lookahead != 0 && - lookahead != ':') ADVANCE(23); + lookahead != ':') ADVANCE(10); END_STATE(); - case 21: + case 10: ACCEPT_TOKEN(sym_key); - if (lookahead == '-') ADVANCE(20); if (lookahead != 0 && lookahead != '\t' && lookahead != '\n' && lookahead != '\r' && lookahead != ' ' && - lookahead != ':') ADVANCE(23); + lookahead != ':') ADVANCE(10); END_STATE(); - case 22: - ACCEPT_TOKEN(sym_key); - if (lookahead == '-') ADVANCE(21); + case 11: + ACCEPT_TOKEN(aux_sym_value_token1); + if (lookahead == '\n') ADVANCE(13); if (lookahead != 0 && - lookahead != '\t' && - lookahead != '\n' && - lookahead != '\r' && - lookahead != ' ' && - lookahead != ':') ADVANCE(23); + lookahead != '(' && + lookahead != ')' && + lookahead != '[' && + lookahead != ']' && + lookahead != '{' && + lookahead != '}' && + lookahead != '~') ADVANCE(12); END_STATE(); - case 23: - ACCEPT_TOKEN(sym_key); + case 12: + ACCEPT_TOKEN(aux_sym_value_token1); if (lookahead != 0 && - lookahead != '\t' && lookahead != '\n' && - lookahead != '\r' && - lookahead != ' ' && - lookahead != ':') ADVANCE(23); + lookahead != '(' && + lookahead != ')' && + lookahead != '[' && + lookahead != ']' && + lookahead != '{' && + lookahead != '}' && + lookahead != '~') ADVANCE(12); END_STATE(); - case 24: - ACCEPT_TOKEN(anon_sym_LBRACE); + case 13: + ACCEPT_TOKEN(anon_sym_TILDE_LF); END_STATE(); - case 25: + case 14: + ACCEPT_TOKEN(anon_sym_LBRACK); + END_STATE(); + case 15: + ACCEPT_TOKEN(anon_sym_RBRACK); + END_STATE(); + case 16: ACCEPT_TOKEN(anon_sym_LBRACE); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); END_STATE(); - case 26: + case 17: ACCEPT_TOKEN(anon_sym_RBRACE); END_STATE(); - case 27: + case 18: ACCEPT_TOKEN(anon_sym_RBRACE); if (lookahead != 0 && lookahead != '\t' && lookahead != '\n' && lookahead != '\r' && lookahead != ' ' && - lookahead != ':') ADVANCE(23); - END_STATE(); - case 28: - ACCEPT_TOKEN(anon_sym_LBRACK); + lookahead != ':') ADVANCE(10); END_STATE(); - case 29: - ACCEPT_TOKEN(anon_sym_LBRACK); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); - END_STATE(); - case 30: - ACCEPT_TOKEN(anon_sym_RBRACK); - END_STATE(); - case 31: - ACCEPT_TOKEN(anon_sym_RBRACK); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); - END_STATE(); - case 32: - ACCEPT_TOKEN(sym__delimiter); - END_STATE(); - case 33: - ACCEPT_TOKEN(sym__delimiter); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(35); - END_STATE(); - case 34: - ACCEPT_TOKEN(aux_sym_named_delimiter_token1); - if (lookahead == '\n') ADVANCE(33); - if (lookahead == '-') ADVANCE(34); - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(35); - END_STATE(); - case 35: - ACCEPT_TOKEN(aux_sym_named_delimiter_token1); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(35); + case 19: + ACCEPT_TOKEN(anon_sym_COLON); END_STATE(); - case 36: - ACCEPT_TOKEN(aux_sym_named_delimiter_token2); + case 20: + ACCEPT_TOKEN(aux_sym_pair_token1); + if (lookahead == 11) ADVANCE(21); if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(36); - if (lookahead != 0 && - lookahead != '-') ADVANCE(37); + lookahead == ' ') ADVANCE(20); END_STATE(); - case 37: - ACCEPT_TOKEN(aux_sym_named_delimiter_token2); - if (lookahead != 0 && - lookahead != '-') ADVANCE(37); - END_STATE(); - case 38: - ACCEPT_TOKEN(aux_sym_named_delimiter_token3); + case 21: + ACCEPT_TOKEN(aux_sym_pair_token1); if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(38); - END_STATE(); - case 39: - ACCEPT_TOKEN(sym__separator); + lookahead == 11 || + lookahead == ' ') ADVANCE(21); END_STATE(); - case 40: - ACCEPT_TOKEN(sym__text_till_eol); - if (lookahead == '[') ADVANCE(29); - if (lookahead == '{') ADVANCE(25); - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(40); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); + case 22: + ACCEPT_TOKEN(anon_sym_LF); + if (lookahead == '\n') ADVANCE(22); END_STATE(); - case 41: - ACCEPT_TOKEN(sym__text_till_eol); - if (lookahead == ']') ADVANCE(31); - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(41); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); + case 23: + ACCEPT_TOKEN(anon_sym_DASH); END_STATE(); - case 42: - ACCEPT_TOKEN(sym__text_till_eol); + case 24: + ACCEPT_TOKEN(aux_sym_delimiter_token1); if (lookahead == '\t' || lookahead == '\r' || - lookahead == ' ') ADVANCE(42); + lookahead == ' ') ADVANCE(24); if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); + lookahead != '\n') ADVANCE(25); END_STATE(); - case 43: - ACCEPT_TOKEN(sym__text_till_eol); + case 25: + ACCEPT_TOKEN(aux_sym_delimiter_token1); if (lookahead != 0 && - lookahead != '\n' && - lookahead != '(' && - lookahead != ')' && - lookahead != '~') ADVANCE(43); - END_STATE(); - case 44: - ACCEPT_TOKEN(anon_sym_TILDE_LF); + lookahead != '\n') ADVANCE(25); END_STATE(); default: return false; @@ -594,547 +456,546 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { static const TSLexMode ts_lex_modes[STATE_COUNT] = { [0] = {.lex_state = 0}, - [1] = {.lex_state = 15}, - [2] = {.lex_state = 15}, - [3] = {.lex_state = 2}, - [4] = {.lex_state = 15}, - [5] = {.lex_state = 2}, - [6] = {.lex_state = 3}, - [7] = {.lex_state = 3}, - [8] = {.lex_state = 3}, - [9] = {.lex_state = 3}, - [10] = {.lex_state = 3}, - [11] = {.lex_state = 12}, - [12] = {.lex_state = 12}, - [13] = {.lex_state = 14}, - [14] = {.lex_state = 12}, - [15] = {.lex_state = 12}, - [16] = {.lex_state = 14}, - [17] = {.lex_state = 12}, - [18] = {.lex_state = 15}, - [19] = {.lex_state = 15}, - [20] = {.lex_state = 15}, - [21] = {.lex_state = 15}, - [22] = {.lex_state = 15}, - [23] = {.lex_state = 15}, - [24] = {.lex_state = 15}, + [1] = {.lex_state = 7}, + [2] = {.lex_state = 4}, + [3] = {.lex_state = 4}, + [4] = {.lex_state = 4}, + [5] = {.lex_state = 4}, + [6] = {.lex_state = 4}, + [7] = {.lex_state = 4}, + [8] = {.lex_state = 4}, + [9] = {.lex_state = 2}, + [10] = {.lex_state = 2}, + [11] = {.lex_state = 7}, + [12] = {.lex_state = 7}, + [13] = {.lex_state = 3}, + [14] = {.lex_state = 5}, + [15] = {.lex_state = 7}, + [16] = {.lex_state = 5}, + [17] = {.lex_state = 5}, + [18] = {.lex_state = 5}, + [19] = {.lex_state = 5}, + [20] = {.lex_state = 5}, + [21] = {.lex_state = 5}, + [22] = {.lex_state = 4}, + [23] = {.lex_state = 4}, + [24] = {.lex_state = 4}, [25] = {.lex_state = 4}, - [26] = {.lex_state = 11}, - [27] = {.lex_state = 4}, - [28] = {.lex_state = 4}, - [29] = {.lex_state = 4}, - [30] = {.lex_state = 3}, - [31] = {.lex_state = 3}, - [32] = {.lex_state = 11}, - [33] = {.lex_state = 3}, - [34] = {.lex_state = 12}, - [35] = {.lex_state = 12}, - [36] = {.lex_state = 12}, - [37] = {.lex_state = 12}, - [38] = {.lex_state = 12}, - [39] = {.lex_state = 10}, - [40] = {.lex_state = 0}, - [41] = {.lex_state = 0}, + [26] = {.lex_state = 4}, + [27] = {.lex_state = 7}, + [28] = {.lex_state = 7}, + [29] = {.lex_state = 7}, + [30] = {.lex_state = 7}, + [31] = {.lex_state = 7}, + [32] = {.lex_state = 5}, + [33] = {.lex_state = 7}, + [34] = {.lex_state = 7}, + [35] = {.lex_state = 5}, + [36] = {.lex_state = 5}, + [37] = {.lex_state = 4}, + [38] = {.lex_state = 5}, + [39] = {.lex_state = 5}, + [40] = {.lex_state = 5}, + [41] = {.lex_state = 5}, [42] = {.lex_state = 4}, - [43] = {.lex_state = 38}, - [44] = {.lex_state = 17}, - [45] = {.lex_state = 17}, - [46] = {.lex_state = 0}, - [47] = {.lex_state = 13}, - [48] = {.lex_state = 17}, + [43] = {.lex_state = 4}, + [44] = {.lex_state = 20}, + [45] = {.lex_state = 0}, + [46] = {.lex_state = 24}, + [47] = {.lex_state = 0}, + [48] = {.lex_state = 20}, + [49] = {.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_RBRACE] = ACTIONS(1), + [anon_sym_TILDE_LF] = ACTIONS(1), [anon_sym_LBRACK] = ACTIONS(1), [anon_sym_RBRACK] = ACTIONS(1), - [sym__delimiter] = ACTIONS(1), - [aux_sym_named_delimiter_token1] = ACTIONS(1), - [sym__separator] = ACTIONS(1), - [anon_sym_TILDE_LF] = ACTIONS(1), + [anon_sym_LBRACE] = ACTIONS(1), + [anon_sym_RBRACE] = ACTIONS(1), + [anon_sym_COLON] = ACTIONS(1), + [anon_sym_DASH] = ACTIONS(1), }, [1] = { - [sym_metadata] = STATE(46), - [sym_pair] = STATE(2), - [sym__key] = STATE(45), - [sym_delimiter] = STATE(2), - [sym_named_delimiter] = STATE(24), - [aux_sym_metadata_repeat1] = STATE(2), + [sym_metadata] = STATE(45), + [sym_pair] = STATE(11), + [sym_delimiter] = STATE(11), + [aux_sym_metadata_repeat1] = STATE(11), [ts_builtin_sym_end] = ACTIONS(3), [sym_key] = ACTIONS(5), - [sym__delimiter] = ACTIONS(7), - [aux_sym_named_delimiter_token1] = ACTIONS(9), + [anon_sym_DASH] = ACTIONS(7), }, }; static const uint16_t ts_small_parse_table[] = { - [0] = 7, - ACTIONS(5), 1, - sym_key, - ACTIONS(7), 1, - sym__delimiter, + [0] = 5, ACTIONS(9), 1, - aux_sym_named_delimiter_token1, - ACTIONS(11), 1, - ts_builtin_sym_end, - STATE(24), 1, - sym_named_delimiter, - STATE(45), 1, - sym__key, - STATE(4), 3, - sym_pair, - sym_delimiter, - aux_sym_metadata_repeat1, - [24] = 6, - ACTIONS(13), 1, - anon_sym_LF, + aux_sym_value_token1, + ACTIONS(12), 1, + anon_sym_LBRACK, ACTIONS(15), 1, - anon_sym_LBRACE, + anon_sym_RBRACK, ACTIONS(17), 1, - anon_sym_LBRACK, - ACTIONS(19), 1, - sym__text_till_eol, - STATE(25), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - STATE(21), 3, + anon_sym_LBRACE, + STATE(2), 4, sym_value, - sym_object, sym_array, - [46] = 7, - ACTIONS(21), 1, - ts_builtin_sym_end, - ACTIONS(23), 1, - sym_key, + sym_object, + aux_sym_array_repeat1, + [19] = 5, + ACTIONS(20), 1, + aux_sym_value_token1, + ACTIONS(22), 1, + anon_sym_LBRACK, + ACTIONS(24), 1, + anon_sym_RBRACK, ACTIONS(26), 1, - sym__delimiter, - ACTIONS(29), 1, - aux_sym_named_delimiter_token1, - STATE(24), 1, - sym_named_delimiter, - STATE(45), 1, - sym__key, - STATE(4), 3, - sym_pair, - sym_delimiter, - aux_sym_metadata_repeat1, - [70] = 6, - ACTIONS(32), 1, - anon_sym_LF, - ACTIONS(34), 1, anon_sym_LBRACE, - ACTIONS(36), 1, - anon_sym_LBRACK, - ACTIONS(38), 1, - sym__text_till_eol, - STATE(27), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - STATE(34), 3, + STATE(2), 4, sym_value, - sym_object, sym_array, - [92] = 5, - ACTIONS(40), 1, - anon_sym_RBRACK, - ACTIONS(42), 1, - sym__text_till_eol, - STATE(7), 1, + sym_object, aux_sym_array_repeat1, - STATE(33), 1, - sym_value, - STATE(29), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [109] = 5, - ACTIONS(44), 1, + [38] = 5, + ACTIONS(20), 1, + aux_sym_value_token1, + ACTIONS(22), 1, + anon_sym_LBRACK, + ACTIONS(26), 1, + anon_sym_LBRACE, + ACTIONS(28), 1, anon_sym_RBRACK, - ACTIONS(46), 1, - sym__text_till_eol, - STATE(7), 1, - aux_sym_array_repeat1, - STATE(33), 1, + STATE(3), 4, sym_value, - STATE(29), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [126] = 5, - ACTIONS(42), 1, - sym__text_till_eol, - ACTIONS(49), 1, - anon_sym_RBRACK, - STATE(7), 1, + sym_array, + sym_object, aux_sym_array_repeat1, - STATE(33), 1, + [57] = 5, + ACTIONS(20), 1, + aux_sym_value_token1, + ACTIONS(22), 1, + anon_sym_LBRACK, + ACTIONS(26), 1, + anon_sym_LBRACE, + ACTIONS(30), 1, + anon_sym_RBRACK, + STATE(2), 4, sym_value, - STATE(29), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [143] = 5, - ACTIONS(42), 1, - sym__text_till_eol, - ACTIONS(51), 1, + sym_array, + sym_object, + aux_sym_array_repeat1, + [76] = 5, + ACTIONS(20), 1, + aux_sym_value_token1, + ACTIONS(22), 1, + anon_sym_LBRACK, + ACTIONS(26), 1, + anon_sym_LBRACE, + ACTIONS(32), 1, anon_sym_RBRACK, - STATE(8), 1, + STATE(5), 4, + sym_value, + sym_array, + sym_object, aux_sym_array_repeat1, - STATE(33), 1, + [95] = 5, + ACTIONS(20), 1, + aux_sym_value_token1, + ACTIONS(22), 1, + anon_sym_LBRACK, + ACTIONS(26), 1, + anon_sym_LBRACE, + ACTIONS(34), 1, + anon_sym_RBRACK, + STATE(8), 4, sym_value, - STATE(29), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [160] = 5, - ACTIONS(42), 1, - sym__text_till_eol, - ACTIONS(53), 1, + sym_array, + sym_object, + aux_sym_array_repeat1, + [114] = 5, + ACTIONS(20), 1, + aux_sym_value_token1, + ACTIONS(22), 1, + anon_sym_LBRACK, + ACTIONS(26), 1, + anon_sym_LBRACE, + ACTIONS(36), 1, anon_sym_RBRACK, - STATE(6), 1, + STATE(2), 4, + sym_value, + sym_array, + sym_object, aux_sym_array_repeat1, - STATE(33), 1, + [133] = 5, + ACTIONS(38), 1, + aux_sym_value_token1, + ACTIONS(40), 1, + anon_sym_LBRACK, + ACTIONS(42), 1, + anon_sym_LBRACE, + ACTIONS(44), 1, + anon_sym_LF, + STATE(39), 3, + sym_value, + sym_array, + sym_object, + [151] = 5, + ACTIONS(46), 1, + aux_sym_value_token1, + ACTIONS(48), 1, + anon_sym_LBRACK, + ACTIONS(50), 1, + anon_sym_LBRACE, + ACTIONS(52), 1, + anon_sym_LF, + STATE(28), 3, sym_value, - STATE(29), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [177] = 4, - ACTIONS(55), 1, + sym_array, + sym_object, + [169] = 4, + ACTIONS(5), 1, sym_key, + ACTIONS(7), 1, + anon_sym_DASH, + ACTIONS(54), 1, + ts_builtin_sym_end, + STATE(12), 3, + sym_pair, + sym_delimiter, + aux_sym_metadata_repeat1, + [184] = 4, + ACTIONS(56), 1, + ts_builtin_sym_end, ACTIONS(58), 1, - anon_sym_RBRACE, - STATE(48), 1, - sym__key, - STATE(11), 2, + sym_key, + ACTIONS(61), 1, + anon_sym_DASH, + STATE(12), 3, sym_pair, - aux_sym_object_repeat1, - [191] = 4, - ACTIONS(5), 1, + sym_delimiter, + aux_sym_metadata_repeat1, + [199] = 3, + ACTIONS(64), 1, + aux_sym_value_token1, + ACTIONS(66), 1, + anon_sym_TILDE_LF, + ACTIONS(68), 3, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LBRACE, + [211] = 3, + ACTIONS(70), 1, sym_key, - ACTIONS(60), 1, + ACTIONS(73), 1, anon_sym_RBRACE, - STATE(48), 1, - sym__key, - STATE(11), 2, + STATE(14), 2, sym_pair, aux_sym_object_repeat1, - [205] = 3, - ACTIONS(62), 1, - ts_builtin_sym_end, - ACTIONS(66), 1, - anon_sym_TILDE_LF, - ACTIONS(64), 3, + [222] = 3, + ACTIONS(64), 1, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [217] = 4, - ACTIONS(5), 1, + ACTIONS(75), 1, + anon_sym_TILDE_LF, + ACTIONS(68), 2, + ts_builtin_sym_end, + anon_sym_DASH, + [233] = 3, + ACTIONS(77), 1, sym_key, - ACTIONS(68), 1, + ACTIONS(79), 1, anon_sym_RBRACE, - STATE(48), 1, - sym__key, - STATE(12), 2, + STATE(14), 2, sym_pair, aux_sym_object_repeat1, - [231] = 4, - ACTIONS(5), 1, + [244] = 3, + ACTIONS(77), 1, sym_key, - ACTIONS(70), 1, + ACTIONS(81), 1, anon_sym_RBRACE, - STATE(48), 1, - sym__key, - STATE(17), 2, + STATE(16), 2, sym_pair, aux_sym_object_repeat1, - [245] = 3, - ACTIONS(66), 1, - anon_sym_TILDE_LF, - ACTIONS(72), 1, - ts_builtin_sym_end, - ACTIONS(74), 3, + [255] = 3, + ACTIONS(77), 1, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [257] = 4, - ACTIONS(5), 1, + ACTIONS(83), 1, + anon_sym_RBRACE, + STATE(14), 2, + sym_pair, + aux_sym_object_repeat1, + [266] = 3, + ACTIONS(77), 1, sym_key, - ACTIONS(76), 1, + ACTIONS(85), 1, anon_sym_RBRACE, - STATE(48), 1, - sym__key, - STATE(11), 2, + STATE(18), 2, sym_pair, aux_sym_object_repeat1, - [271] = 2, - ACTIONS(78), 1, - ts_builtin_sym_end, - ACTIONS(80), 3, + [277] = 3, + ACTIONS(77), 1, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [280] = 2, - ACTIONS(82), 1, - ts_builtin_sym_end, - ACTIONS(84), 3, + ACTIONS(87), 1, + anon_sym_RBRACE, + STATE(14), 2, + sym_pair, + aux_sym_object_repeat1, + [288] = 3, + ACTIONS(77), 1, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [289] = 2, - ACTIONS(86), 1, + ACTIONS(89), 1, + anon_sym_RBRACE, + STATE(20), 2, + sym_pair, + aux_sym_object_repeat1, + [299] = 1, + ACTIONS(91), 4, + aux_sym_value_token1, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LBRACE, + [306] = 1, + ACTIONS(93), 4, + aux_sym_value_token1, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LBRACE, + [313] = 1, + ACTIONS(95), 4, + aux_sym_value_token1, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LBRACE, + [320] = 1, + ACTIONS(97), 4, + aux_sym_value_token1, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LBRACE, + [327] = 1, + ACTIONS(99), 4, + aux_sym_value_token1, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LBRACE, + [334] = 1, + ACTIONS(95), 3, ts_builtin_sym_end, - ACTIONS(88), 3, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [298] = 2, - ACTIONS(90), 1, + anon_sym_DASH, + [340] = 1, + ACTIONS(101), 3, ts_builtin_sym_end, - ACTIONS(92), 3, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [307] = 2, - ACTIONS(94), 1, + anon_sym_DASH, + [346] = 1, + ACTIONS(99), 3, ts_builtin_sym_end, - ACTIONS(96), 3, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [316] = 2, - ACTIONS(98), 1, + anon_sym_DASH, + [352] = 1, + ACTIONS(91), 3, ts_builtin_sym_end, - ACTIONS(100), 3, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [325] = 2, - ACTIONS(102), 1, + anon_sym_DASH, + [358] = 1, + ACTIONS(93), 3, ts_builtin_sym_end, - ACTIONS(104), 3, sym_key, - sym__delimiter, - aux_sym_named_delimiter_token1, - [334] = 2, - ACTIONS(106), 1, - sym__text_till_eol, - STATE(28), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [342] = 2, - ACTIONS(66), 1, + anon_sym_DASH, + [364] = 2, + ACTIONS(103), 1, anon_sym_TILDE_LF, ACTIONS(64), 2, sym_key, anon_sym_RBRACE, - [350] = 2, - ACTIONS(108), 1, - sym__text_till_eol, - STATE(28), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [358] = 2, - ACTIONS(110), 1, - sym__text_till_eol, - STATE(28), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [366] = 2, - ACTIONS(113), 1, - sym__text_till_eol, - STATE(28), 2, - sym__text_with_trailing_modifier, - aux_sym_value_repeat1, - [374] = 2, - ACTIONS(115), 1, - anon_sym_TILDE_LF, - ACTIONS(74), 2, - anon_sym_RBRACK, - sym__text_till_eol, - [382] = 2, - ACTIONS(115), 1, - anon_sym_TILDE_LF, - ACTIONS(64), 2, - anon_sym_RBRACK, - sym__text_till_eol, - [390] = 2, - ACTIONS(66), 1, - anon_sym_TILDE_LF, - ACTIONS(74), 2, + [372] = 1, + ACTIONS(97), 3, + ts_builtin_sym_end, + sym_key, + anon_sym_DASH, + [378] = 1, + ACTIONS(105), 3, + ts_builtin_sym_end, + sym_key, + anon_sym_DASH, + [384] = 1, + ACTIONS(107), 2, sym_key, anon_sym_RBRACE, - [398] = 1, - ACTIONS(117), 2, - anon_sym_RBRACK, - sym__text_till_eol, - [403] = 1, - ACTIONS(92), 2, + [389] = 1, + ACTIONS(109), 2, sym_key, anon_sym_RBRACE, - [408] = 1, - ACTIONS(84), 2, + [394] = 2, + ACTIONS(20), 1, + aux_sym_value_token1, + STATE(24), 1, + sym_value, + [401] = 1, + ACTIONS(111), 2, sym_key, anon_sym_RBRACE, - [413] = 1, - ACTIONS(88), 2, + [406] = 1, + ACTIONS(113), 2, sym_key, anon_sym_RBRACE, - [418] = 1, - ACTIONS(96), 2, + [411] = 1, + ACTIONS(115), 2, sym_key, anon_sym_RBRACE, - [423] = 1, - ACTIONS(100), 2, + [416] = 1, + ACTIONS(117), 2, sym_key, anon_sym_RBRACE, - [428] = 1, + [421] = 2, ACTIONS(119), 1, - sym__delimiter, - [432] = 1, - ACTIONS(66), 1, - anon_sym_TILDE_LF, - [436] = 1, + aux_sym_value_token1, + STATE(36), 1, + sym_value, + [428] = 2, ACTIONS(121), 1, - sym__separator, - [440] = 1, + aux_sym_value_token1, + STATE(27), 1, + sym_value, + [435] = 1, ACTIONS(123), 1, - sym__text_till_eol, - [444] = 1, + aux_sym_pair_token1, + [439] = 1, ACTIONS(125), 1, - aux_sym_named_delimiter_token3, - [448] = 1, + ts_builtin_sym_end, + [443] = 1, ACTIONS(127), 1, - aux_sym_pair_token1, - [452] = 1, + aux_sym_delimiter_token1, + [447] = 1, ACTIONS(129), 1, - aux_sym_pair_token1, - [456] = 1, + anon_sym_COLON, + [451] = 1, ACTIONS(131), 1, - ts_builtin_sym_end, - [460] = 1, - ACTIONS(133), 1, - aux_sym_named_delimiter_token2, - [464] = 1, - ACTIONS(135), 1, aux_sym_pair_token1, + [455] = 1, + ACTIONS(133), 1, + anon_sym_COLON, }; static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(2)] = 0, - [SMALL_STATE(3)] = 24, - [SMALL_STATE(4)] = 46, - [SMALL_STATE(5)] = 70, - [SMALL_STATE(6)] = 92, - [SMALL_STATE(7)] = 109, - [SMALL_STATE(8)] = 126, - [SMALL_STATE(9)] = 143, - [SMALL_STATE(10)] = 160, - [SMALL_STATE(11)] = 177, - [SMALL_STATE(12)] = 191, - [SMALL_STATE(13)] = 205, - [SMALL_STATE(14)] = 217, - [SMALL_STATE(15)] = 231, - [SMALL_STATE(16)] = 245, - [SMALL_STATE(17)] = 257, - [SMALL_STATE(18)] = 271, - [SMALL_STATE(19)] = 280, - [SMALL_STATE(20)] = 289, - [SMALL_STATE(21)] = 298, - [SMALL_STATE(22)] = 307, - [SMALL_STATE(23)] = 316, - [SMALL_STATE(24)] = 325, - [SMALL_STATE(25)] = 334, - [SMALL_STATE(26)] = 342, - [SMALL_STATE(27)] = 350, - [SMALL_STATE(28)] = 358, - [SMALL_STATE(29)] = 366, - [SMALL_STATE(30)] = 374, - [SMALL_STATE(31)] = 382, - [SMALL_STATE(32)] = 390, - [SMALL_STATE(33)] = 398, - [SMALL_STATE(34)] = 403, - [SMALL_STATE(35)] = 408, - [SMALL_STATE(36)] = 413, - [SMALL_STATE(37)] = 418, - [SMALL_STATE(38)] = 423, - [SMALL_STATE(39)] = 428, - [SMALL_STATE(40)] = 432, - [SMALL_STATE(41)] = 436, - [SMALL_STATE(42)] = 440, - [SMALL_STATE(43)] = 444, - [SMALL_STATE(44)] = 448, - [SMALL_STATE(45)] = 452, - [SMALL_STATE(46)] = 456, - [SMALL_STATE(47)] = 460, - [SMALL_STATE(48)] = 464, + [SMALL_STATE(3)] = 19, + [SMALL_STATE(4)] = 38, + [SMALL_STATE(5)] = 57, + [SMALL_STATE(6)] = 76, + [SMALL_STATE(7)] = 95, + [SMALL_STATE(8)] = 114, + [SMALL_STATE(9)] = 133, + [SMALL_STATE(10)] = 151, + [SMALL_STATE(11)] = 169, + [SMALL_STATE(12)] = 184, + [SMALL_STATE(13)] = 199, + [SMALL_STATE(14)] = 211, + [SMALL_STATE(15)] = 222, + [SMALL_STATE(16)] = 233, + [SMALL_STATE(17)] = 244, + [SMALL_STATE(18)] = 255, + [SMALL_STATE(19)] = 266, + [SMALL_STATE(20)] = 277, + [SMALL_STATE(21)] = 288, + [SMALL_STATE(22)] = 299, + [SMALL_STATE(23)] = 306, + [SMALL_STATE(24)] = 313, + [SMALL_STATE(25)] = 320, + [SMALL_STATE(26)] = 327, + [SMALL_STATE(27)] = 334, + [SMALL_STATE(28)] = 340, + [SMALL_STATE(29)] = 346, + [SMALL_STATE(30)] = 352, + [SMALL_STATE(31)] = 358, + [SMALL_STATE(32)] = 364, + [SMALL_STATE(33)] = 372, + [SMALL_STATE(34)] = 378, + [SMALL_STATE(35)] = 384, + [SMALL_STATE(36)] = 389, + [SMALL_STATE(37)] = 394, + [SMALL_STATE(38)] = 401, + [SMALL_STATE(39)] = 406, + [SMALL_STATE(40)] = 411, + [SMALL_STATE(41)] = 416, + [SMALL_STATE(42)] = 421, + [SMALL_STATE(43)] = 428, + [SMALL_STATE(44)] = 435, + [SMALL_STATE(45)] = 439, + [SMALL_STATE(46)] = 443, + [SMALL_STATE(47)] = 447, + [SMALL_STATE(48)] = 451, + [SMALL_STATE(49)] = 455, }; 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}}, REDUCE(sym_metadata, 0), - [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT(41), - [7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), - [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(47), - [11] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_metadata, 1), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), - [15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15), - [17] = {.entry = {.count = 1, .reusable = false}}, SHIFT(10), - [19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), - [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_metadata_repeat1, 2), - [23] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_metadata_repeat1, 2), SHIFT_REPEAT(41), - [26] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_metadata_repeat1, 2), SHIFT_REPEAT(24), - [29] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_metadata_repeat1, 2), SHIFT_REPEAT(47), - [32] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), - [34] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), - [36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(9), + [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(47), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), + [9] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(13), + [12] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(6), + [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), + [17] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(19), + [20] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [22] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), + [24] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), + [26] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [28] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), + [30] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), + [32] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), + [34] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), + [36] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(32), - [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(23), - [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(30), - [44] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_array_repeat1, 2, .production_id = 4), - [46] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_array_repeat1, 2, .production_id = 4), SHIFT_REPEAT(30), - [49] = {.entry = {.count = 1, .reusable = false}}, SHIFT(38), - [51] = {.entry = {.count = 1, .reusable = false}}, SHIFT(36), - [53] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), - [55] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_object_repeat1, 2), SHIFT_REPEAT(41), - [58] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_object_repeat1, 2), - [60] = {.entry = {.count = 1, .reusable = false}}, SHIFT(37), - [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_value, 2), - [64] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_value, 2), - [66] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), - [68] = {.entry = {.count = 1, .reusable = false}}, SHIFT(35), - [70] = {.entry = {.count = 1, .reusable = false}}, SHIFT(19), - [72] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_value, 1), - [74] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_value, 1), - [76] = {.entry = {.count = 1, .reusable = false}}, SHIFT(22), - [78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_named_delimiter, 4, .production_id = 1), - [80] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_named_delimiter, 4, .production_id = 1), - [82] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 2), - [84] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_object, 2), - [86] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2), - [88] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array, 2), - [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 3), - [92] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_pair, 3), - [94] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 3), - [96] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_object, 3), - [98] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3, .production_id = 3), - [100] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array, 3, .production_id = 3), - [102] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_delimiter, 1), - [104] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_delimiter, 1), - [106] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [108] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), - [110] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_value_repeat1, 2), SHIFT_REPEAT(40), - [113] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), - [115] = {.entry = {.count = 1, .reusable = false}}, SHIFT(42), - [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_array_repeat1, 1, .production_id = 2), - [119] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), - [121] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), - [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__text_with_trailing_modifier, 2), - [125] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), - [127] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__key, 2), - [129] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), - [131] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), - [135] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), + [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4), + [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17), + [44] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), + [46] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15), + [48] = {.entry = {.count = 1, .reusable = false}}, SHIFT(7), + [50] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), + [52] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), + [54] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_metadata, 1), + [56] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_metadata_repeat1, 2), + [58] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_metadata_repeat1, 2), SHIFT_REPEAT(47), + [61] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_metadata_repeat1, 2), SHIFT_REPEAT(46), + [64] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_value, 1), + [66] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), + [68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_value, 1), + [70] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_object_repeat1, 2), SHIFT_REPEAT(49), + [73] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_object_repeat1, 2), + [75] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), + [77] = {.entry = {.count = 1, .reusable = false}}, SHIFT(49), + [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(38), + [81] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), + [83] = {.entry = {.count = 1, .reusable = false}}, SHIFT(22), + [85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(25), + [87] = {.entry = {.count = 1, .reusable = false}}, SHIFT(30), + [89] = {.entry = {.count = 1, .reusable = false}}, SHIFT(33), + [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 3), + [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3), + [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_value, 3, .production_id = 1), + [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 2), + [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2), + [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 4), + [103] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), + [105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_delimiter, 2), + [107] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array, 3), + [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_value, 3, .production_id = 1), + [111] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_object, 3), + [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_pair, 4), + [115] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_object, 2), + [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array, 2), + [119] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [121] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [123] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [125] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), + [129] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), + [131] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), }; #ifdef __cplusplus @@ -1161,9 +1022,6 @@ extern const TSLanguage *tree_sitter_norg_meta(void) { .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, diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index cbbc7b4..2b14ac1 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -123,6 +123,7 @@ struct TSLanguage { unsigned (*serialize)(void *, char *); void (*deserialize)(void *, const char *, unsigned); } external_scanner; + const TSStateId *primary_state_ids; }; /* diff --git a/test/corpus/document.meta.txt b/test/corpus/document.meta.txt index 15a0ec6..43c1e46 100644 --- a/test/corpus/document.meta.txt +++ b/test/corpus/document.meta.txt @@ -95,9 +95,7 @@ author: nvim-neorg (key) (value) ) - (delimiter - (named_delimiter) - ) + (delimiter) (pair (key) (value) @@ -173,9 +171,9 @@ key: [ (pair (key) (array - item: (value) - item: (value) - item: (value) + (value) + (value) + (value) ) ) ) @@ -198,9 +196,9 @@ object: { (pair (key) (array - item: (value) - item: (value) - item: (value) + (value) + (value) + (value) ) ) ) @@ -221,9 +219,9 @@ array: [ (pair (key) (array - item: (value) - item: (value) - item: (value) + (value) + (value) + (value) ) ) )