⬆️ tree-sitter-cli

This commit is contained in:
Max Brunsfeld 2018-08-30 13:00:47 -07:00
parent 74882dc9ce
commit 2d69fcd54f
4 changed files with 22 additions and 16 deletions

View File

@ -22,11 +22,13 @@ module.exports = grammar({
doctype: $ => seq( doctype: $ => seq(
'<!', '<!',
alias(/[Dd][Oo][Cc][Tt][Yy][Pp][Ee]/, 'doctype'), alias($._doctype, 'doctype'),
/[^>]+/, /[^>]+/,
'>' '>'
), ),
_doctype: $ => /[Dd][Oo][Cc][Tt][Yy][Pp][Ee]/,
_node: $ => choice( _node: $ => choice(
$.doctype, $.doctype,
$.text, $.text,

View File

@ -16,7 +16,7 @@
"nan": "^2.10.0" "nan": "^2.10.0"
}, },
"devDependencies": { "devDependencies": {
"tree-sitter-cli": "^0.13.7" "tree-sitter-cli": "^0.13.8"
}, },
"scripts": { "scripts": {
"build": "tree-sitter generate && node-gyp build", "build": "tree-sitter generate && node-gyp build",

View File

@ -18,8 +18,8 @@
{ {
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "PATTERN", "type": "SYMBOL",
"value": "[Dd][Oo][Cc][Tt][Yy][Pp][Ee]" "name": "_doctype"
}, },
"named": false, "named": false,
"value": "doctype" "value": "doctype"
@ -34,6 +34,10 @@
} }
] ]
}, },
"_doctype": {
"type": "PATTERN",
"value": "[Dd][Oo][Cc][Tt][Yy][Pp][Ee]"
},
"_node": { "_node": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [

24
src/parser.c vendored
View File

@ -22,9 +22,9 @@ enum {
sym_raw_text = 6, sym_raw_text = 6,
sym_comment = 7, sym_comment = 7,
anon_sym_LT_BANG = 8, anon_sym_LT_BANG = 8,
aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH = 9, aux_sym_SLASH_LBRACK_CARET_GT_RBRACK_PLUS_SLASH = 9,
aux_sym_SLASH_LBRACK_CARET_GT_RBRACK_PLUS_SLASH = 10, anon_sym_GT = 10,
anon_sym_GT = 11, sym__doctype = 11,
anon_sym_LT = 12, anon_sym_LT = 12,
anon_sym_SLASH_GT = 13, anon_sym_SLASH_GT = 13,
anon_sym_LT_SLASH = 14, anon_sym_LT_SLASH = 14,
@ -62,9 +62,9 @@ static const char *ts_symbol_names[] = {
[sym_comment] = "comment", [sym_comment] = "comment",
[ts_builtin_sym_end] = "END", [ts_builtin_sym_end] = "END",
[anon_sym_LT_BANG] = "<!", [anon_sym_LT_BANG] = "<!",
[aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH] = "doctype",
[aux_sym_SLASH_LBRACK_CARET_GT_RBRACK_PLUS_SLASH] = "/[^>]+/", [aux_sym_SLASH_LBRACK_CARET_GT_RBRACK_PLUS_SLASH] = "/[^>]+/",
[anon_sym_GT] = ">", [anon_sym_GT] = ">",
[sym__doctype] = "doctype",
[anon_sym_LT] = "<", [anon_sym_LT] = "<",
[anon_sym_SLASH_GT] = "/>", [anon_sym_SLASH_GT] = "/>",
[anon_sym_LT_SLASH] = "</", [anon_sym_LT_SLASH] = "</",
@ -129,10 +129,6 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true, .visible = true,
.named = false, .named = false,
}, },
[aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH] = {
.visible = false,
.named = true,
},
[aux_sym_SLASH_LBRACK_CARET_GT_RBRACK_PLUS_SLASH] = { [aux_sym_SLASH_LBRACK_CARET_GT_RBRACK_PLUS_SLASH] = {
.visible = false, .visible = false,
.named = false, .named = false,
@ -141,6 +137,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true, .visible = true,
.named = false, .named = false,
}, },
[sym__doctype] = {
.visible = true,
.named = false,
},
[anon_sym_LT] = { [anon_sym_LT] = {
.visible = true, .visible = true,
.named = false, .named = false,
@ -336,7 +336,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
ADVANCE(17); ADVANCE(17);
END_STATE(); END_STATE();
case 17: case 17:
ACCEPT_TOKEN(aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH); ACCEPT_TOKEN(sym__doctype);
END_STATE(); END_STATE();
case 18: case 18:
if (lookahead == 0) if (lookahead == 0)
@ -745,8 +745,8 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = {
[sym_comment] = ACTIONS(1), [sym_comment] = ACTIONS(1),
[ts_builtin_sym_end] = ACTIONS(1), [ts_builtin_sym_end] = ACTIONS(1),
[anon_sym_LT_BANG] = ACTIONS(1), [anon_sym_LT_BANG] = ACTIONS(1),
[aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH] = ACTIONS(1),
[anon_sym_GT] = ACTIONS(1), [anon_sym_GT] = ACTIONS(1),
[sym__doctype] = ACTIONS(1),
[anon_sym_LT] = ACTIONS(3), [anon_sym_LT] = ACTIONS(3),
[anon_sym_SLASH_GT] = ACTIONS(1), [anon_sym_SLASH_GT] = ACTIONS(1),
[anon_sym_LT_SLASH] = ACTIONS(1), [anon_sym_LT_SLASH] = ACTIONS(1),
@ -774,7 +774,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = {
}, },
[2] = { [2] = {
[sym_comment] = ACTIONS(5), [sym_comment] = ACTIONS(5),
[aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH] = ACTIONS(17), [sym__doctype] = ACTIONS(17),
}, },
[3] = { [3] = {
[sym__start_tag_name] = ACTIONS(19), [sym__start_tag_name] = ACTIONS(19),
@ -871,7 +871,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = {
}, },
[15] = { [15] = {
[sym_comment] = ACTIONS(5), [sym_comment] = ACTIONS(5),
[aux_sym_SLASH_LBRACKDd_RBRACK_LBRACKOo_RBRACK_LBRACKCc_RBRACK_LBRACKTt_RBRACK_LBRACKYy_RBRACK_LBRACKPp_RBRACK_LBRACKEe_RBRACK_SLASH] = ACTIONS(67), [sym__doctype] = ACTIONS(67),
}, },
[16] = { [16] = {
[sym__start_tag_name] = ACTIONS(69), [sym__start_tag_name] = ACTIONS(69),