Skip to content

Commit

Permalink
refactor: rename fragment_tag_name -> fragment_tag_delim
Browse files Browse the repository at this point in the history
  • Loading branch information
virchau13 committed Apr 21, 2024
1 parent 1aab99e commit 506515c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 54 deletions.
12 changes: 4 additions & 8 deletions corpus/fragment-empty-tag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Fragment (empty) tags

(document
(element
(start_tag
(fragment_tag_name))
(start_tag)
(element
(start_tag
(tag_name))
Expand All @@ -26,16 +25,13 @@ Fragment (empty) tags
(html_interpolation
(permissible_text)
(element
(start_tag
(fragment_tag_name))
(start_tag)
(element
(start_tag
(tag_name))
(text)
(end_tag
(tag_name)))
(end_tag
(fragment_tag_name)))
(end_tag))
(permissible_text))
(end_tag
(fragment_tag_name))))
(end_tag)))
6 changes: 3 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = grammar(HTML, {
$.attribute_js_expr,
$.attribute_backtick_string,
$.permissible_text,
$.fragment_tag_name,
$._fragment_tag_delim,
]),

rules: {
Expand Down Expand Up @@ -64,7 +64,7 @@ module.exports = grammar(HTML, {
repeat($.attribute),
'>',
),
$.fragment_tag_name,
alias($._fragment_tag_delim, '>'),
),
),
end_tag: ($, _) => seq(
Expand All @@ -74,7 +74,7 @@ module.exports = grammar(HTML, {
alias($._end_tag_name, $.tag_name),
'>',
),
$.fragment_tag_name,
alias($._fragment_tag_delim, '>'),
),
),

