add inline connection

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-04 03:21:42 +03:00
parent a5059fd3de
commit 558206b641
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
5 changed files with 462 additions and 383 deletions

View file

@ -12,12 +12,7 @@ module.exports = grammar({
_end: ($) => choice(";", "\n"),
connection: ($) =>
seq(
field("left", $.identifier),
$.arrow,
field("right", $.identifier),
$._end
),
seq($.identifier, repeat1(seq($.arrow, $.identifier)), $._end),
shape: ($) => seq($.identifier, optional(seq(":", $.label)), $._end),

View file

@ -37,24 +37,24 @@
"connection": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "SYMBOL",
"name": "arrow"
"name": "identifier"
},
{
"type": "FIELD",
"name": "right",
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "identifier"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "arrow"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
}
},
{

View file

@ -7,35 +7,18 @@
{
"type": "connection",
"named": true,
"fields": {
"left": {
"multiple": false,
"required": true,
"types": [
{
"type": "identifier",
"named": true
}
]
},
"right": {
"multiple": false,
"required": true,
"types": [
{
"type": "identifier",
"named": true
}
]
}
},
"fields": {},
"children": {
"multiple": false,
"multiple": true,
"required": true,
"types": [
{
"type": "arrow",
"named": true
},
{
"type": "identifier",
"named": true
}
]
}

View file

@ -6,15 +6,15 @@
#endif
#define LANGUAGE_VERSION 14
#define STATE_COUNT 36
#define STATE_COUNT 38
#define LARGE_STATE_COUNT 2
#define SYMBOL_COUNT 27
#define SYMBOL_COUNT 28
#define ALIAS_COUNT 0
#define TOKEN_COUNT 15
#define EXTERNAL_TOKEN_COUNT 1
#define FIELD_COUNT 2
#define FIELD_COUNT 0
#define MAX_ALIAS_SEQUENCE_LENGTH 4
#define PRODUCTION_ID_COUNT 2
#define PRODUCTION_ID_COUNT 1
enum {
anon_sym_SEMI = 1,
@ -41,8 +41,9 @@ enum {
sym_arrow = 22,
sym_string = 23,
aux_sym_source_file_repeat1 = 24,
aux_sym_arrow_repeat1 = 25,
aux_sym_string_repeat1 = 26,
aux_sym_connection_repeat1 = 25,
aux_sym_arrow_repeat1 = 26,
aux_sym_string_repeat1 = 27,
};
static const char * const ts_symbol_names[] = {
@ -71,6 +72,7 @@ static const char * const ts_symbol_names[] = {
[sym_arrow] = "arrow",
[sym_string] = "string",
[aux_sym_source_file_repeat1] = "source_file_repeat1",
[aux_sym_connection_repeat1] = "connection_repeat1",
[aux_sym_arrow_repeat1] = "arrow_repeat1",
[aux_sym_string_repeat1] = "string_repeat1",
};
@ -101,6 +103,7 @@ static const TSSymbol ts_symbol_map[] = {
[sym_arrow] = sym_arrow,
[sym_string] = sym_string,
[aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1,
[aux_sym_connection_repeat1] = aux_sym_connection_repeat1,
[aux_sym_arrow_repeat1] = aux_sym_arrow_repeat1,
[aux_sym_string_repeat1] = aux_sym_string_repeat1,
};
@ -206,6 +209,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = false,
.named = false,
},
[aux_sym_connection_repeat1] = {
.visible = false,
.named = false,
},
[aux_sym_arrow_repeat1] = {
.visible = false,
.named = false,
@ -216,27 +223,6 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
},
};
enum {
field_left = 1,
field_right = 2,
};
static const char * const ts_field_names[] = {
[0] = NULL,
[field_left] = "left",
[field_right] = "right",
};
static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = {
[1] = {.index = 0, .length = 2},
};
static const TSFieldMapEntry ts_field_map_entries[] = {
[0] =
{field_left, 0},
{field_right, 2},
};
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
[0] = {0},
};
@ -257,20 +243,20 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
[8] = 8,
[9] = 9,
[10] = 10,
[11] = 7,
[11] = 11,
[12] = 12,
[13] = 13,
[14] = 12,
[14] = 13,
[15] = 15,
[16] = 16,
[16] = 13,
[17] = 17,
[18] = 18,
[19] = 19,
[20] = 20,
[21] = 12,
[21] = 21,
[22] = 22,
[23] = 23,
[24] = 24,
[24] = 11,
[25] = 25,
[26] = 26,
[27] = 27,
@ -282,6 +268,8 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
[33] = 33,
[34] = 34,
[35] = 35,
[36] = 36,
[37] = 37,
};
static bool ts_lex(TSLexer *lexer, TSStateId state) {
@ -327,15 +315,6 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
END_STATE();
case 3:
if (lookahead == '\n') SKIP(3)
if (lookahead == '`') ADVANCE(33);
if (lookahead == '\t' ||
lookahead == '\r' ||
lookahead == ' ') ADVANCE(25);
if (lookahead != 0 &&
lookahead != '\'') ADVANCE(27);
END_STATE();
case 4:
if (lookahead == '\n') SKIP(4)
if (lookahead == '"') ADVANCE(30);
if (lookahead == '\t' ||
lookahead == '\r' ||
@ -343,14 +322,23 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
if (lookahead != 0 &&
lookahead != '\'') ADVANCE(27);
END_STATE();
case 5:
if (lookahead == '\n') SKIP(5)
case 4:
if (lookahead == '\n') SKIP(4)
if (lookahead == '\'') ADVANCE(22);
if (lookahead == '\t' ||
lookahead == '\r' ||
lookahead == ' ') ADVANCE(26);
if (lookahead != 0) ADVANCE(27);
END_STATE();
case 5:
if (lookahead == '\n') SKIP(5)
if (lookahead == '`') ADVANCE(33);
if (lookahead == '\t' ||
lookahead == '\r' ||
lookahead == ' ') ADVANCE(25);
if (lookahead != 0 &&
lookahead != '\'') ADVANCE(27);
END_STATE();
case 6:
if (lookahead == '-') ADVANCE(19);
END_STATE();
@ -512,39 +500,41 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = {
[0] = {.lex_state = 0, .external_lex_state = 1},
[1] = {.lex_state = 0, .external_lex_state = 1},
[2] = {.lex_state = 1},
[3] = {.lex_state = 0, .external_lex_state = 1},
[3] = {.lex_state = 1},
[4] = {.lex_state = 1},
[5] = {.lex_state = 0, .external_lex_state = 1},
[6] = {.lex_state = 2},
[7] = {.lex_state = 7, .external_lex_state = 1},
[8] = {.lex_state = 7, .external_lex_state = 1},
[9] = {.lex_state = 7, .external_lex_state = 1},
[10] = {.lex_state = 3},
[11] = {.lex_state = 8},
[12] = {.lex_state = 3},
[13] = {.lex_state = 8},
[5] = {.lex_state = 1},
[6] = {.lex_state = 0, .external_lex_state = 1},
[7] = {.lex_state = 0, .external_lex_state = 1},
[8] = {.lex_state = 2},
[9] = {.lex_state = 1},
[10] = {.lex_state = 7, .external_lex_state = 1},
[11] = {.lex_state = 7, .external_lex_state = 1},
[12] = {.lex_state = 7, .external_lex_state = 1},
[13] = {.lex_state = 3},
[14] = {.lex_state = 4},
[15] = {.lex_state = 5},
[16] = {.lex_state = 4},
[17] = {.lex_state = 3},
[18] = {.lex_state = 1},
[19] = {.lex_state = 7, .external_lex_state = 1},
[20] = {.lex_state = 7, .external_lex_state = 1},
[21] = {.lex_state = 5},
[22] = {.lex_state = 1},
[23] = {.lex_state = 4},
[24] = {.lex_state = 5},
[25] = {.lex_state = 1},
[26] = {.lex_state = 0, .external_lex_state = 1},
[27] = {.lex_state = 0, .external_lex_state = 1},
[15] = {.lex_state = 8},
[16] = {.lex_state = 5},
[17] = {.lex_state = 5},
[18] = {.lex_state = 4},
[19] = {.lex_state = 3},
[20] = {.lex_state = 5},
[21] = {.lex_state = 1},
[22] = {.lex_state = 7, .external_lex_state = 1},
[23] = {.lex_state = 7, .external_lex_state = 1},
[24] = {.lex_state = 8},
[25] = {.lex_state = 3},
[26] = {.lex_state = 4},
[27] = {.lex_state = 1},
[28] = {.lex_state = 0, .external_lex_state = 1},
[29] = {.lex_state = 1},
[29] = {.lex_state = 0, .external_lex_state = 1},
[30] = {.lex_state = 1},
[31] = {.lex_state = 0, .external_lex_state = 1},
[31] = {.lex_state = 1},
[32] = {.lex_state = 0, .external_lex_state = 1},
[33] = {.lex_state = 0, .external_lex_state = 1},
[34] = {.lex_state = 0},
[35] = {.lex_state = 0, .external_lex_state = 1},
[34] = {.lex_state = 0, .external_lex_state = 1},
[35] = {.lex_state = 0},
[36] = {.lex_state = 0, .external_lex_state = 1},
[37] = {.lex_state = 0, .external_lex_state = 1},
};
enum {
@ -577,19 +567,19 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym__identifier] = ACTIONS(1),
},
[1] = {
[sym_source_file] = STATE(34),
[sym__definition] = STATE(5),
[sym_connection] = STATE(5),
[sym_shape] = STATE(5),
[sym_source_file] = STATE(35),
[sym__definition] = STATE(6),
[sym_connection] = STATE(6),
[sym_shape] = STATE(6),
[sym_identifier] = STATE(2),
[aux_sym_source_file_repeat1] = STATE(5),
[aux_sym_source_file_repeat1] = STATE(6),
[ts_builtin_sym_end] = ACTIONS(3),
[sym__identifier] = ACTIONS(5),
},
};
static const uint16_t ts_small_parse_table[] = {
[0] = 10,
[0] = 11,
ACTIONS(7), 1,
anon_sym_SEMI,
ACTIONS(9), 1,
@ -604,332 +594,384 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_LT_DASH,
ACTIONS(19), 1,
anon_sym_DASH_GT,
STATE(13), 1,
STATE(3), 1,
aux_sym_connection_repeat1,
STATE(15), 1,
aux_sym_arrow_repeat1,
STATE(26), 1,
sym__end,
STATE(31), 1,
STATE(32), 1,
sym_arrow,
[31] = 4,
STATE(33), 1,
sym__end,
[34] = 10,
ACTIONS(13), 1,
anon_sym_DASH_DASH,
ACTIONS(15), 1,
anon_sym_DASH,
ACTIONS(17), 1,
anon_sym_LT_DASH,
ACTIONS(19), 1,
anon_sym_DASH_GT,
ACTIONS(21), 1,
ts_builtin_sym_end,
anon_sym_SEMI,
ACTIONS(23), 1,
sym__identifier,
STATE(2), 1,
sym_identifier,
STATE(3), 4,
sym__definition,
sym_connection,
sym_shape,
aux_sym_source_file_repeat1,
[47] = 2,
ACTIONS(28), 1,
anon_sym_LF,
ACTIONS(26), 6,
STATE(4), 1,
aux_sym_connection_repeat1,
STATE(15), 1,
aux_sym_arrow_repeat1,
STATE(28), 1,
sym__end,
STATE(32), 1,
sym_arrow,
[65] = 9,
ACTIONS(25), 1,
anon_sym_SEMI,
ACTIONS(27), 1,
anon_sym_LF,
ACTIONS(29), 1,
anon_sym_DASH_DASH,
ACTIONS(32), 1,
anon_sym_DASH,
ACTIONS(35), 1,
anon_sym_LT_DASH,
ACTIONS(38), 1,
anon_sym_DASH_GT,
STATE(4), 1,
aux_sym_connection_repeat1,
STATE(15), 1,
aux_sym_arrow_repeat1,
STATE(32), 1,
sym_arrow,
[93] = 2,
ACTIONS(43), 1,
anon_sym_LF,
ACTIONS(41), 6,
anon_sym_SEMI,
anon_sym_COLON,
anon_sym_DASH_DASH,
anon_sym_DASH,
anon_sym_LT_DASH,
anon_sym_DASH_GT,
[59] = 4,
[105] = 4,
ACTIONS(5), 1,
sym__identifier,
ACTIONS(30), 1,
ACTIONS(45), 1,
ts_builtin_sym_end,
STATE(2), 1,
sym_identifier,
STATE(3), 4,
STATE(7), 4,
sym__definition,
sym_connection,
sym_shape,
aux_sym_source_file_repeat1,
[75] = 6,
ACTIONS(32), 1,
[121] = 4,
ACTIONS(47), 1,
ts_builtin_sym_end,
ACTIONS(49), 1,
sym__identifier,
STATE(2), 1,
sym_identifier,
STATE(7), 4,
sym__definition,
sym_connection,
sym_shape,
aux_sym_source_file_repeat1,
[137] = 6,
ACTIONS(52), 1,
aux_sym_label_token1,
ACTIONS(34), 1,
ACTIONS(54), 1,
anon_sym_SQUOTE,
ACTIONS(36), 1,
ACTIONS(56), 1,
anon_sym_DQUOTE,
ACTIONS(38), 1,
ACTIONS(58), 1,
anon_sym_BQUOTE,
STATE(18), 1,
STATE(21), 1,
sym_label,
STATE(30), 1,
STATE(31), 1,
sym_string,
[94] = 3,
ACTIONS(40), 1,
[156] = 2,
ACTIONS(27), 1,
anon_sym_LF,
ACTIONS(25), 5,
anon_sym_SEMI,
anon_sym_DASH_DASH,
anon_sym_DASH,
STATE(7), 1,
aux_sym_arrow_repeat1,
ACTIONS(43), 2,
sym__identifier,
anon_sym_GT,
[105] = 4,
ACTIONS(45), 1,
anon_sym_DASH,
ACTIONS(47), 1,
anon_sym_GT,
ACTIONS(49), 1,
sym__identifier,
STATE(9), 1,
aux_sym_arrow_repeat1,
[118] = 4,
ACTIONS(51), 1,
anon_sym_DASH,
ACTIONS(53), 1,
anon_sym_GT,
ACTIONS(55), 1,
sym__identifier,
STATE(7), 1,
aux_sym_arrow_repeat1,
[131] = 3,
ACTIONS(57), 1,
aux_sym_string_token1,
ACTIONS(59), 1,
anon_sym_BQUOTE,
STATE(12), 1,
aux_sym_string_repeat1,
[141] = 3,
ACTIONS(43), 1,
anon_sym_LT_DASH,
anon_sym_DASH_GT,
ACTIONS(61), 1,
[167] = 4,
ACTIONS(60), 1,
anon_sym_DASH,
STATE(11), 1,
aux_sym_arrow_repeat1,
[151] = 3,
ACTIONS(62), 1,
anon_sym_GT,
ACTIONS(64), 1,
aux_sym_string_token1,
ACTIONS(67), 1,
anon_sym_BQUOTE,
sym__identifier,
STATE(12), 1,
aux_sym_string_repeat1,
[161] = 3,
ACTIONS(47), 1,
anon_sym_DASH_GT,
ACTIONS(69), 1,
aux_sym_arrow_repeat1,
[180] = 3,
ACTIONS(66), 1,
anon_sym_DASH,
STATE(11), 1,
aux_sym_arrow_repeat1,
[171] = 3,
ACTIONS(67), 1,
anon_sym_DQUOTE,
ACTIONS(69), 2,
sym__identifier,
anon_sym_GT,
[191] = 4,
ACTIONS(71), 1,
anon_sym_DASH,
ACTIONS(73), 1,
anon_sym_GT,
ACTIONS(75), 1,
sym__identifier,
STATE(11), 1,
aux_sym_arrow_repeat1,
[204] = 3,
ACTIONS(77), 1,
aux_sym_string_token1,
STATE(14), 1,
aux_sym_string_repeat1,
[181] = 3,
ACTIONS(74), 1,
anon_sym_SQUOTE,
ACTIONS(76), 1,
aux_sym_string_token1,
STATE(24), 1,
aux_sym_string_repeat1,
[191] = 3,
ACTIONS(74), 1,
anon_sym_DQUOTE,
ACTIONS(78), 1,
aux_sym_string_token1,
STATE(23), 1,
aux_sym_string_repeat1,
[201] = 3,
ACTIONS(74), 1,
anon_sym_BQUOTE,
ACTIONS(80), 1,
aux_sym_string_token1,
STATE(10), 1,
aux_sym_string_repeat1,
[211] = 3,
ACTIONS(82), 1,
anon_sym_SEMI,
ACTIONS(84), 1,
anon_sym_LF,
STATE(27), 1,
sym__end,
[221] = 3,
ACTIONS(51), 1,
anon_sym_DASH,
ACTIONS(55), 1,
sym__identifier,
STATE(7), 1,
aux_sym_arrow_repeat1,
[231] = 3,
ACTIONS(49), 1,
sym__identifier,
ACTIONS(86), 1,
anon_sym_DASH,
STATE(19), 1,
aux_sym_arrow_repeat1,
[241] = 3,
ACTIONS(67), 1,
anon_sym_SQUOTE,
ACTIONS(88), 1,
aux_sym_string_token1,
STATE(21), 1,
aux_sym_string_repeat1,
[251] = 3,
ACTIONS(91), 1,
anon_sym_SEMI,
ACTIONS(93), 1,
anon_sym_LF,
STATE(28), 1,
sym__end,
[261] = 3,
ACTIONS(59), 1,
anon_sym_DQUOTE,
ACTIONS(95), 1,
STATE(13), 1,
aux_sym_string_repeat1,
[214] = 3,
ACTIONS(80), 1,
anon_sym_SQUOTE,
ACTIONS(82), 1,
aux_sym_string_token1,
STATE(14), 1,
aux_sym_string_repeat1,
[271] = 3,
ACTIONS(59), 1,
anon_sym_SQUOTE,
ACTIONS(97), 1,
[224] = 3,
ACTIONS(62), 1,
anon_sym_DASH_GT,
ACTIONS(85), 1,
anon_sym_DASH,
STATE(24), 1,
aux_sym_arrow_repeat1,
[234] = 3,
ACTIONS(80), 1,
anon_sym_BQUOTE,
ACTIONS(87), 1,
aux_sym_string_token1,
STATE(21), 1,
STATE(16), 1,
aux_sym_string_repeat1,
[281] = 2,
ACTIONS(99), 1,
[244] = 3,
ACTIONS(90), 1,
aux_sym_string_token1,
ACTIONS(92), 1,
anon_sym_BQUOTE,
STATE(16), 1,
aux_sym_string_repeat1,
[254] = 3,
ACTIONS(94), 1,
anon_sym_SQUOTE,
ACTIONS(96), 1,
aux_sym_string_token1,
STATE(26), 1,
aux_sym_string_repeat1,
[264] = 3,
ACTIONS(94), 1,
anon_sym_DQUOTE,
ACTIONS(98), 1,
aux_sym_string_token1,
STATE(25), 1,
aux_sym_string_repeat1,
[274] = 3,
ACTIONS(94), 1,
anon_sym_BQUOTE,
ACTIONS(100), 1,
aux_sym_string_token1,
STATE(17), 1,
aux_sym_string_repeat1,
[284] = 3,
ACTIONS(102), 1,
anon_sym_SEMI,
ACTIONS(101), 1,
ACTIONS(104), 1,
anon_sym_LF,
[288] = 1,
ACTIONS(103), 2,
STATE(29), 1,
sym__end,
[294] = 3,
ACTIONS(71), 1,
anon_sym_DASH,
ACTIONS(75), 1,
sym__identifier,
ts_builtin_sym_end,
[293] = 1,
ACTIONS(105), 2,
STATE(11), 1,
aux_sym_arrow_repeat1,
[304] = 3,
ACTIONS(64), 1,
sym__identifier,
ts_builtin_sym_end,
[298] = 1,
ACTIONS(107), 2,
sym__identifier,
ts_builtin_sym_end,
[303] = 2,
ACTIONS(109), 1,
anon_sym_SEMI,
ACTIONS(106), 1,
anon_sym_DASH,
STATE(22), 1,
aux_sym_arrow_repeat1,
[314] = 3,
ACTIONS(69), 1,
anon_sym_DASH_GT,
ACTIONS(108), 1,
anon_sym_DASH,
STATE(24), 1,
aux_sym_arrow_repeat1,
[324] = 3,
ACTIONS(92), 1,
anon_sym_DQUOTE,
ACTIONS(111), 1,
anon_sym_LF,
[310] = 2,
aux_sym_string_token1,
STATE(13), 1,
aux_sym_string_repeat1,
[334] = 3,
ACTIONS(92), 1,
anon_sym_SQUOTE,
ACTIONS(113), 1,
anon_sym_SEMI,
aux_sym_string_token1,
STATE(14), 1,
aux_sym_string_repeat1,
[344] = 2,
ACTIONS(115), 1,
anon_sym_SEMI,
ACTIONS(117), 1,
anon_sym_LF,
[317] = 2,
[351] = 1,
ACTIONS(119), 2,
sym__identifier,
ts_builtin_sym_end,
[356] = 1,
ACTIONS(121), 2,
sym__identifier,
ts_builtin_sym_end,
[361] = 2,
ACTIONS(123), 1,
anon_sym_SEMI,
ACTIONS(125), 1,
anon_sym_LF,
[368] = 2,
ACTIONS(127), 1,
anon_sym_SEMI,
ACTIONS(129), 1,
anon_sym_LF,
[375] = 2,
ACTIONS(5), 1,
sym__identifier,
STATE(22), 1,
STATE(9), 1,
sym_identifier,
[324] = 1,
ACTIONS(49), 1,
[382] = 1,
ACTIONS(131), 2,
sym__identifier,
[328] = 1,
ACTIONS(117), 1,
sym__identifier,
[332] = 1,
ACTIONS(119), 1,
ts_builtin_sym_end,
[336] = 1,
ACTIONS(55), 1,
[387] = 1,
ACTIONS(75), 1,
sym__identifier,
[391] = 1,
ACTIONS(133), 1,
ts_builtin_sym_end,
[395] = 1,
ACTIONS(135), 1,
sym__identifier,
[399] = 1,
ACTIONS(64), 1,
sym__identifier,
};
static const uint32_t ts_small_parse_table_map[] = {
[SMALL_STATE(2)] = 0,
[SMALL_STATE(3)] = 31,
[SMALL_STATE(4)] = 47,
[SMALL_STATE(5)] = 59,
[SMALL_STATE(6)] = 75,
[SMALL_STATE(7)] = 94,
[SMALL_STATE(8)] = 105,
[SMALL_STATE(9)] = 118,
[SMALL_STATE(10)] = 131,
[SMALL_STATE(11)] = 141,
[SMALL_STATE(12)] = 151,
[SMALL_STATE(13)] = 161,
[SMALL_STATE(14)] = 171,
[SMALL_STATE(15)] = 181,
[SMALL_STATE(16)] = 191,
[SMALL_STATE(17)] = 201,
[SMALL_STATE(18)] = 211,
[SMALL_STATE(19)] = 221,
[SMALL_STATE(20)] = 231,
[SMALL_STATE(21)] = 241,
[SMALL_STATE(22)] = 251,
[SMALL_STATE(23)] = 261,
[SMALL_STATE(24)] = 271,
[SMALL_STATE(25)] = 281,
[SMALL_STATE(26)] = 288,
[SMALL_STATE(27)] = 293,
[SMALL_STATE(28)] = 298,
[SMALL_STATE(29)] = 303,
[SMALL_STATE(30)] = 310,
[SMALL_STATE(31)] = 317,
[SMALL_STATE(32)] = 324,
[SMALL_STATE(33)] = 328,
[SMALL_STATE(34)] = 332,
[SMALL_STATE(35)] = 336,
[SMALL_STATE(3)] = 34,
[SMALL_STATE(4)] = 65,
[SMALL_STATE(5)] = 93,
[SMALL_STATE(6)] = 105,
[SMALL_STATE(7)] = 121,
[SMALL_STATE(8)] = 137,
[SMALL_STATE(9)] = 156,
[SMALL_STATE(10)] = 167,
[SMALL_STATE(11)] = 180,
[SMALL_STATE(12)] = 191,
[SMALL_STATE(13)] = 204,
[SMALL_STATE(14)] = 214,
[SMALL_STATE(15)] = 224,
[SMALL_STATE(16)] = 234,
[SMALL_STATE(17)] = 244,
[SMALL_STATE(18)] = 254,
[SMALL_STATE(19)] = 264,
[SMALL_STATE(20)] = 274,
[SMALL_STATE(21)] = 284,
[SMALL_STATE(22)] = 294,
[SMALL_STATE(23)] = 304,
[SMALL_STATE(24)] = 314,
[SMALL_STATE(25)] = 324,
[SMALL_STATE(26)] = 334,
[SMALL_STATE(27)] = 344,
[SMALL_STATE(28)] = 351,
[SMALL_STATE(29)] = 356,
[SMALL_STATE(30)] = 361,
[SMALL_STATE(31)] = 368,
[SMALL_STATE(32)] = 375,
[SMALL_STATE(33)] = 382,
[SMALL_STATE(34)] = 387,
[SMALL_STATE(35)] = 391,
[SMALL_STATE(36)] = 395,
[SMALL_STATE(37)] = 399,
};
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_source_file, 0),
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
[7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(26),
[9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26),
[11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(6),
[13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20),
[15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(13),
[17] = {.entry = {.count = 1, .reusable = false}}, SHIFT(8),
[19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(32),
[21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2),
[23] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(4),
[26] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1),
[28] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1),
[30] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1),
[32] = {.entry = {.count = 1, .reusable = false}}, SHIFT(30),
[34] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15),
[36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16),
[38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17),
[40] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_arrow_repeat1, 2), SHIFT_REPEAT(7),
[43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_arrow_repeat1, 2),
[45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9),
[47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35),
[49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arrow, 1),
[51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),
[53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33),
[55] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arrow, 2),
[57] = {.entry = {.count = 1, .reusable = false}}, SHIFT(12),
[59] = {.entry = {.count = 1, .reusable = false}}, SHIFT(29),
[61] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_arrow_repeat1, 2), SHIFT_REPEAT(11),
[64] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(12),
[67] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2),
[69] = {.entry = {.count = 1, .reusable = false}}, SHIFT(11),
[71] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(14),
[74] = {.entry = {.count = 1, .reusable = false}}, SHIFT(25),
[76] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24),
[78] = {.entry = {.count = 1, .reusable = false}}, SHIFT(23),
[80] = {.entry = {.count = 1, .reusable = false}}, SHIFT(10),
[82] = {.entry = {.count = 1, .reusable = false}}, SHIFT(27),
[84] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27),
[86] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19),
[88] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(21),
[91] = {.entry = {.count = 1, .reusable = false}}, SHIFT(28),
[93] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28),
[95] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14),
[97] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21),
[99] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string, 2),
[101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2),
[103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_shape, 2),
[105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_shape, 4),
[107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_connection, 4, .production_id = 1),
[109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string, 3),
[111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3),
[113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_label, 1),
[115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_label, 1),
[117] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arrow, 3),
[119] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),
[7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(33),
[9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33),
[11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(8),
[13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(23),
[15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15),
[17] = {.entry = {.count = 1, .reusable = false}}, SHIFT(10),
[19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(37),
[21] = {.entry = {.count = 1, .reusable = false}}, SHIFT(28),
[23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28),
[25] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_connection_repeat1, 2),
[27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_connection_repeat1, 2),
[29] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_connection_repeat1, 2), SHIFT_REPEAT(23),
[32] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_connection_repeat1, 2), SHIFT_REPEAT(15),
[35] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_connection_repeat1, 2), SHIFT_REPEAT(10),
[38] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_connection_repeat1, 2), SHIFT_REPEAT(37),
[41] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1),
[43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1),
[45] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1),
[47] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2),
[49] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(5),
[52] = {.entry = {.count = 1, .reusable = false}}, SHIFT(31),
[54] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18),
[56] = {.entry = {.count = 1, .reusable = false}}, SHIFT(19),
[58] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20),
[60] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12),
[62] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34),
[64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arrow, 1),
[66] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_arrow_repeat1, 2), SHIFT_REPEAT(11),
[69] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_arrow_repeat1, 2),
[71] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11),
[73] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36),
[75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arrow, 2),
[77] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(13),
[80] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2),
[82] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(14),
[85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24),
[87] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(16),
[90] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16),
[92] = {.entry = {.count = 1, .reusable = false}}, SHIFT(30),
[94] = {.entry = {.count = 1, .reusable = false}}, SHIFT(27),
[96] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26),
[98] = {.entry = {.count = 1, .reusable = false}}, SHIFT(25),
[100] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17),
[102] = {.entry = {.count = 1, .reusable = false}}, SHIFT(29),
[104] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29),
[106] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22),
[108] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_arrow_repeat1, 2), SHIFT_REPEAT(24),
[111] = {.entry = {.count = 1, .reusable = false}}, SHIFT(13),
[113] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14),
[115] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string, 2),
[117] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2),
[119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_connection, 3),
[121] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_shape, 4),
[123] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string, 3),
[125] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3),
[127] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_label, 1),
[129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_label, 1),
[131] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_shape, 2),
[133] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
[135] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arrow, 3),
};
#ifdef __cplusplus
@ -962,9 +1004,6 @@ extern const TSLanguage *tree_sitter_d2(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,

View file

@ -1,13 +1,75 @@
==================
Simple name
Simple connection
==================
foo--bar
biz->baz
biz<->baz
biz<-baz
---
(source_file
(connection
left: (identifier)
(identifier)
(arrow)
right: (identifier)))
(identifier)
)
(connection
(identifier)
(arrow)
(identifier)
)
(connection
(identifier)
(arrow)
(identifier)
)
(connection
(identifier)
(arrow)
(identifier)
)
)
=============================
Complex identifier connection
=============================
Foo Bar -- Biz Baz
-Bar-Foo- <- -Baz-Biz-
---
(source_file
(connection
(identifier)
(arrow)
(identifier)
)
(connection
(identifier)
(arrow)
(identifier)
)
)
==================
Inline connection
==================
foo--bar->biz->baz
---
(source_file
(connection
(identifier)
(arrow)
(identifier)
(arrow)
(identifier)
(arrow)
(identifier)
)
)