diff --git a/Cargo.lock b/Cargo.lock index 6e6071b2d..dcf7a4178 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3443,6 +3443,14 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "test_html_grammar" +version = "0.1.0" +dependencies = [ + "tree-sitter-facade-sg", + "tree-sitter-html", +] + [[package]] name = "thiserror" version = "1.0.57" @@ -3852,7 +3860,7 @@ dependencies = [ [[package]] name = "tree-sitter-html" -version = "0.20.0" +version = "0.20.2" dependencies = [ "cc", "tree-sitter", diff --git a/Cargo.toml b/Cargo.toml index 278c48b1b..7a6cdcf54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ members = [ "crates/auth", "crates/externals", "crates/wasm-bindings", - "crates/marzano_messenger", "crates/cli_bin", + "crates/marzano_messenger", "crates/cli_bin", "crates/test_html_grammar", ] exclude = [ "resources", diff --git a/crates/core/src/test.rs b/crates/core/src/test.rs index c3003d510..5ece7dc3d 100644 --- a/crates/core/src/test.rs +++ b/crates/core/src/test.rs @@ -12816,6 +12816,47 @@ fn css_property_value() { .unwrap(); } +#[test] +fn html_match_element() { + run_test_match(TestArg { + pattern: r#" + |language html + | + |contains `` + |"# + .trim_margin() + .unwrap(), + source: r#""# + .to_owned(), + }) + .unwrap(); +} + +#[test] +fn html_prefer_self_closing_tags() { + run_test_expected(TestArgExpected { + pattern: r#" + |language html + | + |`<$name $props>$body` => `<$name $props />` where $body <: . + |"# + .trim_margin() + .unwrap(), + source: r#" + | + |"# + .trim_margin() + .unwrap(), + expected: r#" + | + |"# + .trim_margin() + .unwrap(), + }) + .unwrap(); +} + + #[test] fn json_empty_string_should_not_match_everything() { run_test_no_match(TestArg { diff --git a/crates/language/src/html.rs b/crates/language/src/html.rs index 69fe09020..dbeef712e 100644 --- a/crates/language/src/html.rs +++ b/crates/language/src/html.rs @@ -61,3 +61,40 @@ impl Language for Html { self.metavariable_sort } } + + + + +#[cfg(test)] +mod tests { + use marzano_util::print_node::print_node; + + use crate::language::nodes_from_indices; + + use super::*; + + #[test] + fn import_variable() { + let snippet = r#""#; + let lang = Html::new(None); + let mut parser = tree_sitter::Parser::new().unwrap(); + parser.set_language(lang.get_ts_language()).unwrap(); + let snippets = lang.parse_snippet_contexts(snippet); + let nodes = nodes_from_indices(&snippets); + assert!(!nodes.is_empty()); + print_node(&nodes[0].node); + } + + #[test] + fn print_sexp() { + let code = r#""#; + let mut parser = tree_sitter::Parser::new().unwrap(); + let lang = tree_sitter_html::language().into(); + // let lang = Html::new(None); + parser.set_language(&lang).unwrap(); + let tree = parser.parse(code, None).unwrap().unwrap(); + let root = tree.root_node(); + let sexp = root.to_sexp(); + println!("{sexp}"); + } +} \ No newline at end of file diff --git a/crates/test_html_grammar/Cargo.toml b/crates/test_html_grammar/Cargo.toml new file mode 100644 index 000000000..2c7b2ebf1 --- /dev/null +++ b/crates/test_html_grammar/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "test_html_grammar" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tree-sitter = { path = "../../vendor/tree-sitter-facade", package = "tree-sitter-facade-sg" } +# tree-sitter-html = "0.20.0" +tree-sitter-html = { path = "../../resources/language-metavariables/tree-sitter-html" } diff --git a/crates/test_html_grammar/src/main.rs b/crates/test_html_grammar/src/main.rs new file mode 100644 index 000000000..41f6dbaaf --- /dev/null +++ b/crates/test_html_grammar/src/main.rs @@ -0,0 +1,11 @@ + + +fn main() { + let code = r#""#; + let mut parser = tree_sitter::Parser::new().unwrap(); + parser.set_language(&tree_sitter_html::language().into()).unwrap(); + let tree = parser.parse(code, None).unwrap().unwrap(); + let root = tree.root_node(); + let sexp = root.to_sexp(); + println!("{sexp}"); +} diff --git a/crates/wasm-bindings/wasm_parsers/tree-sitter-html.wasm b/crates/wasm-bindings/wasm_parsers/tree-sitter-html.wasm index 2d2835ca4..1c88c0c46 100755 Binary files a/crates/wasm-bindings/wasm_parsers/tree-sitter-html.wasm and b/crates/wasm-bindings/wasm_parsers/tree-sitter-html.wasm differ diff --git a/resources/edit_grammars.mjs b/resources/edit_grammars.mjs index daba18f5e..244b36033 100644 --- a/resources/edit_grammars.mjs +++ b/resources/edit_grammars.mjs @@ -121,10 +121,6 @@ async function rsyncGrammars(language) { ? `${LANGUAGE_METAVARIABLES}/${treeSitterLang}` : LANGUAGE_METAVARIABLES; - if (languagesWithoutMetaVariables.includes(language)) { - return; - } - await fs.rmdir(mvDir, { recursive: true }); await fs.mkdir(mvDir, { recursive: true }); diff --git a/resources/language-metavariables/tree-sitter-html/.appveyor.yml b/resources/language-metavariables/tree-sitter-html/.appveyor.yml deleted file mode 100644 index 3e438d380..000000000 --- a/resources/language-metavariables/tree-sitter-html/.appveyor.yml +++ /dev/null @@ -1,22 +0,0 @@ -image: Visual Studio 2015 - -environment: - nodejs_version: "10" - -platform: - - x64 - -install: - - ps: Install-Product node $env:nodejs_version - - node --version - - npm --version - - npm install - -test_script: - - npm run test-windows - -build: off - -branches: - only: - - master diff --git a/resources/language-metavariables/tree-sitter-html/.travis.yml b/resources/language-metavariables/tree-sitter-html/.travis.yml deleted file mode 100644 index 38d6538b7..000000000 --- a/resources/language-metavariables/tree-sitter-html/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: node_js - -node_js: 10 - -env: - - CXX=clang++ - -branches: - only: - - master diff --git a/resources/language-metavariables/tree-sitter-html/Cargo.toml b/resources/language-metavariables/tree-sitter-html/Cargo.toml index 556323cb1..7b78055ca 100644 --- a/resources/language-metavariables/tree-sitter-html/Cargo.toml +++ b/resources/language-metavariables/tree-sitter-html/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tree-sitter-html" description = "HTML grammar for tree-sitter" -version = "0.20.0" +version = "0.20.2" authors = [ "Max Brunsfeld ", "Amaan Qureshi ", diff --git a/resources/language-metavariables/tree-sitter-html/Makefile b/resources/language-metavariables/tree-sitter-html/Makefile index 071e95018..c24aed7a1 100644 --- a/resources/language-metavariables/tree-sitter-html/Makefile +++ b/resources/language-metavariables/tree-sitter-html/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.20.0 +VERSION := 0.20.2 # Repository SRC_DIR := src diff --git a/resources/language-metavariables/tree-sitter-html/README.md b/resources/language-metavariables/tree-sitter-html/README.md index c2981f4ba..58bd3e364 100644 --- a/resources/language-metavariables/tree-sitter-html/README.md +++ b/resources/language-metavariables/tree-sitter-html/README.md @@ -1,9 +1,19 @@ # tree-sitter-html -[![build](https://github.com/tree-sitter/tree-sitter-html/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-html/actions/workflows/ci.yml) +[![CI][ci]](https://github.com/tree-sitter/tree-sitter-html/actions/workflows/ci.yml) +[![discord][discord]](https://discord.gg/w7nTvsVJhm) +[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org) +[![crates][crates]](https://crates.io/crates/tree-sitter-html) +[![npm][npm]](https://www.npmjs.com/package/tree-sitter-html) HTML grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). References -* [The HTML5 Spec](https://www.w3.org/TR/html5/syntax.html) +- [The HTML5 Spec](https://www.w3.org/TR/html5/syntax.html) + +[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-html/ci.yml?logo=github&label=CI +[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord +[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix +[npm]: https://img.shields.io/npm/v/tree-sitter-html?logo=npm +[crates]: https://img.shields.io/crates/v/tree-sitter-html?logo=rust diff --git a/resources/language-metavariables/tree-sitter-html/bindings/rust/README.md b/resources/language-metavariables/tree-sitter-html/bindings/rust/README.md index e7de0dee7..6d0ae3698 100644 --- a/resources/language-metavariables/tree-sitter-html/bindings/rust/README.md +++ b/resources/language-metavariables/tree-sitter-html/bindings/rust/README.md @@ -9,7 +9,7 @@ way.) ```toml [dependencies] tree-sitter = "0.20.10" -tree-sitter-html = "0.20.0" +tree-sitter-html = "0.20" ``` Typically, you will use the [language][language func] function to add this diff --git a/resources/language-metavariables/tree-sitter-html/grammar.js b/resources/language-metavariables/tree-sitter-html/grammar.js index 3f76f1eb7..de4c1e571 100644 --- a/resources/language-metavariables/tree-sitter-html/grammar.js +++ b/resources/language-metavariables/tree-sitter-html/grammar.js @@ -31,7 +31,7 @@ module.exports = grammar({ ], rules: { - fragment: $ => repeat($._node), + document: $ => repeat($._node), doctype: $ => seq( ' /&(#([xX][0-9a-fA-F]{1,6}|[0-9]{1,5})|[A-Za-z]{1,30});/, + entity: _ => /&(#([xX][0-9a-fA-F]{1,6}|[0-9]{1,5})|[A-Za-z]{1,30});?/, quoted_attribute_value: $ => choice( seq('\'', optional(alias(/[^']+/, $.attribute_value)), '\''), diff --git a/resources/language-metavariables/tree-sitter-html/package.json b/resources/language-metavariables/tree-sitter-html/package.json index bc332c88a..bbb08e580 100644 --- a/resources/language-metavariables/tree-sitter-html/package.json +++ b/resources/language-metavariables/tree-sitter-html/package.json @@ -1,6 +1,6 @@ { "name": "tree-sitter-html", - "version": "0.20.0", + "version": "0.20.2", "description": "HTML grammar for tree-sitter", "main": "bindings/node", "keywords": [ @@ -37,7 +37,7 @@ }, "tree-sitter": [ { - "scope": "text.html.basic", + "scope": "source.html", "file-types": [ "html" ], @@ -47,6 +47,9 @@ ], "injections": [ "queries/injections.scm" + ], + "external-files": [ + "src/tag.h" ] } ] diff --git a/resources/language-metavariables/tree-sitter-html/src/grammar.json b/resources/language-metavariables/tree-sitter-html/src/grammar.json index 63283e131..2f3a9932b 100644 --- a/resources/language-metavariables/tree-sitter-html/src/grammar.json +++ b/resources/language-metavariables/tree-sitter-html/src/grammar.json @@ -1,7 +1,7 @@ { "name": "html", "rules": { - "fragment": { + "document": { "type": "REPEAT", "content": { "type": "SYMBOL", @@ -373,7 +373,7 @@ }, "entity": { "type": "PATTERN", - "value": "&(#([xX][0-9a-fA-F]{1,6}|[0-9]{1,5})|[A-Za-z]{1,30});" + "value": "&(#([xX][0-9a-fA-F]{1,6}|[0-9]{1,5})|[A-Za-z]{1,30});?" }, "quoted_attribute_value": { "type": "CHOICE", diff --git a/resources/language-metavariables/tree-sitter-html/src/node-types.json b/resources/language-metavariables/tree-sitter-html/src/node-types.json index 17626fccc..07fc3750a 100644 --- a/resources/language-metavariables/tree-sitter-html/src/node-types.json +++ b/resources/language-metavariables/tree-sitter-html/src/node-types.json @@ -27,6 +27,45 @@ "named": true, "fields": {} }, + { + "type": "document", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "doctype", + "named": true + }, + { + "type": "element", + "named": true + }, + { + "type": "entity", + "named": true + }, + { + "type": "erroneous_end_tag", + "named": true + }, + { + "type": "script_element", + "named": true + }, + { + "type": "style_element", + "named": true + }, + { + "type": "text", + "named": true + } + ] + } + }, { "type": "element", "named": true, @@ -108,45 +147,6 @@ ] } }, - { - "type": "fragment", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "doctype", - "named": true - }, - { - "type": "element", - "named": true - }, - { - "type": "entity", - "named": true - }, - { - "type": "erroneous_end_tag", - "named": true - }, - { - "type": "script_element", - "named": true - }, - { - "type": "style_element", - "named": true - }, - { - "type": "text", - "named": true - } - ] - } - }, { "type": "quoted_attribute_value", "named": true, diff --git a/resources/language-metavariables/tree-sitter-html/src/parser.c b/resources/language-metavariables/tree-sitter-html/src/parser.c index 788fb404e..adb20eece 100644 --- a/resources/language-metavariables/tree-sitter-html/src/parser.c +++ b/resources/language-metavariables/tree-sitter-html/src/parser.c @@ -41,7 +41,7 @@ enum { sym__implicit_end_tag = 22, sym_raw_text = 23, sym_comment = 24, - sym_fragment = 25, + sym_document = 25, sym_doctype = 26, sym__node = 27, sym_element = 28, @@ -55,7 +55,7 @@ enum { sym_erroneous_end_tag = 36, sym_attribute = 37, sym_quoted_attribute_value = 38, - aux_sym_fragment_repeat1 = 39, + aux_sym_document_repeat1 = 39, aux_sym_start_tag_repeat1 = 40, }; @@ -85,7 +85,7 @@ static const char * const ts_symbol_names[] = { [sym__implicit_end_tag] = "_implicit_end_tag", [sym_raw_text] = "raw_text", [sym_comment] = "comment", - [sym_fragment] = "fragment", + [sym_document] = "document", [sym_doctype] = "doctype", [sym__node] = "_node", [sym_element] = "element", @@ -99,7 +99,7 @@ static const char * const ts_symbol_names[] = { [sym_erroneous_end_tag] = "erroneous_end_tag", [sym_attribute] = "attribute", [sym_quoted_attribute_value] = "quoted_attribute_value", - [aux_sym_fragment_repeat1] = "fragment_repeat1", + [aux_sym_document_repeat1] = "document_repeat1", [aux_sym_start_tag_repeat1] = "start_tag_repeat1", }; @@ -129,7 +129,7 @@ static const TSSymbol ts_symbol_map[] = { [sym__implicit_end_tag] = sym__implicit_end_tag, [sym_raw_text] = sym_raw_text, [sym_comment] = sym_comment, - [sym_fragment] = sym_fragment, + [sym_document] = sym_document, [sym_doctype] = sym_doctype, [sym__node] = sym__node, [sym_element] = sym_element, @@ -143,7 +143,7 @@ static const TSSymbol ts_symbol_map[] = { [sym_erroneous_end_tag] = sym_erroneous_end_tag, [sym_attribute] = sym_attribute, [sym_quoted_attribute_value] = sym_quoted_attribute_value, - [aux_sym_fragment_repeat1] = aux_sym_fragment_repeat1, + [aux_sym_document_repeat1] = aux_sym_document_repeat1, [aux_sym_start_tag_repeat1] = aux_sym_start_tag_repeat1, }; @@ -248,7 +248,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym_fragment] = { + [sym_document] = { .visible = true, .named = true, }, @@ -304,7 +304,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [aux_sym_fragment_repeat1] = { + [aux_sym_document_repeat1] = { .visible = false, .named = false, }, @@ -424,16 +424,16 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { eof = lexer->eof(lexer); switch (state) { case 0: - if (eof) ADVANCE(57); + if (eof) ADVANCE(18); if (lookahead == '"') ADVANCE(73); if (lookahead == '&') ADVANCE(3); if (lookahead == '\'') ADVANCE(70); - if (lookahead == '/') ADVANCE(45); - if (lookahead == '<') ADVANCE(63); - if (lookahead == '=') ADVANCE(66); - if (lookahead == '>') ADVANCE(61); + if (lookahead == '/') ADVANCE(6); + if (lookahead == '<') ADVANCE(24); + if (lookahead == '=') ADVANCE(27); + if (lookahead == '>') ADVANCE(22); if (lookahead == 'D' || - lookahead == 'd') ADVANCE(48); + lookahead == 'd') ADVANCE(9); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || @@ -447,7 +447,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == '\r' || lookahead == ' ') SKIP(1) if (lookahead != 0 && - (lookahead < '<' || '>' < lookahead)) ADVANCE(68); + (lookahead < '<' || '>' < lookahead)) ADVANCE(29); END_STATE(); case 2: if (lookahead == '"') ADVANCE(73); @@ -458,9 +458,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead != 0) ADVANCE(75); END_STATE(); case 3: - if (lookahead == '#') ADVANCE(51); + if (lookahead == '#') ADVANCE(12); if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(69); END_STATE(); case 4: if (lookahead == '\'') ADVANCE(70); @@ -471,9 +471,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead != 0) ADVANCE(72); END_STATE(); case 5: - if (lookahead == '/') ADVANCE(45); - if (lookahead == '=') ADVANCE(66); - if (lookahead == '>') ADVANCE(61); + if (lookahead == '/') ADVANCE(6); + if (lookahead == '=') ADVANCE(27); + if (lookahead == '>') ADVANCE(22); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || @@ -481,333 +481,372 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead != 0 && lookahead != '"' && lookahead != '\'' && - lookahead != '<') ADVANCE(67); + lookahead != '<') ADVANCE(28); END_STATE(); case 6: - if (lookahead == ';') ADVANCE(69); + if (lookahead == '>') ADVANCE(25); END_STATE(); case 7: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(6); + if (lookahead == 'C' || + lookahead == 'c') ADVANCE(11); END_STATE(); case 8: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(7); + if (lookahead == 'E' || + lookahead == 'e') ADVANCE(23); END_STATE(); case 9: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(8); + if (lookahead == 'O' || + lookahead == 'o') ADVANCE(7); END_STATE(); case 10: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(9); + if (lookahead == 'P' || + lookahead == 'p') ADVANCE(8); END_STATE(); case 11: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(6); + if (lookahead == 'T' || + lookahead == 't') ADVANCE(13); END_STATE(); case 12: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(11); + if (lookahead == 'X' || + lookahead == 'x') ADVANCE(16); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(35); END_STATE(); case 13: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(12); + if (lookahead == 'Y' || + lookahead == 'y') ADVANCE(10); END_STATE(); case 14: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(13); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(14); + if (lookahead != 0 && + lookahead != '&' && + lookahead != '<' && + lookahead != '>') ADVANCE(76); END_STATE(); case 15: - if (lookahead == ';') ADVANCE(69); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(14); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(20); + if (lookahead != 0 && + lookahead != '>') ADVANCE(21); END_STATE(); case 16: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(6); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(40); END_STATE(); case 17: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(16); + if (eof) ADVANCE(18); + if (lookahead == '&') ADVANCE(3); + if (lookahead == '<') ADVANCE(24); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(17) + if (lookahead != 0 && + lookahead != '>') ADVANCE(76); END_STATE(); case 18: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(17); + ACCEPT_TOKEN(ts_builtin_sym_end); END_STATE(); case 19: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(18); + ACCEPT_TOKEN(anon_sym_LT_BANG); END_STATE(); case 20: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(19); + ACCEPT_TOKEN(aux_sym_doctype_token1); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(20); + if (lookahead != 0 && + lookahead != '>') ADVANCE(21); END_STATE(); case 21: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(20); + ACCEPT_TOKEN(aux_sym_doctype_token1); + if (lookahead != 0 && + lookahead != '>') ADVANCE(21); END_STATE(); case 22: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(21); + ACCEPT_TOKEN(anon_sym_GT); END_STATE(); case 23: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(22); + ACCEPT_TOKEN(sym__doctype); END_STATE(); case 24: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(23); + ACCEPT_TOKEN(anon_sym_LT); + if (lookahead == '!') ADVANCE(19); + if (lookahead == '/') ADVANCE(26); END_STATE(); case 25: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(24); + ACCEPT_TOKEN(anon_sym_SLASH_GT); END_STATE(); case 26: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(25); + ACCEPT_TOKEN(anon_sym_LT_SLASH); END_STATE(); case 27: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(26); + ACCEPT_TOKEN(anon_sym_EQ); END_STATE(); case 28: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(27); + ACCEPT_TOKEN(sym_attribute_name); + if (lookahead != 0 && + lookahead != '\t' && + lookahead != '\n' && + lookahead != '\r' && + lookahead != ' ' && + lookahead != '"' && + lookahead != '\'' && + lookahead != '/' && + (lookahead < '<' || '>' < lookahead)) ADVANCE(28); END_STATE(); case 29: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(28); + ACCEPT_TOKEN(sym_attribute_value); + if (lookahead != 0 && + lookahead != '\t' && + lookahead != '\n' && + lookahead != '\r' && + lookahead != ' ' && + lookahead != '"' && + lookahead != '\'' && + (lookahead < '<' || '>' < lookahead)) ADVANCE(29); END_STATE(); case 30: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(29); + ACCEPT_TOKEN(sym_entity); END_STATE(); case 31: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(30); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); END_STATE(); case 32: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(31); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(31); END_STATE(); case 33: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(32); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(32); END_STATE(); case 34: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(33); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(33); END_STATE(); case 35: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(34); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(34); END_STATE(); case 36: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(31); END_STATE(); case 37: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(36); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(36); END_STATE(); case 38: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(37); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(37); END_STATE(); case 39: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(38); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(38); END_STATE(); case 40: - if (lookahead == ';') ADVANCE(69); - if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(39); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(39); END_STATE(); case 41: - if (lookahead == ';') ADVANCE(69); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(40); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(31); END_STATE(); case 42: - if (lookahead == ';') ADVANCE(69); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); if (('A' <= lookahead && lookahead <= 'Z') || ('a' <= lookahead && lookahead <= 'z')) ADVANCE(41); END_STATE(); case 43: - if (lookahead == ';') ADVANCE(69); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); if (('A' <= lookahead && lookahead <= 'Z') || ('a' <= lookahead && lookahead <= 'z')) ADVANCE(42); END_STATE(); case 44: - if (lookahead == ';') ADVANCE(69); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); if (('A' <= lookahead && lookahead <= 'Z') || ('a' <= lookahead && lookahead <= 'z')) ADVANCE(43); END_STATE(); case 45: - if (lookahead == '>') ADVANCE(64); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); case 46: - if (lookahead == 'C' || - lookahead == 'c') ADVANCE(50); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(45); END_STATE(); case 47: - if (lookahead == 'E' || - lookahead == 'e') ADVANCE(62); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(46); END_STATE(); case 48: - if (lookahead == 'O' || - lookahead == 'o') ADVANCE(46); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(47); END_STATE(); case 49: - if (lookahead == 'P' || - lookahead == 'p') ADVANCE(47); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(48); END_STATE(); case 50: - if (lookahead == 'T' || - lookahead == 't') ADVANCE(52); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(49); END_STATE(); case 51: - if (lookahead == 'X' || - lookahead == 'x') ADVANCE(55); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(10); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(50); END_STATE(); case 52: - if (lookahead == 'Y' || - lookahead == 'y') ADVANCE(49); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(51); END_STATE(); case 53: - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(53); - if (lookahead != 0 && - lookahead != '&' && - lookahead != '<' && - lookahead != '>') ADVANCE(76); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); END_STATE(); case 54: - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(59); - if (lookahead != 0 && - lookahead != '>') ADVANCE(60); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(53); END_STATE(); case 55: - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(15); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(54); END_STATE(); case 56: - if (eof) ADVANCE(57); - if (lookahead == '&') ADVANCE(3); - if (lookahead == '<') ADVANCE(63); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(56) - if (lookahead != 0 && - lookahead != '>') ADVANCE(76); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(55); END_STATE(); case 57: - ACCEPT_TOKEN(ts_builtin_sym_end); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(56); END_STATE(); case 58: - ACCEPT_TOKEN(anon_sym_LT_BANG); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(57); END_STATE(); case 59: - ACCEPT_TOKEN(aux_sym_doctype_token1); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(59); - if (lookahead != 0 && - lookahead != '>') ADVANCE(60); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(58); END_STATE(); case 60: - ACCEPT_TOKEN(aux_sym_doctype_token1); - if (lookahead != 0 && - lookahead != '>') ADVANCE(60); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(59); END_STATE(); case 61: - ACCEPT_TOKEN(anon_sym_GT); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(60); END_STATE(); case 62: - ACCEPT_TOKEN(sym__doctype); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(61); END_STATE(); case 63: - ACCEPT_TOKEN(anon_sym_LT); - if (lookahead == '!') ADVANCE(58); - if (lookahead == '/') ADVANCE(65); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(62); END_STATE(); case 64: - ACCEPT_TOKEN(anon_sym_SLASH_GT); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(63); END_STATE(); case 65: - ACCEPT_TOKEN(anon_sym_LT_SLASH); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(64); END_STATE(); case 66: - ACCEPT_TOKEN(anon_sym_EQ); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(65); END_STATE(); case 67: - ACCEPT_TOKEN(sym_attribute_name); - if (lookahead != 0 && - lookahead != '\t' && - lookahead != '\n' && - lookahead != '\r' && - lookahead != ' ' && - lookahead != '"' && - lookahead != '\'' && - lookahead != '/' && - (lookahead < '<' || '>' < lookahead)) ADVANCE(67); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(66); END_STATE(); case 68: - ACCEPT_TOKEN(sym_attribute_value); - if (lookahead != 0 && - lookahead != '\t' && - lookahead != '\n' && - lookahead != '\r' && - lookahead != ' ' && - lookahead != '"' && - lookahead != '\'' && - (lookahead < '<' || '>' < lookahead)) ADVANCE(68); + ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(67); END_STATE(); case 69: ACCEPT_TOKEN(sym_entity); + if (lookahead == ';') ADVANCE(30); + if (('A' <= lookahead && lookahead <= 'Z') || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(68); END_STATE(); case 70: ACCEPT_TOKEN(anon_sym_SQUOTE); @@ -848,7 +887,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') ADVANCE(53); + lookahead == ' ') ADVANCE(14); if (lookahead != 0 && lookahead != '&' && lookahead != '<' && @@ -861,40 +900,40 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { static const TSLexMode ts_lex_modes[STATE_COUNT] = { [0] = {.lex_state = 0, .external_lex_state = 1}, - [1] = {.lex_state = 56, .external_lex_state = 2}, - [2] = {.lex_state = 56, .external_lex_state = 3}, - [3] = {.lex_state = 56, .external_lex_state = 3}, - [4] = {.lex_state = 56, .external_lex_state = 3}, - [5] = {.lex_state = 56, .external_lex_state = 3}, - [6] = {.lex_state = 56, .external_lex_state = 3}, - [7] = {.lex_state = 56, .external_lex_state = 2}, - [8] = {.lex_state = 56, .external_lex_state = 2}, - [9] = {.lex_state = 56, .external_lex_state = 2}, - [10] = {.lex_state = 56, .external_lex_state = 2}, - [11] = {.lex_state = 56, .external_lex_state = 2}, - [12] = {.lex_state = 56, .external_lex_state = 3}, - [13] = {.lex_state = 56, .external_lex_state = 3}, - [14] = {.lex_state = 56, .external_lex_state = 2}, - [15] = {.lex_state = 56, .external_lex_state = 2}, - [16] = {.lex_state = 56, .external_lex_state = 3}, - [17] = {.lex_state = 56, .external_lex_state = 2}, - [18] = {.lex_state = 56, .external_lex_state = 3}, - [19] = {.lex_state = 56, .external_lex_state = 3}, - [20] = {.lex_state = 56, .external_lex_state = 3}, - [21] = {.lex_state = 56, .external_lex_state = 2}, - [22] = {.lex_state = 56, .external_lex_state = 3}, - [23] = {.lex_state = 56, .external_lex_state = 2}, - [24] = {.lex_state = 56, .external_lex_state = 3}, - [25] = {.lex_state = 56, .external_lex_state = 3}, - [26] = {.lex_state = 56, .external_lex_state = 3}, - [27] = {.lex_state = 56, .external_lex_state = 2}, - [28] = {.lex_state = 56, .external_lex_state = 2}, - [29] = {.lex_state = 56, .external_lex_state = 2}, - [30] = {.lex_state = 56, .external_lex_state = 3}, - [31] = {.lex_state = 56, .external_lex_state = 3}, - [32] = {.lex_state = 56, .external_lex_state = 3}, - [33] = {.lex_state = 56, .external_lex_state = 3}, - [34] = {.lex_state = 56, .external_lex_state = 2}, + [1] = {.lex_state = 17, .external_lex_state = 2}, + [2] = {.lex_state = 17, .external_lex_state = 3}, + [3] = {.lex_state = 17, .external_lex_state = 3}, + [4] = {.lex_state = 17, .external_lex_state = 3}, + [5] = {.lex_state = 17, .external_lex_state = 3}, + [6] = {.lex_state = 17, .external_lex_state = 3}, + [7] = {.lex_state = 17, .external_lex_state = 2}, + [8] = {.lex_state = 17, .external_lex_state = 2}, + [9] = {.lex_state = 17, .external_lex_state = 2}, + [10] = {.lex_state = 17, .external_lex_state = 2}, + [11] = {.lex_state = 17, .external_lex_state = 2}, + [12] = {.lex_state = 17, .external_lex_state = 3}, + [13] = {.lex_state = 17, .external_lex_state = 3}, + [14] = {.lex_state = 17, .external_lex_state = 2}, + [15] = {.lex_state = 17, .external_lex_state = 2}, + [16] = {.lex_state = 17, .external_lex_state = 3}, + [17] = {.lex_state = 17, .external_lex_state = 2}, + [18] = {.lex_state = 17, .external_lex_state = 3}, + [19] = {.lex_state = 17, .external_lex_state = 3}, + [20] = {.lex_state = 17, .external_lex_state = 3}, + [21] = {.lex_state = 17, .external_lex_state = 2}, + [22] = {.lex_state = 17, .external_lex_state = 3}, + [23] = {.lex_state = 17, .external_lex_state = 2}, + [24] = {.lex_state = 17, .external_lex_state = 3}, + [25] = {.lex_state = 17, .external_lex_state = 3}, + [26] = {.lex_state = 17, .external_lex_state = 3}, + [27] = {.lex_state = 17, .external_lex_state = 2}, + [28] = {.lex_state = 17, .external_lex_state = 2}, + [29] = {.lex_state = 17, .external_lex_state = 2}, + [30] = {.lex_state = 17, .external_lex_state = 3}, + [31] = {.lex_state = 17, .external_lex_state = 3}, + [32] = {.lex_state = 17, .external_lex_state = 3}, + [33] = {.lex_state = 17, .external_lex_state = 3}, + [34] = {.lex_state = 17, .external_lex_state = 2}, [35] = {.lex_state = 5, .external_lex_state = 4}, [36] = {.lex_state = 5, .external_lex_state = 4}, [37] = {.lex_state = 5, .external_lex_state = 4}, @@ -939,7 +978,7 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [76] = {.lex_state = 0, .external_lex_state = 2}, [77] = {.lex_state = 0, .external_lex_state = 2}, [78] = {.lex_state = 0, .external_lex_state = 2}, - [79] = {.lex_state = 54, .external_lex_state = 2}, + [79] = {.lex_state = 15, .external_lex_state = 2}, [80] = {.lex_state = 0, .external_lex_state = 2}, [81] = {.lex_state = 0, .external_lex_state = 8}, [82] = {.lex_state = 0, .external_lex_state = 2}, @@ -950,7 +989,7 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [87] = {.lex_state = 0, .external_lex_state = 2}, [88] = {.lex_state = 0, .external_lex_state = 2}, [89] = {.lex_state = 0, .external_lex_state = 8}, - [90] = {.lex_state = 54, .external_lex_state = 2}, + [90] = {.lex_state = 15, .external_lex_state = 2}, [91] = {.lex_state = 0, .external_lex_state = 2}, [92] = {.lex_state = 0, .external_lex_state = 9}, [93] = {.lex_state = 0, .external_lex_state = 2}, @@ -1051,7 +1090,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [sym_comment] = ACTIONS(3), }, [1] = { - [sym_fragment] = STATE(77), + [sym_document] = STATE(77), [sym_doctype] = STATE(8), [sym__node] = STATE(8), [sym_element] = STATE(8), @@ -1062,7 +1101,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [sym_style_start_tag] = STATE(57), [sym_self_closing_tag] = STATE(11), [sym_erroneous_end_tag] = STATE(8), - [aux_sym_fragment_repeat1] = STATE(8), + [aux_sym_document_repeat1] = STATE(8), [ts_builtin_sym_end] = ACTIONS(5), [anon_sym_LT_BANG] = ACTIONS(7), [anon_sym_LT] = ACTIONS(9), @@ -1105,7 +1144,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [44] = 12, ACTIONS(3), 1, sym_comment, @@ -1137,7 +1176,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [88] = 12, ACTIONS(3), 1, sym_comment, @@ -1169,7 +1208,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [132] = 12, ACTIONS(3), 1, sym_comment, @@ -1201,7 +1240,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [176] = 11, ACTIONS(3), 1, sym_comment, @@ -1231,7 +1270,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [217] = 11, ACTIONS(3), 1, sym_comment, @@ -1261,7 +1300,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [258] = 11, ACTIONS(3), 1, sym_comment, @@ -1291,7 +1330,7 @@ static const uint16_t ts_small_parse_table[] = { sym_script_element, sym_style_element, sym_erroneous_end_tag, - aux_sym_fragment_repeat1, + aux_sym_document_repeat1, [299] = 3, ACTIONS(3), 1, sym_comment, @@ -2109,7 +2148,7 @@ 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}}, SHIFT_EXTRA(), - [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_fragment, 0), + [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 0), [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(75), [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(52), [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), @@ -2125,16 +2164,16 @@ static const TSParseActionEntry ts_parse_actions[] = { [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 = true}}, 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 = true}}, 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 = true}}, 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 = true}}, 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), + [37] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(93), + [40] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(51), + [43] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(89), + [46] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(6), + [49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), + [51] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(75), + [54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(52), + [57] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(81), + [60] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(7), + [63] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1), [65] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), [67] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_element, 3), [69] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_element, 3), diff --git a/resources/language-metavariables/tree-sitter-html/src/scanner.c b/resources/language-metavariables/tree-sitter-html/src/scanner.c index 9ec2915a1..078315351 100644 --- a/resources/language-metavariables/tree-sitter-html/src/scanner.c +++ b/resources/language-metavariables/tree-sitter-html/src/scanner.c @@ -1,5 +1,5 @@ #include "tag.h" - +#include "tree_sitter/array.h" #include enum TokenType { @@ -11,107 +11,24 @@ enum TokenType { SELF_CLOSING_TAG_DELIMITER, IMPLICIT_END_TAG, RAW_TEXT, - COMMENT + COMMENT, + OMITTED_HTML_END_TAG, + OMITTED_HEAD_END_TAG, + OMITTED_BODY_END_TAG, }; typedef struct { - uint32_t len; - uint32_t cap; - Tag *data; -} tags_vec; - -typedef struct { - tags_vec tags; + Array(Tag) tags; } Scanner; #define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define VEC_RESIZE(vec, _cap) \ - if ((_cap) > (vec).cap && (_cap) > 0) { \ - void *tmp = realloc((vec).data, (_cap) * sizeof((vec).data[0])); \ - assert(tmp != NULL); \ - (vec).data = tmp; \ - (vec).cap = (_cap); \ - } - -#define VEC_GROW(vec, _cap) \ - if ((vec).cap < (_cap)) { \ - VEC_RESIZE((vec), (_cap)); \ - } - -#define VEC_PUSH(vec, el) \ - if ((vec).cap == (vec).len) { \ - VEC_RESIZE((vec), MAX(16, (vec).len * 2)); \ - } \ - (vec).data[(vec).len++] = (el); - -#define VEC_POP(vec) \ - { \ - if (VEC_BACK(vec).type == CUSTOM) { \ - tag_free(&VEC_BACK(vec)); \ - } \ - (vec).len--; \ - } - -#define VEC_BACK(vec) ((vec).data[(vec).len - 1]) - -#define VEC_FREE(vec) \ - { \ - if ((vec).data != NULL) \ - free((vec).data); \ - (vec).data = NULL; \ - } - -#define VEC_CLEAR(vec) \ - { \ - for (int i = 0; i < (vec).len; i++) { \ - tag_free(&(vec).data[i]); \ - } \ - (vec).len = 0; \ - } - -#define STRING_RESIZE(vec, _cap) \ - void *tmp = realloc((vec).data, ((_cap) + 1) * sizeof((vec).data[0])); \ - assert(tmp != NULL); \ - (vec).data = tmp; \ - memset((vec).data + (vec).len, 0, \ - (((_cap) + 1) - (vec).len) * sizeof((vec).data[0])); \ - (vec).cap = (_cap); - -#define STRING_GROW(vec, _cap) \ - if ((vec).cap < (_cap)) { \ - STRING_RESIZE((vec), (_cap)); \ - } - -#define STRING_PUSH(vec, el) \ - if ((vec).cap == (vec).len) { \ - STRING_RESIZE((vec), MAX(16, (vec).len * 2)); \ - } \ - (vec).data[(vec).len++] = (el); - -#define STRING_INIT(vec) \ - { \ - (vec).data = calloc(1, sizeof(char) * 17); \ - (vec).len = 0; \ - (vec).cap = 16; \ - } +static inline void advance(TSLexer *lexer) { lexer->advance(lexer, false); } -#define STRING_FREE(vec) \ - { \ - if ((vec).data != NULL) \ - free((vec).data); \ - (vec).data = NULL; \ - } - -#define STRING_CLEAR(vec) \ - { \ - (vec).len = 0; \ - memset((vec).data, 0, (vec).cap * sizeof(char)); \ - } +static inline void skip(TSLexer *lexer) { lexer->advance(lexer, true); } static unsigned serialize(Scanner *scanner, char *buffer) { - uint16_t tag_count = - scanner->tags.len > UINT16_MAX ? UINT16_MAX : scanner->tags.len; + uint16_t tag_count = scanner->tags.size > UINT16_MAX ? UINT16_MAX : scanner->tags.size; uint16_t serialized_tag_count = 0; unsigned size = sizeof(tag_count); @@ -119,19 +36,18 @@ static unsigned serialize(Scanner *scanner, char *buffer) { size += sizeof(tag_count); for (; serialized_tag_count < tag_count; serialized_tag_count++) { - Tag tag = scanner->tags.data[serialized_tag_count]; + Tag tag = scanner->tags.contents[serialized_tag_count]; if (tag.type == CUSTOM) { - unsigned name_length = tag.custom_tag_name.len; + unsigned name_length = tag.custom_tag_name.size; if (name_length > UINT8_MAX) { name_length = UINT8_MAX; } - if (size + 2 + name_length >= - TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { + if (size + 2 + name_length >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { break; } buffer[size++] = (char)tag.type; buffer[size++] = (char)name_length; - strncpy(&buffer[size], tag.custom_tag_name.data, name_length); + strncpy(&buffer[size], tag.custom_tag_name.contents, name_length); size += name_length; } else { if (size + 1 >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) { @@ -146,54 +62,51 @@ static unsigned serialize(Scanner *scanner, char *buffer) { } static void deserialize(Scanner *scanner, const char *buffer, unsigned length) { - VEC_CLEAR(scanner->tags); + for (unsigned i = 0; i < scanner->tags.size; i++) { + tag_free(&scanner->tags.contents[i]); + } + array_clear(&scanner->tags); + if (length > 0) { unsigned size = 0; uint16_t tag_count = 0; uint16_t serialized_tag_count = 0; - memcpy(&serialized_tag_count, &buffer[size], - sizeof(serialized_tag_count)); + memcpy(&serialized_tag_count, &buffer[size], sizeof(serialized_tag_count)); size += sizeof(serialized_tag_count); memcpy(&tag_count, &buffer[size], sizeof(tag_count)); size += sizeof(tag_count); - VEC_RESIZE(scanner->tags, tag_count); + array_reserve(&scanner->tags, tag_count); if (tag_count > 0) { unsigned iter = 0; for (iter = 0; iter < serialized_tag_count; iter++) { - Tag tag = scanner->tags.data[iter]; + Tag tag = tag_new(); tag.type = (TagType)buffer[size++]; if (tag.type == CUSTOM) { uint16_t name_length = (uint8_t)buffer[size++]; - tag.custom_tag_name.len = name_length; - tag.custom_tag_name.cap = name_length; - tag.custom_tag_name.data = - (char *)calloc(1, sizeof(char) * (name_length + 1)); - strncpy(tag.custom_tag_name.data, &buffer[size], - name_length); + array_reserve(&tag.custom_tag_name, name_length); + tag.custom_tag_name.size = name_length; + memcpy(tag.custom_tag_name.contents, &buffer[size], name_length); size += name_length; } - VEC_PUSH(scanner->tags, tag); + array_push(&scanner->tags, tag); } // add zero tags if we didn't read enough, this is because the // buffer had no more room but we held more tags. for (; iter < tag_count; iter++) { - Tag tag = new_tag(); - VEC_PUSH(scanner->tags, tag); + array_push(&scanner->tags, tag_new()); } } } } static String scan_tag_name(TSLexer *lexer) { - String tag_name; - STRING_INIT(tag_name); - while (iswalnum(lexer->lookahead) || lexer->lookahead == '-' || - lexer->lookahead == ':') { - STRING_PUSH(tag_name, towupper(lexer->lookahead)); - lexer->advance(lexer, false); + String tag_name = array_new(); + while (iswalnum(lexer->lookahead) || lexer->lookahead == '-' || lexer->lookahead == ':') { + array_push(&tag_name, towupper(lexer->lookahead)); + advance(lexer); } return tag_name; } @@ -202,11 +115,11 @@ static bool scan_comment(TSLexer *lexer) { if (lexer->lookahead != '-') { return false; } - lexer->advance(lexer, false); + advance(lexer); if (lexer->lookahead != '-') { return false; } - lexer->advance(lexer, false); + advance(lexer); unsigned dashes = 0; while (lexer->lookahead) { @@ -217,27 +130,26 @@ static bool scan_comment(TSLexer *lexer) { case '>': if (dashes >= 2) { lexer->result_symbol = COMMENT; - lexer->advance(lexer, false); + advance(lexer); lexer->mark_end(lexer); return true; } default: dashes = 0; } - lexer->advance(lexer, false); + advance(lexer); } return false; } static bool scan_raw_text(Scanner *scanner, TSLexer *lexer) { - if (scanner->tags.len == 0) { + if (scanner->tags.size == 0) { return false; } lexer->mark_end(lexer); - const char *end_delimiter = - VEC_BACK(scanner->tags).type == SCRIPT ? "tags)->type == SCRIPT ? "lookahead) { @@ -246,10 +158,10 @@ static bool scan_raw_text(Scanner *scanner, TSLexer *lexer) { if (delimiter_index == strlen(end_delimiter)) { break; } - lexer->advance(lexer, false); + advance(lexer); } else { delimiter_index = 0; - lexer->advance(lexer, false); + advance(lexer); lexer->mark_end(lexer); } } @@ -258,70 +170,77 @@ static bool scan_raw_text(Scanner *scanner, TSLexer *lexer) { return true; } +static void pop_tag(Scanner *scanner) { + Tag popped_tag = array_pop(&scanner->tags); + tag_free(&popped_tag); +} + static bool scan_implicit_end_tag(Scanner *scanner, TSLexer *lexer) { - Tag *parent = scanner->tags.len == 0 ? NULL : &VEC_BACK(scanner->tags); + Tag *parent = scanner->tags.size == 0 ? NULL : array_back(&scanner->tags); bool is_closing_tag = false; if (lexer->lookahead == '/') { is_closing_tag = true; - lexer->advance(lexer, false); + advance(lexer); } else { - if (parent && is_void(parent)) { - VEC_POP(scanner->tags); + if (parent && tag_is_void(parent)) { + pop_tag(scanner); lexer->result_symbol = IMPLICIT_END_TAG; return true; } } String tag_name = scan_tag_name(lexer); - if (tag_name.len == 0) { - STRING_FREE(tag_name); + if (tag_name.size == 0 && !lexer->eof(lexer)) { + array_delete(&tag_name); return false; } - Tag next_tag = for_name(tag_name.data); + Tag next_tag = tag_for_name(tag_name); if (is_closing_tag) { // The tag correctly closes the topmost element on the stack - if (scanner->tags.len > 0 && - tagcmp(&VEC_BACK(scanner->tags), &next_tag)) { - STRING_FREE(tag_name); + if (scanner->tags.size > 0 && tag_eq(array_back(&scanner->tags), &next_tag)) { tag_free(&next_tag); return false; } // Otherwise, dig deeper and queue implicit end tags (to be nice in // the case of malformed HTML) - for (unsigned i = scanner->tags.len; i > 0; i--) { - if (scanner->tags.data[i - 1].type == next_tag.type) { - VEC_POP(scanner->tags); + for (unsigned i = scanner->tags.size; i > 0; i--) { + if (scanner->tags.contents[i - 1].type == next_tag.type) { + pop_tag(scanner); lexer->result_symbol = IMPLICIT_END_TAG; - STRING_FREE(tag_name); tag_free(&next_tag); return true; } } - } else if (parent && !can_contain(parent, &next_tag)) { - VEC_POP(scanner->tags); + } else if ( + parent && + ( + !tag_can_contain(parent, &next_tag) || + ((parent->type == HTML || parent->type == HEAD || parent->type == BODY) && lexer->eof(lexer)) + ) + ) { + pop_tag(scanner); lexer->result_symbol = IMPLICIT_END_TAG; - STRING_FREE(tag_name); tag_free(&next_tag); return true; } - STRING_FREE(tag_name); tag_free(&next_tag); return false; } static bool scan_start_tag_name(Scanner *scanner, TSLexer *lexer) { String tag_name = scan_tag_name(lexer); - if (tag_name.len == 0) { - STRING_FREE(tag_name); + if (tag_name.size == 0) { + array_delete(&tag_name); return false; } - Tag tag = for_name(tag_name.data); - VEC_PUSH(scanner->tags, tag); + + Tag tag = tag_for_name(tag_name); + array_push(&scanner->tags, tag); switch (tag.type) { case SCRIPT: lexer->result_symbol = SCRIPT_START_TAG_NAME; @@ -333,34 +252,35 @@ static bool scan_start_tag_name(Scanner *scanner, TSLexer *lexer) { lexer->result_symbol = START_TAG_NAME; break; } - STRING_FREE(tag_name); return true; } static bool scan_end_tag_name(Scanner *scanner, TSLexer *lexer) { String tag_name = scan_tag_name(lexer); - if (tag_name.len == 0) { - STRING_FREE(tag_name); + + if (tag_name.size == 0) { + array_delete(&tag_name); return false; } - Tag tag = for_name(tag_name.data); - if (scanner->tags.len > 0 && tagcmp(&VEC_BACK(scanner->tags), &tag)) { - VEC_POP(scanner->tags); + + Tag tag = tag_for_name(tag_name); + if (scanner->tags.size > 0 && tag_eq(array_back(&scanner->tags), &tag)) { + pop_tag(scanner); lexer->result_symbol = END_TAG_NAME; } else { lexer->result_symbol = ERRONEOUS_END_TAG_NAME; } + tag_free(&tag); - STRING_FREE(tag_name); return true; } static bool scan_self_closing_tag_delimiter(Scanner *scanner, TSLexer *lexer) { - lexer->advance(lexer, false); + advance(lexer); if (lexer->lookahead == '>') { - lexer->advance(lexer, false); - if (scanner->tags.len > 0) { - VEC_POP(scanner->tags); + advance(lexer); + if (scanner->tags.size > 0) { + pop_tag(scanner); lexer->result_symbol = SELF_CLOSING_TAG_DELIMITER; } return true; @@ -369,22 +289,21 @@ static bool scan_self_closing_tag_delimiter(Scanner *scanner, TSLexer *lexer) { } static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) { - if (valid_symbols[RAW_TEXT] && !valid_symbols[START_TAG_NAME] && - !valid_symbols[END_TAG_NAME]) { + if (valid_symbols[RAW_TEXT] && !valid_symbols[START_TAG_NAME] && !valid_symbols[END_TAG_NAME]) { return scan_raw_text(scanner, lexer); } while (iswspace(lexer->lookahead)) { - lexer->advance(lexer, true); + skip(lexer); } switch (lexer->lookahead) { case '<': lexer->mark_end(lexer); - lexer->advance(lexer, false); + advance(lexer); if (lexer->lookahead == '!') { - lexer->advance(lexer, false); + advance(lexer); return scan_comment(lexer); } @@ -406,12 +325,9 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) { break; default: - if ((valid_symbols[START_TAG_NAME] || - valid_symbols[END_TAG_NAME]) && - !valid_symbols[RAW_TEXT]) { - return valid_symbols[START_TAG_NAME] - ? scan_start_tag_name(scanner, lexer) - : scan_end_tag_name(scanner, lexer); + if ((valid_symbols[START_TAG_NAME] || valid_symbols[END_TAG_NAME]) && !valid_symbols[RAW_TEXT]) { + return valid_symbols[START_TAG_NAME] ? scan_start_tag_name(scanner, lexer) + : scan_end_tag_name(scanner, lexer); } } @@ -423,30 +339,26 @@ void *tree_sitter_html_external_scanner_create() { return scanner; } -bool tree_sitter_html_external_scanner_scan(void *payload, TSLexer *lexer, - const bool *valid_symbols) { +bool tree_sitter_html_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) { Scanner *scanner = (Scanner *)payload; return scan(scanner, lexer, valid_symbols); } -unsigned tree_sitter_html_external_scanner_serialize(void *payload, - char *buffer) { +unsigned tree_sitter_html_external_scanner_serialize(void *payload, char *buffer) { Scanner *scanner = (Scanner *)payload; return serialize(scanner, buffer); } -void tree_sitter_html_external_scanner_deserialize(void *payload, - const char *buffer, - unsigned length) { +void tree_sitter_html_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) { Scanner *scanner = (Scanner *)payload; deserialize(scanner, buffer, length); } void tree_sitter_html_external_scanner_destroy(void *payload) { Scanner *scanner = (Scanner *)payload; - for (unsigned i = 0; i < scanner->tags.len; i++) { - STRING_FREE(scanner->tags.data[i].custom_tag_name); + for (unsigned i = 0; i < scanner->tags.size; i++) { + tag_free(&scanner->tags.contents[i]); } - VEC_FREE(scanner->tags); + array_delete(&scanner->tags); free(scanner); } diff --git a/resources/language-metavariables/tree-sitter-html/src/tag.h b/resources/language-metavariables/tree-sitter-html/src/tag.h index 2e21c9393..6884fbdd5 100644 --- a/resources/language-metavariables/tree-sitter-html/src/tag.h +++ b/resources/language-metavariables/tree-sitter-html/src/tag.h @@ -1,5 +1,5 @@ #include "tree_sitter/parser.h" - +#include "tree_sitter/array.h" #include #include @@ -137,23 +137,19 @@ typedef enum { END_, } TagType; -typedef struct { - uint32_t len; - uint32_t cap; - char *data; -} String; +typedef Array(char) String; typedef struct { char tag_name[16]; - TagType tag_value; -} TagMap; + TagType tag_type; +} TagMapEntry; typedef struct { TagType type; String custom_tag_name; } Tag; -const TagMap TAG_TYPES_BY_TAG_NAME[126] = { +static const TagMapEntry TAG_TYPES_BY_TAG_NAME[126] = { {"AREA", AREA }, {"BASE", BASE }, {"BASEFONT", BASEFONT }, @@ -289,59 +285,65 @@ static const TagType TAG_TYPES_NOT_ALLOWED_IN_PARAGRAPHS[] = { NAV, OL, P, PRE, SECTION, }; -static TagType get_tag_from_string(const char *tag_name) { +static TagType tag_type_for_name(const String *tag_name) { for (int i = 0; i < 126; i++) { - if (strcmp(TAG_TYPES_BY_TAG_NAME[i].tag_name, tag_name) == 0) { - return TAG_TYPES_BY_TAG_NAME[i].tag_value; + const TagMapEntry *entry = &TAG_TYPES_BY_TAG_NAME[i]; + if ( + strlen(entry->tag_name) == tag_name->size && + memcmp(tag_name->contents, entry->tag_name, tag_name->size) == 0 + ) { + return entry->tag_type; } } return CUSTOM; } -static inline Tag new_tag() { +static inline Tag tag_new() { Tag tag; tag.type = END_; - tag.custom_tag_name.data = NULL; - tag.custom_tag_name.len = 0; - tag.custom_tag_name.cap = 0; + tag.custom_tag_name = (String) array_new(); return tag; } -static Tag make_tag(TagType type, const char *name) { - Tag tag = new_tag(); - tag.type = type; - if (type == CUSTOM) { - tag.custom_tag_name.len = (uint32_t)strlen(name); - tag.custom_tag_name.data = - (char *)calloc(1, sizeof(char) * (tag.custom_tag_name.len + 1)); - strncpy(tag.custom_tag_name.data, name, tag.custom_tag_name.len); +static inline Tag tag_for_name(String name) { + Tag tag = tag_new(); + tag.type = tag_type_for_name(&name); + if (tag.type == CUSTOM) { + tag.custom_tag_name = name; + } else { + array_delete(&name); } return tag; } static inline void tag_free(Tag *tag) { if (tag->type == CUSTOM) { - free(tag->custom_tag_name.data); + array_delete(&tag->custom_tag_name); } - tag->custom_tag_name.data = NULL; -} - -static inline bool is_void(const Tag *tag) { - return tag->type < END_OF_VOID_TAGS; } -static inline Tag for_name(const char *name) { - return make_tag(get_tag_from_string(name), name); +static inline bool tag_is_void(const Tag *self) { + return self->type < END_OF_VOID_TAGS; } -static inline bool tagcmp(const Tag *_tag1, const Tag *_tag2) { - return _tag1->type == _tag2->type && - (_tag1->type == CUSTOM ? strcmp(_tag1->custom_tag_name.data, - _tag2->custom_tag_name.data) == 0 - : true); +static inline bool tag_eq(const Tag *self, const Tag *other) { + if (self->type != other->type) return false; + if (self->type == CUSTOM) { + if (self->custom_tag_name.size != other->custom_tag_name.size) { + return false; + } + if (memcmp( + self->custom_tag_name.contents, + other->custom_tag_name.contents, + self->custom_tag_name.size + ) != 0) { + return false; + } + } + return true; } -static bool can_contain(Tag *self, const Tag *other) { +static bool tag_can_contain(Tag *self, const Tag *other) { TagType child = other->type; switch (self->type) { diff --git a/resources/language-metavariables/tree-sitter-html/src/tree_sitter/alloc.h b/resources/language-metavariables/tree-sitter-html/src/tree_sitter/alloc.h new file mode 100644 index 000000000..1f4466d75 --- /dev/null +++ b/resources/language-metavariables/tree-sitter-html/src/tree_sitter/alloc.h @@ -0,0 +1,54 @@ +#ifndef TREE_SITTER_ALLOC_H_ +#define TREE_SITTER_ALLOC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +// Allow clients to override allocation functions +#ifdef TREE_SITTER_REUSE_ALLOCATOR + +extern void *(*ts_current_malloc)(size_t); +extern void *(*ts_current_calloc)(size_t, size_t); +extern void *(*ts_current_realloc)(void *, size_t); +extern void (*ts_current_free)(void *); + +#ifndef ts_malloc +#define ts_malloc ts_current_malloc +#endif +#ifndef ts_calloc +#define ts_calloc ts_current_calloc +#endif +#ifndef ts_realloc +#define ts_realloc ts_current_realloc +#endif +#ifndef ts_free +#define ts_free ts_current_free +#endif + +#else + +#ifndef ts_malloc +#define ts_malloc malloc +#endif +#ifndef ts_calloc +#define ts_calloc calloc +#endif +#ifndef ts_realloc +#define ts_realloc realloc +#endif +#ifndef ts_free +#define ts_free free +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_ALLOC_H_ diff --git a/resources/language-metavariables/tree-sitter-html/src/tree_sitter/array.h b/resources/language-metavariables/tree-sitter-html/src/tree_sitter/array.h new file mode 100644 index 000000000..15a3b233b --- /dev/null +++ b/resources/language-metavariables/tree-sitter-html/src/tree_sitter/array.h @@ -0,0 +1,290 @@ +#ifndef TREE_SITTER_ARRAY_H_ +#define TREE_SITTER_ARRAY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "./alloc.h" + +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning(disable : 4101) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif + +#define Array(T) \ + struct { \ + T *contents; \ + uint32_t size; \ + uint32_t capacity; \ + } + +/// Initialize an array. +#define array_init(self) \ + ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL) + +/// Create an empty array. +#define array_new() \ + { NULL, 0, 0 } + +/// Get a pointer to the element at a given `index` in the array. +#define array_get(self, _index) \ + (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index]) + +/// Get a pointer to the first element in the array. +#define array_front(self) array_get(self, 0) + +/// Get a pointer to the last element in the array. +#define array_back(self) array_get(self, (self)->size - 1) + +/// Clear the array, setting its size to zero. Note that this does not free any +/// memory allocated for the array's contents. +#define array_clear(self) ((self)->size = 0) + +/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is +/// less than the array's current capacity, this function has no effect. +#define array_reserve(self, new_capacity) \ + _array__reserve((Array *)(self), array_elem_size(self), new_capacity) + +/// Free any memory allocated for this array. Note that this does not free any +/// memory allocated for the array's contents. +#define array_delete(self) _array__delete((Array *)(self)) + +/// Push a new `element` onto the end of the array. +#define array_push(self, element) \ + (_array__grow((Array *)(self), 1, array_elem_size(self)), \ + (self)->contents[(self)->size++] = (element)) + +/// Increase the array's size by `count` elements. +/// New elements are zero-initialized. +#define array_grow_by(self, count) \ + do { \ + if ((count) == 0) break; \ + _array__grow((Array *)(self), count, array_elem_size(self)); \ + memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \ + (self)->size += (count); \ + } while (0) + +/// Append all elements from one array to the end of another. +#define array_push_all(self, other) \ + array_extend((self), (other)->size, (other)->contents) + +/// Append `count` elements to the end of the array, reading their values from the +/// `contents` pointer. +#define array_extend(self, count, contents) \ + _array__splice( \ + (Array *)(self), array_elem_size(self), (self)->size, \ + 0, count, contents \ + ) + +/// Remove `old_count` elements from the array starting at the given `index`. At +/// the same index, insert `new_count` new elements, reading their values from the +/// `new_contents` pointer. +#define array_splice(self, _index, old_count, new_count, new_contents) \ + _array__splice( \ + (Array *)(self), array_elem_size(self), _index, \ + old_count, new_count, new_contents \ + ) + +/// Insert one `element` into the array at the given `index`. +#define array_insert(self, _index, element) \ + _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element)) + +/// Remove one element from the array at the given `index`. +#define array_erase(self, _index) \ + _array__erase((Array *)(self), array_elem_size(self), _index) + +/// Pop the last element off the array, returning the element by value. +#define array_pop(self) ((self)->contents[--(self)->size]) + +/// Assign the contents of one array to another, reallocating if necessary. +#define array_assign(self, other) \ + _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self)) + +/// Swap one array with another +#define array_swap(self, other) \ + _array__swap((Array *)(self), (Array *)(other)) + +/// Get the size of the array contents +#define array_elem_size(self) (sizeof *(self)->contents) + +/// Search a sorted array for a given `needle` value, using the given `compare` +/// callback to determine the order. +/// +/// If an existing element is found to be equal to `needle`, then the `index` +/// out-parameter is set to the existing value's index, and the `exists` +/// out-parameter is set to true. Otherwise, `index` is set to an index where +/// `needle` should be inserted in order to preserve the sorting, and `exists` +/// is set to false. +#define array_search_sorted_with(self, compare, needle, _index, _exists) \ + _array__search_sorted(self, 0, compare, , needle, _index, _exists) + +/// Search a sorted array for a given `needle` value, using integer comparisons +/// of a given struct field (specified with a leading dot) to determine the order. +/// +/// See also `array_search_sorted_with`. +#define array_search_sorted_by(self, field, needle, _index, _exists) \ + _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists) + +/// Insert a given `value` into a sorted array, using the given `compare` +/// callback to determine the order. +#define array_insert_sorted_with(self, compare, value) \ + do { \ + unsigned _index, _exists; \ + array_search_sorted_with(self, compare, &(value), &_index, &_exists); \ + if (!_exists) array_insert(self, _index, value); \ + } while (0) + +/// Insert a given `value` into a sorted array, using integer comparisons of +/// a given struct field (specified with a leading dot) to determine the order. +/// +/// See also `array_search_sorted_by`. +#define array_insert_sorted_by(self, field, value) \ + do { \ + unsigned _index, _exists; \ + array_search_sorted_by(self, field, (value) field, &_index, &_exists); \ + if (!_exists) array_insert(self, _index, value); \ + } while (0) + +// Private + +typedef Array(void) Array; + +/// This is not what you're looking for, see `array_delete`. +static inline void _array__delete(Array *self) { + if (self->contents) { + ts_free(self->contents); + self->contents = NULL; + self->size = 0; + self->capacity = 0; + } +} + +/// This is not what you're looking for, see `array_erase`. +static inline void _array__erase(Array *self, size_t element_size, + uint32_t index) { + assert(index < self->size); + char *contents = (char *)self->contents; + memmove(contents + index * element_size, contents + (index + 1) * element_size, + (self->size - index - 1) * element_size); + self->size--; +} + +/// This is not what you're looking for, see `array_reserve`. +static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) { + if (new_capacity > self->capacity) { + if (self->contents) { + self->contents = ts_realloc(self->contents, new_capacity * element_size); + } else { + self->contents = ts_malloc(new_capacity * element_size); + } + self->capacity = new_capacity; + } +} + +/// This is not what you're looking for, see `array_assign`. +static inline void _array__assign(Array *self, const Array *other, size_t element_size) { + _array__reserve(self, element_size, other->size); + self->size = other->size; + memcpy(self->contents, other->contents, self->size * element_size); +} + +/// This is not what you're looking for, see `array_swap`. +static inline void _array__swap(Array *self, Array *other) { + Array swap = *other; + *other = *self; + *self = swap; +} + +/// This is not what you're looking for, see `array_push` or `array_grow_by`. +static inline void _array__grow(Array *self, uint32_t count, size_t element_size) { + uint32_t new_size = self->size + count; + if (new_size > self->capacity) { + uint32_t new_capacity = self->capacity * 2; + if (new_capacity < 8) new_capacity = 8; + if (new_capacity < new_size) new_capacity = new_size; + _array__reserve(self, element_size, new_capacity); + } +} + +/// This is not what you're looking for, see `array_splice`. +static inline void _array__splice(Array *self, size_t element_size, + uint32_t index, uint32_t old_count, + uint32_t new_count, const void *elements) { + uint32_t new_size = self->size + new_count - old_count; + uint32_t old_end = index + old_count; + uint32_t new_end = index + new_count; + assert(old_end <= self->size); + + _array__reserve(self, element_size, new_size); + + char *contents = (char *)self->contents; + if (self->size > old_end) { + memmove( + contents + new_end * element_size, + contents + old_end * element_size, + (self->size - old_end) * element_size + ); + } + if (new_count > 0) { + if (elements) { + memcpy( + (contents + index * element_size), + elements, + new_count * element_size + ); + } else { + memset( + (contents + index * element_size), + 0, + new_count * element_size + ); + } + } + self->size += new_count - old_count; +} + +/// A binary search routine, based on Rust's `std::slice::binary_search_by`. +/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`. +#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \ + do { \ + *(_index) = start; \ + *(_exists) = false; \ + uint32_t size = (self)->size - *(_index); \ + if (size == 0) break; \ + int comparison; \ + while (size > 1) { \ + uint32_t half_size = size / 2; \ + uint32_t mid_index = *(_index) + half_size; \ + comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \ + if (comparison <= 0) *(_index) = mid_index; \ + size -= half_size; \ + } \ + comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \ + if (comparison == 0) *(_exists) = true; \ + else if (comparison < 0) *(_index) += 1; \ + } while (0) + +/// Helper macro for the `_sorted_by` routines below. This takes the left (existing) +/// parameter by reference in order to work with the generic sorting function above. +#define _compare_int(a, b) ((int)*(a) - (int)(b)) + +#ifdef _MSC_VER +#pragma warning(default : 4101) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_ARRAY_H_ diff --git a/resources/language-metavariables/tree-sitter-typescript/build/Release/tree_sitter_typescript_binding.node b/resources/language-metavariables/tree-sitter-typescript/build/Release/tree_sitter_typescript_binding.node index 62af9d3a8..71f99cdb2 100755 Binary files a/resources/language-metavariables/tree-sitter-typescript/build/Release/tree_sitter_typescript_binding.node and b/resources/language-metavariables/tree-sitter-typescript/build/Release/tree_sitter_typescript_binding.node differ diff --git a/resources/language-metavariables/tree-sitter-typescript/build/tree_sitter_typescript_binding.target.mk b/resources/language-metavariables/tree-sitter-typescript/build/tree_sitter_typescript_binding.target.mk index 8fa9e2e27..9fe25c12d 100644 --- a/resources/language-metavariables/tree-sitter-typescript/build/tree_sitter_typescript_binding.target.mk +++ b/resources/language-metavariables/tree-sitter-typescript/build/tree_sitter_typescript_binding.target.mk @@ -135,26 +135,26 @@ $(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_ # Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD @$(call do_cmd,cxx,1) -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD +$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD @$(call do_cmd,cc,1) +# Try building from generated source, too. + $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD +$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD @$(call do_cmd,cc,1) $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) + # End of this set of suffix rules ### Rules for final target. LDFLAGS_Debug := \ diff --git a/resources/language-metavariables/tree-sitter-typescript/common/define-grammar.js b/resources/language-metavariables/tree-sitter-typescript/common/define-grammar.js index 0db67f6d3..6fc1195cf 100644 --- a/resources/language-metavariables/tree-sitter-typescript/common/define-grammar.js +++ b/resources/language-metavariables/tree-sitter-typescript/common/define-grammar.js @@ -150,6 +150,9 @@ module.exports = function defineGrammar(dialect) { optional($._initializer), ), + // TODO use the below version of the rule as it is up to date with the upstream typescript grammar + // unfortunatly using it breaks the react class componenets to functional componenets pattern + // public_field_definition: ($) => seq( // repeat(field('decorator', $.decorator)), // optional(choice( @@ -441,6 +444,9 @@ module.exports = function defineGrammar(dialect) { '}', ), + // TODO use the below version of the rule as it is up to date with the upstream typescript grammar + // unfortunatly using it breaks the react class componenets to functional componenets pattern + // class_body: ($) => seq( // '{', // repeat(choice( diff --git a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Makefile b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Makefile index 8bcd78b9a..5b9825949 100644 --- a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Makefile +++ b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Makefile @@ -327,7 +327,7 @@ endif quiet_cmd_regen_makefile = ACTION Regenerating $@ cmd_regen_makefile = cd $(srcdir); /Users/itamarlevy-or/.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/itamarlevy-or/Library/Caches/node-gyp/18.5.0" "-Dnode_gyp_dir=/Users/itamarlevy-or/.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/itamarlevy-or/Library/Caches/node-gyp/18.5.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/itamarlevy-or/dev/gritql/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/Users/itamarlevy-or/dev/gritql/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/config.gypi -I/Users/itamarlevy-or/.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/itamarlevy-or/Library/Caches/node-gyp/18.5.0/include/node/common.gypi "--toplevel-dir=." binding.gyp -Makefile: $(srcdir)/../../../../../../../Library/Caches/node-gyp/18.5.0/include/node/common.gypi $(srcdir)/../../../../../../../.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp +Makefile: $(srcdir)/binding.gyp $(srcdir)/../../../../../../../.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../../../../../../../Library/Caches/node-gyp/18.5.0/include/node/common.gypi $(srcdir)/build/config.gypi $(call do_cmd,regen_makefile) # "all" is a concatenation of the "all" targets from all the included diff --git a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/parser.o b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/parser.o index 65bf7499e..d211ec065 100644 Binary files a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/parser.o and b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/parser.o differ diff --git a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/scanner.o b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/scanner.o index 6917008b9..2180780ea 100644 Binary files a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/scanner.o and b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/obj.target/tree_sitter_javascript_binding/src/scanner.o differ diff --git a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/tree_sitter_javascript_binding.node b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/tree_sitter_javascript_binding.node index a6d4afa37..230458b40 100755 Binary files a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/tree_sitter_javascript_binding.node and b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/build/Release/tree_sitter_javascript_binding.node differ diff --git a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/src/node-types.json b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/src/node-types.json index e7717bca4..ec93c93c8 100644 --- a/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/src/node-types.json +++ b/resources/language-metavariables/tree-sitter-typescript/node_modules/tree-sitter-javascript/src/node-types.json @@ -15,10 +15,6 @@ "type": "generator_function_declaration", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "lexical_declaration", "named": true @@ -95,10 +91,6 @@ "type": "array_pattern", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "identifier", "named": true @@ -150,7 +142,7 @@ "named": true }, { - "type": "function", + "type": "function_expression", "named": true }, { @@ -305,68 +297,67 @@ } ] }, + { + "type": "arguments", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "spread_element", + "named": true + } + ] + } + }, { "type": "array", "named": true, - "fields": { - "elements": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "expression", - "named": true - }, - { - "type": "spread_element", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "spread_element", + "named": true + } + ] } }, { "type": "array_pattern", "named": true, - "fields": { - "elements": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "assignment_pattern", + "named": true + }, + { + "type": "pattern", + "named": true + } + ] } }, { "type": "arrow_function", "named": true, "fields": { - "async": { - "multiple": false, - "required": false, - "types": [ - { - "type": "async", - "named": true - } - ] - }, "body": { "multiple": false, "required": true, @@ -381,34 +372,22 @@ } ] }, - "parameters": { - "multiple": true, + "parameter": { + "multiple": false, "required": false, "types": [ { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", + "type": "identifier", "named": true } ] }, - "parenthesis": { - "multiple": true, + "parameters": { + "multiple": false, "required": false, "types": [ { - "type": "l_parenthesis", - "named": true - }, - { - "type": "r_parenthesis", + "type": "formal_parameters", "named": true } ] @@ -522,64 +501,64 @@ "required": true, "types": [ { - "type": "and_equal", - "named": true + "type": "%=", + "named": false }, { - "type": "divide_equal", - "named": true + "type": "&&=", + "named": false }, { - "type": "exponent_equal", - "named": true + "type": "&=", + "named": false }, { - "type": "left_shift_equal", - "named": true + "type": "**=", + "named": false }, { - "type": "logical_and_equal", - "named": true + "type": "*=", + "named": false }, { - "type": "logical_nullish_equal", - "named": true + "type": "+=", + "named": false }, { - "type": "logical_or_equal", - "named": true + "type": "-=", + "named": false }, { - "type": "minus_equal", - "named": true + "type": "/=", + "named": false }, { - "type": "modulo_equal", - "named": true + "type": "<<=", + "named": false }, { - "type": "or_equal", - "named": true + "type": ">>=", + "named": false }, { - "type": "plus_equal", - "named": true + "type": ">>>=", + "named": false }, { - "type": "right_shift_equal", - "named": true + "type": "??=", + "named": false }, { - "type": "times_equal", - "named": true + "type": "^=", + "named": false }, { - "type": "unsigned_right_shift_equal", - "named": true + "type": "|=", + "named": false }, { - "type": "xor_equal", - "named": true + "type": "||=", + "named": false } ] }, @@ -598,24 +577,18 @@ { "type": "await_expression", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + } + ] } }, - { - "type": "binary_divide", - "named": true, - "fields": {} - }, { "type": "binary_expression", "named": true, @@ -627,6 +600,10 @@ { "type": "expression", "named": true + }, + { + "type": "private_property_identifier", + "named": true } ] }, @@ -635,104 +612,104 @@ "required": true, "types": [ { - "type": "binary_divide", - "named": true + "type": "!=", + "named": false }, { - "type": "binary_exp", - "named": true + "type": "!==", + "named": false }, { - "type": "binary_left_shift", - "named": true + "type": "%", + "named": false }, { - "type": "binary_modulo", - "named": true + "type": "&", + "named": false }, { - "type": "binary_right_shift", - "named": true + "type": "&&", + "named": false }, { - "type": "binary_times", - "named": true + "type": "*", + "named": false }, { - "type": "binary_unsigned_right_shift", - "named": true + "type": "**", + "named": false }, { - "type": "bitwise_and", - "named": true + "type": "+", + "named": false }, { - "type": "bitwise_or", - "named": true + "type": "-", + "named": false }, { - "type": "bitwise_xor", - "named": true + "type": "/", + "named": false }, { - "type": "equal", - "named": true + "type": "<", + "named": false }, { - "type": "greater_than", - "named": true + "type": "<<", + "named": false }, { - "type": "greater_than_or_equal", - "named": true + "type": "<=", + "named": false }, { - "type": "in", - "named": true + "type": "==", + "named": false }, { - "type": "instanceof", - "named": true + "type": "===", + "named": false }, { - "type": "less_than", - "named": true + "type": ">", + "named": false }, { - "type": "less_than_or_equal", - "named": true + "type": ">=", + "named": false }, { - "type": "logical_and", - "named": true + "type": ">>", + "named": false }, { - "type": "logical_nullish", - "named": true + "type": ">>>", + "named": false }, { - "type": "logical_or", - "named": true + "type": "??", + "named": false }, { - "type": "minus", - "named": true + "type": "^", + "named": false }, { - "type": "not_equal", - "named": true + "type": "in", + "named": false }, { - "type": "plus", - "named": true + "type": "instanceof", + "named": false }, { - "type": "strict_equal", - "named": true + "type": "|", + "named": false }, { - "type": "strict_not_equal", - "named": true + "type": "||", + "named": false } ] }, @@ -748,11 +725,6 @@ } } }, - { - "type": "binary_times", - "named": true, - "fields": {} - }, { "type": "break_statement", "named": true, @@ -774,19 +746,11 @@ "named": true, "fields": { "arguments": { - "multiple": true, - "required": false, + "multiple": false, + "required": true, "types": [ { - "type": ",", - "named": false - }, - { - "type": "expression", - "named": true - }, - { - "type": "spread_element", + "type": "arguments", "named": true }, { @@ -855,11 +819,6 @@ } } }, - { - "type": "chain", - "named": true, - "fields": {} - }, { "type": "class", "named": true, @@ -884,16 +843,6 @@ } ] }, - "heritage": { - "multiple": false, - "required": false, - "types": [ - { - "type": "class_heritage", - "named": true - } - ] - }, "name": { "multiple": false, "required": false, @@ -904,6 +853,16 @@ } ] } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "class_heritage", + "named": true + } + ] } }, { @@ -964,19 +923,9 @@ } ] }, - "heritage": { + "name": { "multiple": false, - "required": false, - "types": [ - { - "type": "class_heritage", - "named": true - } - ] - }, - "name": { - "multiple": false, - "required": true, + "required": true, "types": [ { "type": "identifier", @@ -984,22 +933,31 @@ } ] } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "class_heritage", + "named": true + } + ] } }, { "type": "class_heritage", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + } + ] } }, { @@ -1016,16 +974,6 @@ } ] } - }, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "static", - "named": true - } - ] } }, { @@ -1036,17 +984,16 @@ { "type": "computed_property_name", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + } + ] } }, { @@ -1073,25 +1020,24 @@ { "type": "decorator", "named": true, - "fields": { - "identifier": { - "multiple": false, - "required": true, - "types": [ - { - "type": "call_expression", - "named": true - }, - { - "type": "identifier", - "named": true - }, - { - "type": "member_expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "call_expression", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "member_expression", + "named": true + } + ] } }, { @@ -1123,17 +1069,16 @@ { "type": "else_clause", "named": true, - "fields": { - "else": { - "multiple": false, - "required": true, - "types": [ - { - "type": "statement", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "statement", + "named": true + } + ] } }, { @@ -1144,21 +1089,16 @@ { "type": "export_clause", "named": true, - "fields": { - "specifiers": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "export_specifier", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "export_specifier", + "named": true + } + ] } }, { @@ -1206,10 +1146,6 @@ { "type": "declaration", "named": true - }, - { - "type": "expression", - "named": true } ] }, @@ -1223,58 +1159,59 @@ } ] }, - "export": { + "source": { "multiple": false, "required": false, "types": [ { - "type": "export_clause", - "named": true - }, - { - "type": "namespace_export", + "type": "string", "named": true } ] }, - "source": { + "value": { "multiple": false, "required": false, "types": [ { - "type": "grit_metavariable", - "named": true - }, - { - "type": "string", + "type": "expression", "named": true } ] } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "export_clause", + "named": true + }, + { + "type": "namespace_export", + "named": true + } + ] } }, { "type": "expression_statement", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - }, - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "sequence_expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "sequence_expression", + "named": true + } + ] } }, { @@ -1299,10 +1236,6 @@ "type": "computed_property_name", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "number", "named": true @@ -1321,16 +1254,6 @@ } ] }, - "static": { - "multiple": false, - "required": false, - "types": [ - { - "type": "static", - "named": true - } - ] - }, "value": { "multiple": false, "required": false, @@ -1379,15 +1302,15 @@ "types": [ { "type": "const", - "named": true + "named": false }, { "type": "let", - "named": true + "named": false }, { "type": "var", - "named": true + "named": false } ] }, @@ -1431,11 +1354,11 @@ "types": [ { "type": "in", - "named": true + "named": false }, { "type": "of", - "named": true + "named": false } ] }, @@ -1447,10 +1370,6 @@ "type": "expression", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "sequence_expression", "named": true @@ -1505,10 +1424,6 @@ "type": "expression", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "sequence_expression", "named": true @@ -1540,19 +1455,28 @@ } }, { - "type": "function", + "type": "formal_parameters", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "assignment_pattern", + "named": true + }, + { + "type": "pattern", + "named": true + } + ] + } + }, + { + "type": "function_declaration", "named": true, "fields": { - "async": { - "multiple": false, - "required": false, - "types": [ - { - "type": "async", - "named": true - } - ] - }, "body": { "multiple": false, "required": true, @@ -1565,7 +1489,7 @@ }, "name": { "multiple": false, - "required": false, + "required": true, "types": [ { "type": "identifier", @@ -1574,33 +1498,11 @@ ] }, "parameters": { - "multiple": true, - "required": false, + "multiple": false, + "required": true, "types": [ { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", - "named": true - } - ] - }, - "parenthesis": { - "multiple": true, - "required": true, - "types": [ - { - "type": "l_parenthesis", - "named": true - }, - { - "type": "r_parenthesis", + "type": "formal_parameters", "named": true } ] @@ -1608,19 +1510,9 @@ } }, { - "type": "function_declaration", + "type": "function_expression", "named": true, "fields": { - "async": { - "multiple": false, - "required": false, - "types": [ - { - "type": "async", - "named": true - } - ] - }, "body": { "multiple": false, "required": true, @@ -1633,7 +1525,7 @@ }, "name": { "multiple": false, - "required": true, + "required": false, "types": [ { "type": "identifier", @@ -1642,33 +1534,11 @@ ] }, "parameters": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", - "named": true - } - ] - }, - "parenthesis": { - "multiple": true, + "multiple": false, "required": true, "types": [ { - "type": "l_parenthesis", - "named": true - }, - { - "type": "r_parenthesis", + "type": "formal_parameters", "named": true } ] @@ -1679,16 +1549,6 @@ "type": "generator_function", "named": true, "fields": { - "async": { - "multiple": false, - "required": false, - "types": [ - { - "type": "async", - "named": true - } - ] - }, "body": { "multiple": false, "required": true, @@ -1710,33 +1570,11 @@ ] }, "parameters": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", - "named": true - } - ] - }, - "parenthesis": { - "multiple": true, + "multiple": false, "required": true, "types": [ { - "type": "l_parenthesis", - "named": true - }, - { - "type": "r_parenthesis", + "type": "formal_parameters", "named": true } ] @@ -1747,16 +1585,6 @@ "type": "generator_function_declaration", "named": true, "fields": { - "async": { - "multiple": false, - "required": false, - "types": [ - { - "type": "async", - "named": true - } - ] - }, "body": { "multiple": false, "required": true, @@ -1778,33 +1606,11 @@ ] }, "parameters": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", - "named": true - } - ] - }, - "parenthesis": { - "multiple": true, + "multiple": false, "required": true, "types": [ { - "type": "l_parenthesis", - "named": true - }, - { - "type": "r_parenthesis", + "type": "formal_parameters", "named": true } ] @@ -1847,26 +1653,6 @@ } } }, - { - "type": "greater_than", - "named": true, - "fields": {} - }, - { - "type": "identifier", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": false, - "types": [ - { - "type": "grit_metavariable", - "named": true - } - ] - } - }, { "type": "if_statement", "named": true, @@ -1926,31 +1712,24 @@ { "type": "import_clause", "named": true, - "fields": { - "default": { - "multiple": false, - "required": false, - "types": [ - { - "type": "identifier", - "named": true - } - ] - }, - "name": { - "multiple": false, - "required": false, - "types": [ - { - "type": "named_imports", - "named": true - }, - { - "type": "namespace_import", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + }, + { + "type": "named_imports", + "named": true + }, + { + "type": "namespace_import", + "named": true + } + ] } }, { @@ -1987,82 +1766,65 @@ "type": "import_statement", "named": true, "fields": { - "attribute": { - "multiple": false, - "required": false, - "types": [ - { - "type": "import_attribute", - "named": true - } - ] - }, - "import": { - "multiple": false, - "required": false, - "types": [ - { - "type": "import_clause", - "named": true - } - ] - }, "source": { "multiple": false, "required": true, "types": [ - { - "type": "grit_metavariable", - "named": true - }, { "type": "string", "named": true } ] } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "import_attribute", + "named": true + }, + { + "type": "import_clause", + "named": true + } + ] } }, { "type": "jsx_attribute", "named": true, - "fields": { - "name": { - "multiple": false, - "required": true, - "types": [ - { - "type": "jsx_namespace_name", - "named": true - }, - { - "type": "property_identifier", - "named": true - } - ] - }, - "value": { - "multiple": false, - "required": false, - "types": [ - { - "type": "jsx_element", - "named": true - }, - { - "type": "jsx_expression", - "named": true - }, - { - "type": "jsx_self_closing_element", - "named": true - }, - { - "type": "string", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "jsx_element", + "named": true + }, + { + "type": "jsx_expression", + "named": true + }, + { + "type": "jsx_namespace_name", + "named": true + }, + { + "type": "jsx_self_closing_element", + "named": true + }, + { + "type": "property_identifier", + "named": true + }, + { + "type": "string", + "named": true + } + ] } }, { @@ -2093,36 +1855,6 @@ "type": "jsx_element", "named": true, "fields": { - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "html_character_reference", - "named": true - }, - { - "type": "jsx_element", - "named": true - }, - { - "type": "jsx_expression", - "named": true - }, - { - "type": "jsx_self_closing_element", - "named": true - }, - { - "type": "jsx_text", - "named": true - } - ] - }, "close_tag": { "multiple": false, "required": true, @@ -2143,56 +1875,70 @@ } ] } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "html_character_reference", + "named": true + }, + { + "type": "jsx_element", + "named": true + }, + { + "type": "jsx_expression", + "named": true + }, + { + "type": "jsx_self_closing_element", + "named": true + }, + { + "type": "jsx_text", + "named": true + } + ] } }, { "type": "jsx_expression", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": false, - "types": [ - { - "type": "expression", - "named": true - }, - { - "type": "sequence_expression", - "named": true - }, - { - "type": "spread_element", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "sequence_expression", + "named": true + }, + { + "type": "spread_element", + "named": true + } + ] } }, { "type": "jsx_namespace_name", "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": true, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] } }, { @@ -2302,78 +2048,60 @@ } } }, - { - "type": "less_than", - "named": true, - "fields": {} - }, { "type": "lexical_declaration", "named": true, "fields": { - "declarations": { - "multiple": true, - "required": true, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "variable_declarator", - "named": true - } - ] - }, "kind": { "multiple": false, "required": true, "types": [ { "type": "const", - "named": true + "named": false }, { "type": "let", - "named": true + "named": false } ] } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "variable_declarator", + "named": true + } + ] } }, - { - "type": "logical_or", - "named": true, - "fields": {} - }, { "type": "member_expression", "named": true, "fields": { - "chain": { + "object": { "multiple": false, - "required": false, + "required": true, "types": [ { - "type": "chain", + "type": "expression", "named": true }, { - "type": "optional_chain", + "type": "import", "named": true } ] }, - "object": { + "optional_chain": { "multiple": false, - "required": true, + "required": false, "types": [ { - "type": "expression", - "named": true - }, - { - "type": "import", + "type": "optional_chain", "named": true } ] @@ -2403,16 +2131,6 @@ "type": "method_definition", "named": true, "fields": { - "async": { - "multiple": false, - "required": false, - "types": [ - { - "type": "async", - "named": true - } - ] - }, "body": { "multiple": false, "required": true, @@ -2441,10 +2159,6 @@ "type": "computed_property_name", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "number", "named": true @@ -2464,47 +2178,11 @@ ] }, "parameters": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "assignment_pattern", - "named": true - }, - { - "type": "pattern", - "named": true - } - ] - }, - "parenthesis": { - "multiple": true, - "required": true, - "types": [ - { - "type": "l_parenthesis", - "named": true - }, - { - "type": "r_parenthesis", - "named": true - } - ] - }, - "static": { "multiple": false, - "required": false, + "required": true, "types": [ { - "type": "static", - "named": true - }, - { - "type": "static_get", + "type": "formal_parameters", "named": true } ] @@ -2514,28 +2192,13 @@ { "type": "named_imports", "named": true, - "fields": { - "imports": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "import_specifier", - "named": true - } - ] - } - }, + "fields": {}, "children": { - "multiple": false, + "multiple": true, "required": false, "types": [ { - "type": "grit_metavariable", + "type": "import_specifier", "named": true } ] @@ -2544,37 +2207,35 @@ { "type": "namespace_export", "named": true, - "fields": { - "module": { - "multiple": false, - "required": true, - "types": [ - { - "type": "identifier", - "named": true - }, - { - "type": "string", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + }, + { + "type": "string", + "named": true + } + ] } }, { "type": "namespace_import", "named": true, - "fields": { - "namespace": { - "multiple": false, - "required": true, - "types": [ - { - "type": "identifier", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] } }, { @@ -2582,19 +2243,11 @@ "named": true, "fields": { "arguments": { - "multiple": true, + "multiple": false, "required": false, "types": [ { - "type": ",", - "named": false - }, - { - "type": "expression", - "named": true - }, - { - "type": "spread_element", + "type": "arguments", "named": true } ] @@ -2618,33 +2271,28 @@ { "type": "object", "named": true, - "fields": { - "properties": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "method_definition", - "named": true - }, - { - "type": "pair", - "named": true - }, - { - "type": "shorthand_property_identifier", - "named": true - }, - { - "type": "spread_element", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "method_definition", + "named": true + }, + { + "type": "pair", + "named": true + }, + { + "type": "shorthand_property_identifier", + "named": true + }, + { + "type": "spread_element", + "named": true + } + ] } }, { @@ -2684,33 +2332,28 @@ { "type": "object_pattern", "named": true, - "fields": { - "properties": { - "multiple": true, - "required": false, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "object_assignment_pattern", - "named": true - }, - { - "type": "pair_pattern", - "named": true - }, - { - "type": "rest_pattern", - "named": true - }, - { - "type": "shorthand_property_identifier_pattern", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "object_assignment_pattern", + "named": true + }, + { + "type": "pair_pattern", + "named": true + }, + { + "type": "rest_pattern", + "named": true + }, + { + "type": "shorthand_property_identifier_pattern", + "named": true + } + ] } }, { @@ -2725,10 +2368,6 @@ "type": "computed_property_name", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "number", "named": true @@ -2771,10 +2410,6 @@ "type": "computed_property_name", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "number", "named": true @@ -2812,63 +2447,36 @@ { "type": "parenthesized_expression", "named": true, - "fields": { - "expressions": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - }, - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "sequence_expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "sequence_expression", + "named": true + } + ] } }, { "type": "program", "named": true, - "fields": { - "hash_bang": { - "multiple": false, - "required": false, - "types": [ - { - "type": "hash_bang_line", - "named": true - } - ] - }, - "statements": { - "multiple": true, - "required": false, - "types": [ - { - "type": "statement", - "named": true - } - ] - } - } - }, - { - "type": "property_identifier", - "named": true, "fields": {}, "children": { - "multiple": false, + "multiple": true, "required": false, "types": [ { - "type": "grit_metavariable", + "type": "hash_bang_line", + "named": true + }, + { + "type": "statement", "named": true } ] @@ -2883,97 +2491,17 @@ "required": false, "types": [ { - "type": "regex_flags", - "named": true - } - ] - }, - "pattern": { - "multiple": false, - "required": true, - "types": [ - { - "type": "regex_pattern", - "named": true - } - ] - } - } - }, - { - "type": "rest_pattern", - "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "array_pattern", - "named": true - }, - { - "type": "identifier", - "named": true - }, - { - "type": "member_expression", - "named": true - }, - { - "type": "object_pattern", - "named": true - }, - { - "type": "subscript_expression", - "named": true - }, - { - "type": "undefined", - "named": true - } - ] - } - } - }, - { - "type": "return_statement", - "named": true, - "fields": { - "expressions": { - "multiple": false, - "required": false, - "types": [ - { - "type": "expression", - "named": true - }, - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "sequence_expression", + "type": "regex_flags", "named": true } ] - } - } - }, - { - "type": "sequence_expression", - "named": true, - "fields": { - "expressions": { - "multiple": true, + }, + "pattern": { + "multiple": false, "required": true, "types": [ { - "type": ",", - "named": false - }, - { - "type": "expression", + "type": "regex_pattern", "named": true } ] @@ -2981,22 +2509,42 @@ } }, { - "type": "shorthand_property_identifier", + "type": "rest_pattern", "named": true, "fields": {}, "children": { "multiple": false, - "required": false, + "required": true, "types": [ { - "type": "grit_metavariable", + "type": "array_pattern", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "member_expression", + "named": true + }, + { + "type": "object_pattern", + "named": true + }, + { + "type": "subscript_expression", + "named": true + }, + { + "type": "undefined", "named": true } ] } }, { - "type": "shorthand_property_identifier_pattern", + "type": "return_statement", "named": true, "fields": {}, "children": { @@ -3004,54 +2552,56 @@ "required": false, "types": [ { - "type": "grit_metavariable", + "type": "expression", + "named": true + }, + { + "type": "sequence_expression", "named": true } ] } }, { - "type": "spread_element", + "type": "sequence_expression", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "expression", + "named": true + } + ] } }, { - "type": "statement_block", + "type": "spread_element", "named": true, - "fields": { - "statements": { - "multiple": true, - "required": false, - "types": [ - { - "type": "statement", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + } + ] } }, { - "type": "statement_identifier", + "type": "statement_block", "named": true, "fields": {}, "children": { - "multiple": false, + "multiple": true, "required": false, "types": [ { - "type": "grit_metavariable", + "type": "statement", "named": true } ] @@ -3060,30 +2610,15 @@ { "type": "string", "named": true, - "fields": { - "fragment": { - "multiple": true, - "required": false, - "types": [ - { - "type": "escape_sequence", - "named": true - }, - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "string_fragment", - "named": true - } - ] - } - }, + "fields": {}, "children": { "multiple": true, "required": false, "types": [ + { + "type": "escape_sequence", + "named": true + }, { "type": "html_character_reference", "named": true @@ -3107,10 +2642,6 @@ "type": "expression", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "sequence_expression", "named": true @@ -3180,10 +2711,6 @@ "type": "expression", "named": true }, - { - "type": "grit_metavariable", - "named": true - }, { "type": "sequence_expression", "named": true @@ -3234,68 +2761,46 @@ } } }, - { - "type": "template_content", - "named": true, - "fields": { - "content": { - "multiple": true, - "required": true, - "types": [ - { - "type": "escape_sequence", - "named": true - }, - { - "type": "string_fragment", - "named": true - }, - { - "type": "template_substitution", - "named": true - } - ] - } - } - }, { "type": "template_string", "named": true, - "fields": { - "template": { - "multiple": false, - "required": false, - "types": [ - { - "type": "template_content", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "escape_sequence", + "named": true + }, + { + "type": "string_fragment", + "named": true + }, + { + "type": "template_substitution", + "named": true + } + ] } }, { "type": "template_substitution", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - }, - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "sequence_expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "sequence_expression", + "named": true + } + ] } }, { @@ -3337,25 +2842,20 @@ { "type": "throw_statement", "named": true, - "fields": { - "expressions": { - "multiple": false, - "required": true, - "types": [ - { - "type": "expression", - "named": true - }, - { - "type": "grit_metavariable", - "named": true - }, - { - "type": "sequence_expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "expression", + "named": true + }, + { + "type": "sequence_expression", + "named": true + } + ] } }, { @@ -3413,32 +2913,32 @@ "required": true, "types": [ { - "type": "bitwise_not", - "named": true - }, - { - "type": "delete", - "named": true + "type": "!", + "named": false }, { - "type": "minus", - "named": true + "type": "+", + "named": false }, { - "type": "not", - "named": true + "type": "-", + "named": false }, { - "type": "plus", - "named": true + "type": "delete", + "named": false }, { "type": "typeof", - "named": true + "named": false }, { "type": "void", - "named": true + "named": false + }, + { + "type": "~", + "named": false } ] } @@ -3463,12 +2963,12 @@ "required": true, "types": [ { - "type": "decrement", - "named": true + "type": "++", + "named": false }, { - "type": "increment", - "named": true + "type": "--", + "named": false } ] } @@ -3477,28 +2977,13 @@ { "type": "variable_declaration", "named": true, - "fields": { - "declarations": { - "multiple": true, - "required": true, - "types": [ - { - "type": ",", - "named": false - }, - { - "type": "variable_declarator", - "named": true - } - ] - } - }, + "fields": {}, "children": { - "multiple": false, + "multiple": true, "required": true, "types": [ { - "type": "var", + "type": "variable_declarator", "named": true } ] @@ -3593,19 +3078,30 @@ { "type": "yield_expression", "named": true, - "fields": { - "expression": { - "multiple": false, - "required": false, - "types": [ - { - "type": "expression", - "named": true - } - ] - } + "fields": {}, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "expression", + "named": true + } + ] } }, + { + "type": "!", + "named": false + }, + { + "type": "!=", + "named": false + }, + { + "type": "!==", + "named": false + }, { "type": "\"", "named": false @@ -3614,6 +3110,30 @@ "type": "${", "named": false }, + { + "type": "%", + "named": false + }, + { + "type": "%=", + "named": false + }, + { + "type": "&", + "named": false + }, + { + "type": "&&", + "named": false + }, + { + "type": "&&=", + "named": false + }, + { + "type": "&=", + "named": false + }, { "type": "'", "named": false @@ -3630,10 +3150,46 @@ "type": "*", "named": false }, + { + "type": "**", + "named": false + }, + { + "type": "**=", + "named": false + }, + { + "type": "*=", + "named": false + }, + { + "type": "+", + "named": false + }, + { + "type": "++", + "named": false + }, + { + "type": "+=", + "named": false + }, { "type": ",", "named": false }, + { + "type": "-", + "named": false + }, + { + "type": "--", + "named": false + }, + { + "type": "-=", + "named": false + }, { "type": ".", "named": false @@ -3646,6 +3202,10 @@ "type": "/", "named": false }, + { + "type": "/=", + "named": false + }, { "type": "/>", "named": false @@ -3670,6 +3230,18 @@ "type": "", "named": false }, + { + "type": "<<", + "named": false + }, + { + "type": "<<=", + "named": false + }, + { + "type": "<=", + "named": false + }, { "type": "