Expand Down
20 changes: 15 additions & 5 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,13 @@
]
},
{
"type": "SYMBOL",
"name": "fragment_tag_name"
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_fragment_tag_delim"
},
"named": false,
"value": ">"
}
]
}
Expand Down Expand Up @@ -345,8 +350,13 @@
]
},
{
"type": "SYMBOL",
"name": "fragment_tag_name"
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_fragment_tag_delim"
},
"named": false,
"value": ">"
}
]
}
Expand Down Expand Up @@ -711,7 +721,7 @@
},
{
"type": "SYMBOL",
"name": "fragment_tag_name"
"name": "_fragment_tag_delim"
}
],
"inline": [],
Expand Down
16 changes: 2 additions & 14 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,8 @@
"fields": {},
"children": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "fragment_tag_name",
"named": true
},
{
"type": "tag_name",
"named": true
Expand Down Expand Up @@ -291,16 +287,12 @@
"fields": {},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "attribute",
"named": true
},
{
"type": "fragment_tag_name",
"named": true
},
{
"type": "tag_name",
"named": true
Expand Down Expand Up @@ -395,10 +387,6 @@
"type": "erroneous_end_tag_name",
"named": true
},
{
"type": "fragment_tag_name",
"named": true
},
{
"type": "frontmatter_js_block",
"named": true
Expand Down
42 changes: 21 additions & 21 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum ts_symbol_identifiers {
sym_attribute_js_expr = 32,
sym_attribute_backtick_string = 33,
sym_permissible_text = 34,
sym_fragment_tag_name = 35,
sym__fragment_tag_delim = 35,
sym_document = 36,
sym_doctype = 37,
sym__node = 38,
Expand Down Expand Up @@ -111,7 +111,7 @@ static const char * const ts_symbol_names[] = {
[sym_attribute_js_expr] = "attribute_js_expr",
[sym_attribute_backtick_string] = "attribute_backtick_string",
[sym_permissible_text] = "permissible_text",
[sym_fragment_tag_name] = "fragment_tag_name",
[sym__fragment_tag_delim] = ">",
[sym_document] = "document",
[sym_doctype] = "doctype",
[sym__node] = "_node",
Expand Down Expand Up @@ -171,7 +171,7 @@ static const TSSymbol ts_symbol_map[] = {
[sym_attribute_js_expr] = sym_attribute_js_expr,
[sym_attribute_backtick_string] = sym_attribute_backtick_string,
[sym_permissible_text] = sym_permissible_text,
[sym_fragment_tag_name] = sym_fragment_tag_name,
[sym__fragment_tag_delim] = anon_sym_GT,
[sym_document] = sym_document,
[sym_doctype] = sym_doctype,
[sym__node] = sym__node,
Expand Down Expand Up @@ -336,9 +336,9 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true,
.named = true,
},
[sym_fragment_tag_name] = {
[sym__fragment_tag_delim] = {
.visible = true,
.named = true,
.named = false,
},
[sym_document] = {
.visible = true,
Expand Down Expand Up @@ -1289,7 +1289,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_attribute_js_expr] = ACTIONS(1),
[sym_attribute_backtick_string] = ACTIONS(1),
[sym_permissible_text] = ACTIONS(1),
[sym_fragment_tag_name] = ACTIONS(1),
[sym__fragment_tag_delim] = ACTIONS(1),
},
[1] = {
[sym_document] = STATE(127),
Expand Down Expand Up @@ -2574,7 +2574,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(270), 1,
sym__style_start_tag_name,
ACTIONS(272), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[1687] = 5,
ACTIONS(3), 1,
sym_comment,
Expand All @@ -2583,7 +2583,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(270), 1,
sym__style_start_tag_name,
ACTIONS(272), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
ACTIONS(274), 1,
sym__start_tag_name,
[1703] = 4,
Expand All @@ -2604,7 +2604,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(270), 1,
sym__style_start_tag_name,
ACTIONS(272), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
ACTIONS(278), 1,
sym__start_tag_name,
[1733] = 4,
Expand Down Expand Up @@ -2648,7 +2648,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(293), 1,
sym_erroneous_end_tag_name,
ACTIONS(295), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[1791] = 4,
ACTIONS(3), 1,
sym_comment,
Expand Down Expand Up @@ -2708,7 +2708,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(313), 1,
sym__end_tag_name,
ACTIONS(315), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[1876] = 4,
ACTIONS(3), 1,
sym_comment,
Expand All @@ -2726,7 +2726,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(319), 1,
sym__end_tag_name,
ACTIONS(321), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[1902] = 2,
ACTIONS(3), 1,
sym_comment,
Expand Down Expand Up @@ -2774,7 +2774,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(313), 1,
sym__end_tag_name,
ACTIONS(315), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[1969] = 3,
ACTIONS(3), 1,
sym_comment,
Expand All @@ -2801,7 +2801,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(319), 1,
sym__end_tag_name,
ACTIONS(321), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[2007] = 2,
ACTIONS(3), 1,
sym_comment,
Expand Down Expand Up @@ -2839,7 +2839,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(291), 1,
sym__end_tag_name,
ACTIONS(295), 1,
sym_fragment_tag_name,
sym__fragment_tag_delim,
[2059] = 3,
ACTIONS(3), 1,
sym_comment,
Expand Down Expand Up @@ -3371,7 +3371,7 @@ enum ts_external_scanner_symbol_identifiers {
ts_external_token_attribute_js_expr = 12,
ts_external_token_attribute_backtick_string = 13,
ts_external_token_permissible_text = 14,
ts_external_token_fragment_tag_name = 15,
ts_external_token__fragment_tag_delim = 15,
};

static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
Expand All @@ -3390,7 +3390,7 @@ static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
[ts_external_token_attribute_js_expr] = sym_attribute_js_expr,
[ts_external_token_attribute_backtick_string] = sym_attribute_backtick_string,
[ts_external_token_permissible_text] = sym_permissible_text,
[ts_external_token_fragment_tag_name] = sym_fragment_tag_name,
[ts_external_token__fragment_tag_delim] = sym__fragment_tag_delim,
};

static const bool ts_external_scanner_states[15][EXTERNAL_TOKEN_COUNT] = {
Expand All @@ -3410,7 +3410,7 @@ static const bool ts_external_scanner_states[15][EXTERNAL_TOKEN_COUNT] = {
[ts_external_token_attribute_js_expr] = true,
[ts_external_token_attribute_backtick_string] = true,
[ts_external_token_permissible_text] = true,
[ts_external_token_fragment_tag_name] = true,
[ts_external_token__fragment_tag_delim] = true,
},
[2] = {
[ts_external_token_comment] = true,
Expand Down Expand Up @@ -3443,7 +3443,7 @@ static const bool ts_external_scanner_states[15][EXTERNAL_TOKEN_COUNT] = {
[ts_external_token__script_start_tag_name] = true,
[ts_external_token__style_start_tag_name] = true,
[ts_external_token_comment] = true,
[ts_external_token_fragment_tag_name] = true,
[ts_external_token__fragment_tag_delim] = true,
},
[9] = {
[ts_external_token_raw_text] = true,
Expand All @@ -3453,12 +3453,12 @@ static const bool ts_external_scanner_states[15][EXTERNAL_TOKEN_COUNT] = {
[ts_external_token__end_tag_name] = true,
[ts_external_token_erroneous_end_tag_name] = true,
[ts_external_token_comment] = true,
[ts_external_token_fragment_tag_name] = true,
[ts_external_token__fragment_tag_delim] = true,
},
[11] = {
[ts_external_token__end_tag_name] = true,
[ts_external_token_comment] = true,
[ts_external_token_fragment_tag_name] = true,
[ts_external_token__fragment_tag_delim] = true,
},
[12] = {
[ts_external_token_comment] = true,
Expand Down
6 changes: 3 additions & 3 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum TokenType {
ATTRIBUTE_JS_EXPR,
ATTRIBUTE_BACKTICK_STRING,
PERMISSIBLE_TEXT,
FRAGMENT_TAG_NAME,
FRAGMENT_TAG_DELIM,
};

typedef struct {
Expand Down Expand Up @@ -405,7 +405,7 @@ static bool scan_start_tag_name(Scanner *scanner, TSLexer *lexer) {
advance(lexer);
Tag tag = {.type = FRAGMENT, .custom_tag_name = {0}};
array_push(&scanner->tags, tag);
lexer->result_symbol = FRAGMENT_TAG_NAME;
lexer->result_symbol = FRAGMENT_TAG_DELIM;
return true;
} else {
return false;
Expand Down Expand Up @@ -436,7 +436,7 @@ static bool scan_end_tag_name(Scanner *scanner, TSLexer *lexer) {
advance(lexer);
if (scanner->tags.size > 0 && array_back(&scanner->tags)->type == FRAGMENT) {
pop_tag(scanner);
lexer->result_symbol = FRAGMENT_TAG_NAME;
lexer->result_symbol = FRAGMENT_TAG_DELIM;
return true;
} else {
lexer->result_symbol = ERRONEOUS_END_TAG_NAME;
Expand Down

0 comments on commit 506515c

Please sign in to comment.