From 3a88003062c93095e90bb6c51ac7e04f8e00cff6 Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Mon, 12 Sep 2022 19:56:06 +0200 Subject: [PATCH 1/3] add support for webassembly text format --- book/src/generated/lang-support.md | 1 + languages.toml | 11 +++++++++++ runtime/queries/wat/highlights.scm | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 runtime/queries/wat/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 86c26042d110..1b85570c1c0e 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -119,6 +119,7 @@ | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | | vue | ✓ | | | `vls` | +| wat | ✓ | | | | | wgsl | ✓ | | | `wgsl_analyzer` | | xit | ✓ | | | | | yaml | ✓ | | ✓ | `yaml-language-server` | diff --git a/languages.toml b/languages.toml index a7b8f93d4ad0..045802b13364 100644 --- a/languages.toml +++ b/languages.toml @@ -1781,3 +1781,14 @@ language-server = { command = "bass", args = ["--lsp"] } [[grammar]] name = "bass" source = { git = "https://github.com/vito/tree-sitter-bass", rev = "501133e260d768ed4e1fd7374912ed5c86d6fd90" } + +[[language]] +name = "wat" +scope = "source.webassembly" +comment-token = ";;" +file-types = ["wast", "wat"] +roots = [] + +[[grammar]] +name = "wat" +source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f9d709847bf7a3de0942a84e912f59088", subpath = "wat" } diff --git a/runtime/queries/wat/highlights.scm b/runtime/queries/wat/highlights.scm new file mode 100644 index 000000000000..c9ca1e07328f --- /dev/null +++ b/runtime/queries/wat/highlights.scm @@ -0,0 +1,15 @@ +["module" "func" "param" "result" "type" "memory" "elem" "data" "table" "global"] @keyword + +["import" "export"] @keyword.control.import + +["local"] @keyword.storage.type + +[(name) (string)] @string + +(identifier) @function + +[(comment_block) (comment_line)] @comment + +[(nat) (align_offset_value)] @constant.numeric.integer + +(value_type) @type From 7091a07afcabff85c6997b28962c04ae0366e1ca Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Fri, 30 Sep 2022 15:00:41 +0200 Subject: [PATCH 2/3] split grammars for wat and wast --- languages.toml | 13 ++++++++++++- runtime/queries/wast/highlights.scm | 21 +++++++++++++++++++++ runtime/queries/wat/highlights.scm | 4 +++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 runtime/queries/wast/highlights.scm diff --git a/languages.toml b/languages.toml index 045802b13364..c6d565f15541 100644 --- a/languages.toml +++ b/languages.toml @@ -1786,9 +1786,20 @@ source = { git = "https://github.com/vito/tree-sitter-bass", rev = "501133e260d7 name = "wat" scope = "source.webassembly" comment-token = ";;" -file-types = ["wast", "wat"] +file-types = ["wat"] roots = [] [[grammar]] name = "wat" source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f9d709847bf7a3de0942a84e912f59088", subpath = "wat" } + +[[language]] +name = "wast" +scope = "source.webassembly" +comment-token = ";;" +file-types = ["wast"] +roots = [] + +[[grammar]] +name = "wast" +source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f9d709847bf7a3de0942a84e912f59088", subpath = "wast" } diff --git a/runtime/queries/wast/highlights.scm b/runtime/queries/wast/highlights.scm new file mode 100644 index 000000000000..ef5b547ec451 --- /dev/null +++ b/runtime/queries/wast/highlights.scm @@ -0,0 +1,21 @@ +; inherits: wat + +[ + "assert_return" + "assert_trap" + "assert_exhaustion" + "assert_malformed" + "assert_invalid" + "assert_unlinkable" + "assert_trap" + + "invoke" + "get" + + "script" + "input" + "output" + + "binary" + "quote" +] @keyword diff --git a/runtime/queries/wat/highlights.scm b/runtime/queries/wat/highlights.scm index c9ca1e07328f..007e3bbff8e0 100644 --- a/runtime/queries/wat/highlights.scm +++ b/runtime/queries/wat/highlights.scm @@ -10,6 +10,8 @@ [(comment_block) (comment_line)] @comment -[(nat) (align_offset_value)] @constant.numeric.integer +[(nat) (float) (align_offset_value)] @constant.numeric.integer (value_type) @type + +["(" ")"] @punctuation.bracket From 604bca1fd76c596dd190c8cb6f650475981028b6 Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Sat, 1 Oct 2022 13:36:58 +0200 Subject: [PATCH 3/3] code review --- book/src/generated/lang-support.md | 1 + languages.toml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 1b85570c1c0e..5c64d0977abe 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -119,6 +119,7 @@ | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | | vue | ✓ | | | `vls` | +| wast | ✓ | | | | | wat | ✓ | | | | | wgsl | ✓ | | | `wgsl_analyzer` | | xit | ✓ | | | | diff --git a/languages.toml b/languages.toml index c6d565f15541..7d50160fe44d 100644 --- a/languages.toml +++ b/languages.toml @@ -1784,7 +1784,7 @@ source = { git = "https://github.com/vito/tree-sitter-bass", rev = "501133e260d7 [[language]] name = "wat" -scope = "source.webassembly" +scope = "source.wat" comment-token = ";;" file-types = ["wat"] roots = [] @@ -1795,7 +1795,7 @@ source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f [[language]] name = "wast" -scope = "source.webassembly" +scope = "source.wast" comment-token = ";;" file-types = ["wast"] roots = []