diff --git a/Cargo.lock b/Cargo.lock index dc40008..2a354f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 4 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "cc" -version = "1.2.41" +version = "1.2.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" +checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38" dependencies = [ "find-msvc-tools", "shlex", @@ -29,21 +29,21 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "indexmap" -version = "2.11.4" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", "hashbrown", @@ -51,39 +51,39 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.41" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.12.2" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +checksum = "2a0e75113e14dc5acb068cd0786884f214f1312650a3d36d269f5c4f3cdee8a2" dependencies = [ "aho-corasick", "memchr", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "1f388202e4b80542a0921078cc23b6333bcf1409c1e3f86404cae4766a6131db" dependencies = [ "aho-corasick", "memchr", @@ -104,15 +104,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" - -[[package]] -name = "ryu" -version = "1.0.20" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "serde" @@ -145,23 +139,23 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.145" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "indexmap", "itoa", "memchr", - "ryu", "serde", "serde_core", + "zmij", ] [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "streaming-iterator" @@ -171,9 +165,9 @@ checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" [[package]] name = "syn" -version = "2.0.106" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ "proc-macro2", "quote", @@ -182,9 +176,9 @@ dependencies = [ [[package]] name = "tree-sitter" -version = "0.25.10" +version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78f873475d258561b06f1c595d93308a7ed124d9977cb26b148c2084a4a3cc87" +checksum = "af1c71c1c4cc0920b20d6b0f6572e7682cd07a6a2faec71067a31fa394c586df" dependencies = [ "cc", "regex", @@ -196,9 +190,9 @@ dependencies = [ [[package]] name = "tree-sitter-language" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4013970217383f67b18aef68f6fb2e8d409bc5755227092d32efb0422ba24b8" +checksum = "009994f150cc0cd50ff54917d5bc8bffe8cad10ca10d81c34da2ec421ae61782" [[package]] name = "tree-sitter-wit" @@ -211,6 +205,12 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "zmij" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml index 720d196..d67dc64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,4 +31,4 @@ tree-sitter-language = "0.1" cc = "1.2" [dev-dependencies] -tree-sitter = "0.25.6" +tree-sitter = "0.26.11" diff --git a/Makefile b/Makefile index 73307c5..d9f8ef7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ LANGUAGE_NAME := tree-sitter-wit HOMEPAGE_URL := https://github.com/liamwh/tree-sitter-wit VERSION := 1.2.0 +DESCRIPTION := WIT grammar for tree-sitter # repository SRC_DIR := src diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index 3ece67f..4c40394 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -15,7 +15,7 @@ //! assert!(!tree.root_node().has_error()); //! ``` //! -//! [`Parser`]: https://docs.rs/tree-sitter/0.26.6/tree_sitter/struct.Parser.html +//! [`Parser`]: https://docs.rs/tree-sitter/0.26.11/tree_sitter/struct.Parser.html //! [tree-sitter]: https://tree-sitter.github.io/ use tree_sitter_language::LanguageFn; diff --git a/grammar.js b/grammar.js index 1e98474..3961d0e 100644 --- a/grammar.js +++ b/grammar.js @@ -10,7 +10,7 @@ const commaSeparatedList = (rule) => seq(rule, repeat(seq(',', rule)), optional(',')); -module.exports = grammar({ +export default grammar({ name: 'wit', extras: $ => [ diff --git a/justfile b/justfile index 76e3f68..a3482e0 100644 --- a/justfile +++ b/justfile @@ -46,7 +46,7 @@ lint: # updates node package.json to latest available update: pnpm outdated --format json | jq 'keys[]' | xargs pnpm update - cargo upgrade && cargo update + cargo upgrade --incompatible && cargo update # updates node package.json to latest available outdated: diff --git a/package.json b/package.json index fa7edfd..a0710fc 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "src/**" ], "dependencies": { - "node-addon-api": "^8.6.0", + "node-addon-api": "^8.9.0", "node-gyp-build": "^4.8.4" }, "peerDependencies": { @@ -47,8 +47,8 @@ } }, "devDependencies": { - "@eslint/js": "^9.39.3", - "eslint": "^9.39.3", + "@eslint/js": "^9.39.5", + "eslint": "^9.39.5", "eslint-config-treesitter": "^1.0.2", "globals": "^16.5.0", "prebuildify": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4dff3b5..4363f71 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: node-addon-api: - specifier: ^8.6.0 - version: 8.6.0 + specifier: ^8.9.0 + version: 8.9.0 node-gyp-build: specifier: ^4.8.4 version: 4.8.4 @@ -19,14 +19,14 @@ importers: version: 0.22.4 devDependencies: '@eslint/js': - specifier: ^9.39.3 - version: 9.39.3 + specifier: ^9.39.5 + version: 9.39.5 eslint: - specifier: ^9.39.3 - version: 9.39.3 + specifier: ^9.39.5 + version: 9.39.5 eslint-config-treesitter: specifier: ^1.0.2 - version: 1.0.2(eslint@9.39.3) + version: 1.0.2(eslint@9.39.5) globals: specifier: ^16.5.0 version: 16.5.0 @@ -53,8 +53,8 @@ packages: resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint/config-array@0.21.1': - resolution: {integrity: sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==} + '@eslint/config-array@0.21.2': + resolution: {integrity: sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/config-helpers@0.4.2': @@ -65,12 +65,12 @@ packages: resolution: {integrity: sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/eslintrc@3.3.4': - resolution: {integrity: sha512-4h4MVF8pmBsncB60r0wSJiIeUKTSD4m7FmTFThG8RHlsg9ajqckLm9OraguFGZE4vVdpiI1Q4+hFnisopmG6gQ==} + '@eslint/eslintrc@3.3.6': + resolution: {integrity: sha512-l2Ul9PrHsPCKcEY/ac7VgFj9D80C7S68sOKc618SyHDPK36s1XcFebXY0iTzUVn4Yq+YbwvSnDmCz9yxjX+QrA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.39.3': - resolution: {integrity: sha512-1B1VkCq6FuUNlQvlBYb+1jDu/gV297TIs/OeiaSR9l1H27SVW55ONE1e1Vp16NqP683+xEGzxYtv4XCiDPaQiw==} + '@eslint/js@9.39.5': + resolution: {integrity: sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.7': @@ -217,8 +217,8 @@ packages: resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint@9.39.3: - resolution: {integrity: sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==} + eslint@9.39.5: + resolution: {integrity: sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -319,8 +319,8 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - js-yaml@4.1.1: - resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==} + js-yaml@4.3.0: + resolution: {integrity: sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==} hasBin: true jsdoc-type-pratt-parser@4.1.0: @@ -373,6 +373,10 @@ packages: resolution: {integrity: sha512-gBVjCaqDlRUk0EwoPNKzIr9KkS9041G/q31IBShPs1Xz6UTA+EXdZADbzqAJQrpDRq71CIMnOP5VMut3SL0z5Q==} engines: {node: ^18 || ^20 || >= 21} + node-addon-api@8.9.0: + resolution: {integrity: sha512-ekZMeaaIzSQTSpr7X2X3iJM7lTzgnx8ahAG9pJfT/7+14mlEM8ZYQ9cgCDvSSRbReFK0oHli3WrZdCiRsgAT9Q==} + engines: {node: ^18 || ^20 || >= 21} + node-gyp-build@4.8.4: resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} hasBin: true @@ -524,14 +528,14 @@ snapshots: esquery: 1.7.0 jsdoc-type-pratt-parser: 4.1.0 - '@eslint-community/eslint-utils@4.9.1(eslint@9.39.3)': + '@eslint-community/eslint-utils@4.9.1(eslint@9.39.5)': dependencies: - eslint: 9.39.3 + eslint: 9.39.5 eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} - '@eslint/config-array@0.21.1': + '@eslint/config-array@0.21.2': dependencies: '@eslint/object-schema': 2.1.7 debug: 4.4.3 @@ -547,7 +551,7 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 - '@eslint/eslintrc@3.3.4': + '@eslint/eslintrc@3.3.6': dependencies: ajv: 6.14.0 debug: 4.4.3 @@ -555,13 +559,13 @@ snapshots: globals: 14.0.0 ignore: 5.3.2 import-fresh: 3.3.1 - js-yaml: 4.1.1 + js-yaml: 4.3.0 minimatch: 3.1.5 strip-json-comments: 3.1.1 transitivePeerDependencies: - supports-color - '@eslint/js@9.39.3': {} + '@eslint/js@9.39.5': {} '@eslint/object-schema@2.1.7': {} @@ -665,21 +669,21 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-treesitter@1.0.2(eslint@9.39.3): + eslint-config-treesitter@1.0.2(eslint@9.39.5): dependencies: - eslint: 9.39.3 - eslint-plugin-jsdoc: 50.8.0(eslint@9.39.3) + eslint: 9.39.5 + eslint-plugin-jsdoc: 50.8.0(eslint@9.39.5) transitivePeerDependencies: - supports-color - eslint-plugin-jsdoc@50.8.0(eslint@9.39.3): + eslint-plugin-jsdoc@50.8.0(eslint@9.39.5): dependencies: '@es-joy/jsdoccomment': 0.50.2 are-docs-informative: 0.0.2 comment-parser: 1.4.1 debug: 4.4.3 escape-string-regexp: 4.0.0 - eslint: 9.39.3 + eslint: 9.39.5 espree: 10.4.0 esquery: 1.7.0 parse-imports-exports: 0.2.4 @@ -697,15 +701,15 @@ snapshots: eslint-visitor-keys@4.2.1: {} - eslint@9.39.3: + eslint@9.39.5: dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.3) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5) '@eslint-community/regexpp': 4.12.2 - '@eslint/config-array': 0.21.1 + '@eslint/config-array': 0.21.2 '@eslint/config-helpers': 0.4.2 '@eslint/core': 0.17.0 - '@eslint/eslintrc': 3.3.4 - '@eslint/js': 9.39.3 + '@eslint/eslintrc': 3.3.6 + '@eslint/js': 9.39.5 '@eslint/plugin-kit': 0.4.1 '@humanfs/node': 0.16.7 '@humanwhocodes/module-importer': 1.0.1 @@ -809,7 +813,7 @@ snapshots: isexe@2.0.0: {} - js-yaml@4.1.1: + js-yaml@4.3.0: dependencies: argparse: 2.0.1 @@ -854,6 +858,8 @@ snapshots: node-addon-api@8.6.0: {} + node-addon-api@8.9.0: {} + node-gyp-build@4.8.4: {} npm-run-path@3.1.0: diff --git a/src/parser.c b/src/parser.c index d817bff..7371595 100644 --- a/src/parser.c +++ b/src/parser.c @@ -3504,7 +3504,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { case 371: ACCEPT_TOKEN(anon_sym_SLASH_SLASH); if (lookahead != 0 && - lookahead != '\n') ADVANCE(375); + lookahead != '\n' && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(375); END_STATE(); case 372: ACCEPT_TOKEN(anon_sym_SLASH_SLASH2); @@ -3514,7 +3516,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '*') ADVANCE(382); if (lookahead == '/') ADVANCE(371); if (lookahead != 0 && - lookahead != '\n') ADVANCE(375); + lookahead != '\n' && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(375); END_STATE(); case 374: ACCEPT_TOKEN(aux_sym_line_comment_token1); @@ -3523,12 +3527,16 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { (0x0b <= lookahead && lookahead <= '\r') || lookahead == ' ') ADVANCE(374); if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead)) ADVANCE(375); + (lookahead < '\t' || '\r' < lookahead) && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(375); END_STATE(); case 375: ACCEPT_TOKEN(aux_sym_line_comment_token1); if (lookahead != 0 && - lookahead != '\n') ADVANCE(375); + lookahead != '\n' && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(375); END_STATE(); case 376: ACCEPT_TOKEN(anon_sym_SLASH2); @@ -3539,7 +3547,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '*') ADVANCE(380); if (lookahead == '/') ADVANCE(380); if (lookahead != 0 && - lookahead != '\n') ADVANCE(380); + lookahead != '\n' && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(380); END_STATE(); case 378: ACCEPT_TOKEN(aux_sym_line_comment_token2); @@ -3548,7 +3558,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { (0x0b <= lookahead && lookahead <= '\r') || lookahead == ' ') ADVANCE(379); if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead)) ADVANCE(380); + (lookahead < '\t' || '\r' < lookahead) && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(380); END_STATE(); case 379: ACCEPT_TOKEN(aux_sym_line_comment_token2); @@ -3557,12 +3569,16 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { (0x0b <= lookahead && lookahead <= '\r') || lookahead == ' ') ADVANCE(379); if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead)) ADVANCE(380); + (lookahead < '\t' || '\r' < lookahead) && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(380); END_STATE(); case 380: ACCEPT_TOKEN(aux_sym_line_comment_token2); if (lookahead != 0 && - lookahead != '\n') ADVANCE(380); + lookahead != '\n' && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(380); END_STATE(); case 381: ACCEPT_TOKEN(anon_sym_SLASH_STAR); @@ -3570,7 +3586,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { case 382: ACCEPT_TOKEN(anon_sym_SLASH_STAR); if (lookahead != 0 && - lookahead != '\n') ADVANCE(375); + lookahead != '\n' && + lookahead != 0x17f && + lookahead != 0x212a) ADVANCE(375); END_STATE(); case 383: ACCEPT_TOKEN(anon_sym_STAR_SLASH); diff --git a/src/tree_sitter/array.h b/src/tree_sitter/array.h index 56fc8cd..eba3da4 100644 --- a/src/tree_sitter/array.h +++ b/src/tree_sitter/array.h @@ -50,12 +50,18 @@ extern "C" { /// memory allocated for the array's contents. #define array_clear(self) ((self)->size = 0) +#ifdef __cplusplus +#define _array__cast(self, expr) (decltype((self)->contents))(expr) +#else +#define _array__cast(self, expr) (expr) +#endif + /// 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) \ - ((self)->contents = _array__reserve( \ - (void *)(self)->contents, &(self)->capacity, \ - array_elem_size(self), new_capacity) \ +#define array_reserve(self, new_capacity) \ + ((self)->contents = _array__cast(self, _array__reserve( \ + (void *)(self)->contents, &(self)->capacity, \ + array_elem_size(self), new_capacity)) \ ) /// Free any memory allocated for this array. Note that this does not free any @@ -71,10 +77,10 @@ extern "C" { /// Push a new `element` onto the end of the array. #define array_push(self, element) \ do { \ - (self)->contents = _array__grow( \ + (self)->contents = _array__cast(self, _array__grow( \ (void *)(self)->contents, (self)->size, &(self)->capacity, \ 1, array_elem_size(self) \ - ); \ + )); \ (self)->contents[(self)->size++] = (element); \ } while(0) @@ -83,10 +89,10 @@ extern "C" { #define array_grow_by(self, count) \ do { \ if ((count) == 0) break; \ - (self)->contents = _array__grow( \ + (self)->contents = _array__cast(self, _array__grow( \ (self)->contents, (self)->size, &(self)->capacity, \ count, array_elem_size(self) \ - ); \ + )); \ memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \ (self)->size += (count); \ } while (0) @@ -98,26 +104,26 @@ extern "C" { /// Append `count` elements to the end of the array, reading their values from the /// `contents` pointer. #define array_extend(self, count, other_contents) \ - (self)->contents = _array__splice( \ + ((self)->contents = _array__cast(self, _array__splice( \ (void*)(self)->contents, &(self)->size, &(self)->capacity, \ array_elem_size(self), (self)->size, 0, count, other_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) \ - (self)->contents = _array__splice( \ + ((self)->contents = _array__cast(self, _array__splice( \ (void *)(self)->contents, &(self)->size, &(self)->capacity, \ 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) \ - (self)->contents = _array__splice( \ + ((self)->contents = _array__cast(self, _array__splice( \ (void *)(self)->contents, &(self)->size, &(self)->capacity, \ array_elem_size(self), _index, 0, 1, &(element) \ - ) + ))) /// Remove one element from the array at the given `index`. #define array_erase(self, _index) \ @@ -128,17 +134,17 @@ extern "C" { /// Assign the contents of one array to another, reallocating if necessary. #define array_assign(self, other) \ - (self)->contents = _array__assign( \ + ((self)->contents = _array__cast(self, _array__assign( \ (void *)(self)->contents, &(self)->size, &(self)->capacity, \ (const void *)(other)->contents, (other)->size, array_elem_size(self) \ - ) + ))) /// Swap one array with another #define array_swap(self, other) \ do { \ void *_array_swap_tmp = (void *)(self)->contents; \ (self)->contents = (other)->contents; \ - (other)->contents = _array_swap_tmp; \ + (other)->contents = _array__cast(other, _array_swap_tmp); \ _array__swap(&(self)->size, &(self)->capacity, \ &(other)->size, &(other)->capacity); \ } while (0)