comparison runtime/syntax/wat.vim @ 33767:4913b4f5a133 v9.0.2104

patch 9.0.2104: wast filetype should be replaced by wat filetype Commit: https://github.com/vim/vim/commit/bc8f79d36a456054ed29f46585830af6d71f57c8 Author: rhysd <lin90162@yahoo.co.jp> Date: Tue Nov 14 16:46:07 2023 +0100 patch 9.0.2104: wast filetype should be replaced by wat filetype Problem: wast filetype should be replaced by wat filetype Solution: start using the official wat filetype name runtime: rename `wast` filetype to `wat` (Wasm text format) The problem is the name of the current filetype wast. When the plugin was initially created, the file extension for Wasm text format was not fixed and .wast was more popular. However, recently .wat became the official file extension for WebAssembly text (WAT) format and .wast is now a file extension for the unofficial WAST format, which is a superset of .wat for the convenience to describe the Wasm specification conformance tests. https://webassembly.js.org/docs/contrib-wat-vs-wast.html However for now, let's keep using the `wat` filetype even for the .wast extension, so that we at least do not lose the filetype settings and syntax highlighting. This can be adjusted later, if it turns out to have a separate need for. closes: #13533 Signed-off-by: rhysd <lin90162@yahoo.co.jp> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 14 Nov 2023 17:15:03 +0100
parents
children
comparison
equal deleted inserted replaced
33766:fc557aa379ef 33767:4913b4f5a133
1 " Vim syntax file
2 " Language: WebAssembly
3 " Maintainer: rhysd <lin90162@yahoo.co.jp>
4 " Last Change: Nov 14, 2023
5 " For bugs, patches and license go to https://github.com/rhysd/vim-wasm
6
7 if exists("b:current_syntax")
8 finish
9 endif
10
11 let s:cpo_save = &cpo
12 set cpo&vim
13
14 syn cluster watNotTop contains=watModule,watInstWithType,watInstGetSet,watInstGeneral,watParamInst,watControlInst,watSimdInst,watString,watNamedVar,watUnnamedVar,watFloat,watNumber,watComment,watList,watType
15
16 " Instructions
17 " https://webassembly.github.io/spec/core/text/instructions.html
18 " Note: memarg (align=,offset=) can be added to memory instructions
19 syn match watInstWithType "\%((\s*\)\@<=\<\%(i32\|i64\|f32\|f64\|memory\)\.[[:alnum:]_]\+\%(/\%(i32\|i64\|f32\|f64\)\)\=\>\%(\s\+\%(align\|offset\)=\)\=" contained display
20 syn match watInstGeneral "\%((\s*\)\@<=\<[[:alnum:]_]\+\>" contained display
21 syn match watInstGetSet "\%((\s*\)\@<=\<\%(local\|global\)\.\%(get\|set\)\>" contained display
22 " https://webassembly.github.io/spec/core/text/instructions.html#control-instructions
23 syn match watControlInst "\%((\s*\)\@<=\<\%(block\|end\|loop\|if\|then\|else\|unreachable\|nop\|br\|br_if\|br_table\|return\|call\|call_indirect\)\>" contained display
24 " https://webassembly.github.io/spec/core/text/instructions.html#parametric-instructions
25 syn match watParamInst "\%((\s*\)\@<=\<\%(drop\|select\)\>" contained display
26 " SIMD instructions
27 " https://webassembly.github.io/simd/core/text/instructions.html#simd-instructions
28 syn match watSimdInst "\<\%(v128\|i8x16\|i16x8\|i32x4\|i64x2\|f32x4\|f64x2)\)\.[[:alnum:]_]\+\%(\s\+\%(i8x16\|i16x8\|i32x4\|i64x2\|f32x4\|f64x2\)\)\=\>" contained display
29
30 " Identifiers
31 " https://webassembly.github.io/spec/core/text/values.html#text-id
32 syn match watNamedVar "$\+[[:alnum:]!#$%&'∗./:=><?@\\^_`~+-]*" contained contains=watEscapeUtf8
33 syn match watUnnamedVar "$\+\d\+[[:alnum:]!#$%&'∗./:=><?@\\^_`~+-]\@!" contained display
34 " Presuming the source text is itself encoded correctly, strings that do not
35 " contain any uses of hexadecimal byte escapes are always valid names.
36 " https://webassembly.github.io/spec/core/text/values.html#names
37 syn match watEscapedUtf8 "\\\x\{1,6}" contained containedin=watNamedVar display
38
39 " String literals
40 " https://webassembly.github.io/spec/core/text/values.html#strings
41 syn region watString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=watStringSpecial
42 syn match watStringSpecial "\\\x\x\|\\[tnr'\\\"]\|\\u\x\+" contained containedin=watString display
43
44 " Float literals
45 " https://webassembly.github.io/spec/core/text/values.html#floating-point
46 syn match watFloat "\<-\=\d\%(_\=\d\)*\%(\.\d\%(_\=\d\)*\)\=\%([eE][-+]\=\d\%(_\=\d\)*\)\=" display contained
47 syn match watFloat "\<-\=0x\x\%(_\=\x\)*\%(\.\x\%(_\=\x\)*\)\=\%([pP][-+]\=\d\%(_\=\d\)*\)\=" display contained
48 syn keyword watFloat inf nan contained
49 syn match watFloat "nan:0x\x\%(_\=\x\)*" display contained
50
51 " Integer literals
52 " https://webassembly.github.io/spec/core/text/values.html#integers
53 syn match watNumber "\<-\=\d\%(_\=\d\)*\>" display contained
54 syn match watNumber "\<-\=0x\x\%(_\=\x\)*\>" display contained
55
56 " Comments
57 " https://webassembly.github.io/spec/core/text/lexical.html#comments
58 syn region watComment start=";;" end="$"
59 syn region watComment start="(;;\@!" end=";)"
60
61 syn region watList matchgroup=watListDelimiter start="(;\@!" matchgroup=watListDelimiter end=";\@<!)" contains=@watNotTop
62
63 " Types
64 " https://webassembly.github.io/spec/core/text/types.html
65 " Note: `mut` was changed to `const`/`var` at Wasm 2.0
66 syn keyword watType i64 i32 f64 f32 param result funcref func externref extern mut v128 const var contained
67 syn match watType "\%((\_s*\)\@<=func\%(\_s*[()]\)\@=" display contained
68
69 " Modules
70 " https://webassembly.github.io/spec/core/text/modules.html
71 syn keyword watModule module type export import table memory global data elem contained
72 syn match watModule "\%((\_s*\)\@<=func\%(\_s\+\$\)\@=" display contained
73
74 syn sync maxlines=100
75
76 hi def link watModule PreProc
77 hi def link watListDelimiter Delimiter
78 hi def link watInstWithType Operator
79 hi def link watInstGetSet Operator
80 hi def link watInstGeneral Operator
81 hi def link watControlInst Statement
82 hi def link watSimdInst Operator
83 hi def link watParamInst Conditional
84 hi def link watString String
85 hi def link watStringSpecial Special
86 hi def link watNamedVar Identifier
87 hi def link watUnnamedVar PreProc
88 hi def link watFloat Float
89 hi def link watNumber Number
90 hi def link watComment Comment
91 hi def link watType Type
92 hi def link watEscapedUtf8 Special
93
94 let b:current_syntax = "wat"
95
96 let &cpo = s:cpo_save
97 unlet s:cpo_save