⬆️ tree-sitter-cli

This commit is contained in:
Max Brunsfeld 2020-05-14 14:49:20 -07:00
parent 8791121881
commit 047eafe80c
3 changed files with 154 additions and 142 deletions

View File

@ -16,7 +16,7 @@
"nan": "^2.14.0"
},
"devDependencies": {
"tree-sitter-cli": "^0.16.5"
"tree-sitter-cli": "^0.16.7"
},
"scripts": {
"test": "tree-sitter test && tree-sitter parse examples/*.html --quiet --time",

244
src/parser.c vendored
View File

@ -1743,128 +1743,128 @@ static uint32_t ts_small_parse_table_map[] = {
};
static TSParseActionEntry ts_parse_actions[] = {
[0] = {.count = 0, .reusable = false},
[1] = {.count = 1, .reusable = false}, RECOVER(),
[3] = {.count = 1, .reusable = true}, SHIFT_EXTRA(),
[5] = {.count = 1, .reusable = true}, REDUCE(sym_fragment, 0),
[7] = {.count = 1, .reusable = false}, SHIFT(75),
[9] = {.count = 1, .reusable = false}, SHIFT(52),
[11] = {.count = 1, .reusable = false}, SHIFT(81),
[13] = {.count = 1, .reusable = true}, SHIFT(8),
[15] = {.count = 1, .reusable = false}, SHIFT(93),
[17] = {.count = 1, .reusable = false}, SHIFT(51),
[19] = {.count = 1, .reusable = false}, SHIFT(66),
[21] = {.count = 1, .reusable = true}, SHIFT(6),
[23] = {.count = 1, .reusable = true}, SHIFT(36),
[25] = {.count = 1, .reusable = false}, SHIFT(62),
[27] = {.count = 1, .reusable = true}, SHIFT(22),
[29] = {.count = 1, .reusable = true}, SHIFT(2),
[31] = {.count = 1, .reusable = true}, SHIFT(17),
[33] = {.count = 1, .reusable = true}, SHIFT(3),
[35] = {.count = 1, .reusable = true}, SHIFT(12),
[37] = {.count = 2, .reusable = false}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(93),
[40] = {.count = 2, .reusable = false}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(51),
[43] = {.count = 2, .reusable = false}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(89),
[46] = {.count = 2, .reusable = true}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(6),
[49] = {.count = 1, .reusable = true}, REDUCE(aux_sym_fragment_repeat1, 2),
[51] = {.count = 2, .reusable = false}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(75),
[54] = {.count = 2, .reusable = false}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(52),
[57] = {.count = 2, .reusable = false}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(81),
[60] = {.count = 2, .reusable = true}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(7),
[63] = {.count = 1, .reusable = true}, REDUCE(sym_fragment, 1),
[65] = {.count = 1, .reusable = true}, SHIFT(7),
[67] = {.count = 1, .reusable = true}, SHIFT(26),
[69] = {.count = 1, .reusable = true}, SHIFT(27),
[71] = {.count = 1, .reusable = true}, SHIFT(43),
[73] = {.count = 1, .reusable = true}, REDUCE(sym_script_element, 3),
[75] = {.count = 1, .reusable = false}, REDUCE(sym_script_element, 3),
[77] = {.count = 1, .reusable = true}, REDUCE(sym_element, 1),
[79] = {.count = 1, .reusable = false}, REDUCE(sym_element, 1),
[81] = {.count = 1, .reusable = false}, REDUCE(sym_element, 2),
[83] = {.count = 1, .reusable = true}, REDUCE(sym_element, 2),
[85] = {.count = 1, .reusable = false}, REDUCE(sym_script_element, 2),
[87] = {.count = 1, .reusable = true}, REDUCE(sym_script_element, 2),
[89] = {.count = 1, .reusable = true}, SHIFT(33),
[91] = {.count = 1, .reusable = true}, SHIFT(16),
[93] = {.count = 1, .reusable = false}, REDUCE(sym_self_closing_tag, 4),
[95] = {.count = 1, .reusable = true}, REDUCE(sym_self_closing_tag, 4),
[97] = {.count = 1, .reusable = false}, REDUCE(sym_doctype, 4),
[99] = {.count = 1, .reusable = true}, REDUCE(sym_doctype, 4),
[101] = {.count = 1, .reusable = false}, REDUCE(sym_style_element, 3),
[103] = {.count = 1, .reusable = true}, REDUCE(sym_style_element, 3),
[105] = {.count = 1, .reusable = false}, REDUCE(sym_element, 3),
[107] = {.count = 1, .reusable = true}, REDUCE(sym_element, 3),
[109] = {.count = 1, .reusable = true}, REDUCE(sym_style_element, 2),
[111] = {.count = 1, .reusable = false}, REDUCE(sym_style_element, 2),
[113] = {.count = 1, .reusable = true}, REDUCE(sym_end_tag, 3),
[115] = {.count = 1, .reusable = false}, REDUCE(sym_end_tag, 3),
[117] = {.count = 1, .reusable = false}, REDUCE(sym_erroneous_end_tag, 3),
[119] = {.count = 1, .reusable = true}, REDUCE(sym_erroneous_end_tag, 3),
[121] = {.count = 1, .reusable = false}, REDUCE(sym_start_tag, 3),
[123] = {.count = 1, .reusable = true}, REDUCE(sym_start_tag, 3),
[125] = {.count = 1, .reusable = true}, REDUCE(sym_self_closing_tag, 3),
[127] = {.count = 1, .reusable = false}, REDUCE(sym_self_closing_tag, 3),
[129] = {.count = 1, .reusable = true}, REDUCE(aux_sym_start_tag_repeat1, 2),
[131] = {.count = 2, .reusable = true}, REDUCE(aux_sym_start_tag_repeat1, 2), SHIFT_REPEAT(43),
[134] = {.count = 1, .reusable = true}, SHIFT(31),
[136] = {.count = 1, .reusable = true}, SHIFT(30),
[138] = {.count = 1, .reusable = false}, REDUCE(sym_start_tag, 4),
[140] = {.count = 1, .reusable = true}, REDUCE(sym_start_tag, 4),
[142] = {.count = 1, .reusable = true}, SHIFT(48),
[144] = {.count = 1, .reusable = true}, SHIFT(74),
[146] = {.count = 1, .reusable = true}, SHIFT(71),
[148] = {.count = 1, .reusable = true}, SHIFT(73),
[150] = {.count = 1, .reusable = true}, SHIFT(49),
[152] = {.count = 1, .reusable = true}, SHIFT(59),
[154] = {.count = 1, .reusable = true}, REDUCE(sym_attribute, 1),
[156] = {.count = 1, .reusable = true}, SHIFT(40),
[158] = {.count = 1, .reusable = true}, SHIFT(69),
[160] = {.count = 1, .reusable = true}, SHIFT(67),
[162] = {.count = 1, .reusable = true}, SHIFT(64),
[164] = {.count = 1, .reusable = true}, SHIFT(60),
[166] = {.count = 1, .reusable = true}, SHIFT(61),
[168] = {.count = 2, .reusable = true}, REDUCE(aux_sym_start_tag_repeat1, 2), SHIFT_REPEAT(49),
[171] = {.count = 1, .reusable = true}, REDUCE(sym_attribute, 3),
[173] = {.count = 1, .reusable = true}, SHIFT(44),
[175] = {.count = 1, .reusable = true}, REDUCE(sym_quoted_attribute_value, 2),
[177] = {.count = 1, .reusable = true}, SHIFT(32),
[179] = {.count = 1, .reusable = true}, SHIFT(46),
[181] = {.count = 1, .reusable = true}, SHIFT(45),
[183] = {.count = 1, .reusable = true}, SHIFT(9),
[185] = {.count = 1, .reusable = true}, REDUCE(sym_quoted_attribute_value, 3),
[187] = {.count = 1, .reusable = true}, SHIFT(85),
[189] = {.count = 1, .reusable = true}, SHIFT(65),
[191] = {.count = 1, .reusable = true}, SHIFT(92),
[193] = {.count = 1, .reusable = true}, SHIFT(68),
[195] = {.count = 1, .reusable = true}, SHIFT(72),
[197] = {.count = 1, .reusable = true}, SHIFT(63),
[199] = {.count = 1, .reusable = true}, REDUCE(sym_script_start_tag, 4),
[201] = {.count = 1, .reusable = true}, REDUCE(sym_style_start_tag, 3),
[203] = {.count = 1, .reusable = true}, REDUCE(sym_script_start_tag, 3),
[205] = {.count = 1, .reusable = true}, SHIFT(82),
[207] = {.count = 1, .reusable = true}, SHIFT(76),
[209] = {.count = 1, .reusable = false}, SHIFT(70),
[211] = {.count = 1, .reusable = true}, SHIFT(87),
[213] = {.count = 1, .reusable = true}, SHIFT(83),
[215] = {.count = 1, .reusable = true}, SHIFT(86),
[217] = {.count = 1, .reusable = false}, SHIFT(50),
[219] = {.count = 1, .reusable = true}, SHIFT(88),
[221] = {.count = 1, .reusable = true}, REDUCE(sym_style_start_tag, 4),
[223] = {.count = 1, .reusable = true}, SHIFT(78),
[225] = {.count = 1, .reusable = true}, SHIFT(79),
[227] = {.count = 1, .reusable = true}, SHIFT(25),
[229] = {.count = 1, .reusable = true}, ACCEPT_INPUT(),
[231] = {.count = 1, .reusable = true}, SHIFT(53),
[233] = {.count = 1, .reusable = true}, SHIFT(91),
[235] = {.count = 1, .reusable = true}, SHIFT(18),
[237] = {.count = 1, .reusable = true}, SHIFT(84),
[239] = {.count = 1, .reusable = true}, SHIFT(37),
[241] = {.count = 1, .reusable = true}, SHIFT(24),
[243] = {.count = 1, .reusable = true}, SHIFT(34),
[245] = {.count = 1, .reusable = true}, SHIFT(58),
[247] = {.count = 1, .reusable = true}, SHIFT(80),
[249] = {.count = 1, .reusable = true}, SHIFT(39),
[251] = {.count = 1, .reusable = true}, SHIFT(90),
[0] = {.entry = {.count = 0, .reusable = false}},
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
[3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),
[5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_fragment, 0),
[7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(75),
[9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(52),
[11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(81),
[13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8),
[15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(93),
[17] = {.entry = {.count = 1, .reusable = false}}, SHIFT(51),
[19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(66),
[21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6),
[23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36),
[25] = {.entry = {.count = 1, .reusable = false}}, SHIFT(62),
[27] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22),
[29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
[31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17),
[33] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),
[35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12),
[37] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(93),
[40] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(51),
[43] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(89),
[46] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(6),
[49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_fragment_repeat1, 2),
[51] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(75),
[54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(52),
[57] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(81),
[60] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_fragment_repeat1, 2), SHIFT_REPEAT(7),
[63] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_fragment, 1),
[65] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),
[67] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26),
[69] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27),
[71] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43),
[73] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_script_element, 3),
[75] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_script_element, 3),
[77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_element, 1),
[79] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_element, 1),
[81] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_element, 2),
[83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_element, 2),
[85] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_script_element, 2),
[87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_script_element, 2),
[89] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33),
[91] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16),
[93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_self_closing_tag, 4),
[95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_self_closing_tag, 4),
[97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_doctype, 4),
[99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_doctype, 4),
[101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_style_element, 3),
[103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_style_element, 3),
[105] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_element, 3),
[107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_element, 3),
[109] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_style_element, 2),
[111] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_style_element, 2),
[113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_end_tag, 3),
[115] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_end_tag, 3),
[117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_erroneous_end_tag, 3),
[119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_erroneous_end_tag, 3),
[121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_start_tag, 3),
[123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_start_tag, 3),
[125] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_self_closing_tag, 3),
[127] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_self_closing_tag, 3),
[129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_start_tag_repeat1, 2),
[131] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_start_tag_repeat1, 2), SHIFT_REPEAT(43),
[134] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31),
[136] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30),
[138] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_start_tag, 4),
[140] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_start_tag, 4),
[142] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48),
[144] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74),
[146] = {.entry = {.count = 1, .reusable = true}}, SHIFT(71),
[148] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73),
[150] = {.entry = {.count = 1, .reusable = true}}, SHIFT(49),
[152] = {.entry = {.count = 1, .reusable = true}}, SHIFT(59),
[154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute, 1),
[156] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40),
[158] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69),
[160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(67),
[162] = {.entry = {.count = 1, .reusable = true}}, SHIFT(64),
[164] = {.entry = {.count = 1, .reusable = true}}, SHIFT(60),
[166] = {.entry = {.count = 1, .reusable = true}}, SHIFT(61),
[168] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_start_tag_repeat1, 2), SHIFT_REPEAT(49),
[171] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute, 3),
[173] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44),
[175] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_quoted_attribute_value, 2),
[177] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32),
[179] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46),
[181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45),
[183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9),
[185] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_quoted_attribute_value, 3),
[187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(85),
[189] = {.entry = {.count = 1, .reusable = true}}, SHIFT(65),
[191] = {.entry = {.count = 1, .reusable = true}}, SHIFT(92),
[193] = {.entry = {.count = 1, .reusable = true}}, SHIFT(68),
[195] = {.entry = {.count = 1, .reusable = true}}, SHIFT(72),
[197] = {.entry = {.count = 1, .reusable = true}}, SHIFT(63),
[199] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_script_start_tag, 4),
[201] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_style_start_tag, 3),
[203] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_script_start_tag, 3),
[205] = {.entry = {.count = 1, .reusable = true}}, SHIFT(82),
[207] = {.entry = {.count = 1, .reusable = true}}, SHIFT(76),
[209] = {.entry = {.count = 1, .reusable = false}}, SHIFT(70),
[211] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87),
[213] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83),
[215] = {.entry = {.count = 1, .reusable = true}}, SHIFT(86),
[217] = {.entry = {.count = 1, .reusable = false}}, SHIFT(50),
[219] = {.entry = {.count = 1, .reusable = true}}, SHIFT(88),
[221] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_style_start_tag, 4),
[223] = {.entry = {.count = 1, .reusable = true}}, SHIFT(78),
[225] = {.entry = {.count = 1, .reusable = true}}, SHIFT(79),
[227] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25),
[229] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
[231] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53),
[233] = {.entry = {.count = 1, .reusable = true}}, SHIFT(91),
[235] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18),
[237] = {.entry = {.count = 1, .reusable = true}}, SHIFT(84),
[239] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37),
[241] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24),
[243] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34),
[245] = {.entry = {.count = 1, .reusable = true}}, SHIFT(58),
[247] = {.entry = {.count = 1, .reusable = true}}, SHIFT(80),
[249] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39),
[251] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90),
};
#ifdef __cplusplus

View File

@ -62,13 +62,13 @@ typedef struct {
TSStateId state;
bool extra : 1;
bool repetition : 1;
};
} shift;
struct {
TSSymbol symbol;
int16_t dynamic_precedence;
uint8_t child_count;
uint8_t production_id;
};
} reduce;
} params;
TSParseActionType type : 4;
} TSParseAction;
@ -83,7 +83,7 @@ typedef union {
struct {
uint8_t count;
bool reusable : 1;
};
} entry;
} TSParseActionEntry;
struct TSLanguage {
@ -167,22 +167,28 @@ struct TSLanguage {
#define ACTIONS(id) id
#define SHIFT(state_value) \
{ \
{ \
.type = TSParseActionTypeShift, \
.params = {.state = state_value}, \
} \
#define SHIFT(state_value) \
{ \
{ \
.params = { \
.shift = { \
.state = state_value \
} \
}, \
.type = TSParseActionTypeShift \
} \
}
#define SHIFT_REPEAT(state_value) \
{ \
{ \
.type = TSParseActionTypeShift, \
.params = { \
.state = state_value, \
.repetition = true \
.shift = { \
.state = state_value, \
.repetition = true \
} \
}, \
.type = TSParseActionTypeShift \
} \
}
@ -194,20 +200,26 @@ struct TSLanguage {
#define SHIFT_EXTRA() \
{ \
{ \
.type = TSParseActionTypeShift, \
.params = {.extra = true} \
.params = { \
.shift = { \
.extra = true \
} \
}, \
.type = TSParseActionTypeShift \
} \
}
#define REDUCE(symbol_val, child_count_val, ...) \
{ \
{ \
.type = TSParseActionTypeReduce, \
.params = { \
.symbol = symbol_val, \
.child_count = child_count_val, \
__VA_ARGS__ \
} \
.reduce = { \
.symbol = symbol_val, \
.child_count = child_count_val, \
__VA_ARGS__ \
}, \
}, \
.type = TSParseActionTypeReduce \
} \
}