Mercurial > vim
annotate runtime/syntax/wast.vim @ 33080:51b4577d57bf
Added tag v9.0.1826 for changeset 5f201b734cb7b114a411a339a895d25ebecf7262
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 30 Aug 2023 19:45:05 +0200 |
parents | 2023f0835f75 |
children |
rev | line source |
---|---|
14432 | 1 " Vim syntax file |
2 " Language: WebAssembly | |
3 " Maintainer: rhysd <lin90162@yahoo.co.jp> | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
4 " Last Change: Aug 7, 2023 |
14432 | 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 | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
14 syn cluster wastNotTop contains=wastModule,wastInstWithType,wastInstGetSet,wastInstGeneral,wastParamInst,wastControlInst,wastSimdInst,wastString,wastNamedVar,wastUnnamedVar,wastFloat,wastNumber,wastComment,wastList,wastType |
14432 | 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 wastInstWithType "\%((\s*\)\@<=\<\%(i32\|i64\|f32\|f64\|memory\)\.[[:alnum:]_]\+\%(/\%(i32\|i64\|f32\|f64\)\)\=\>\%(\s\+\%(align\|offset\)=\)\=" contained display | |
20 syn match wastInstGeneral "\%((\s*\)\@<=\<[[:alnum:]_]\+\>" contained display | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
21 syn match wastInstGetSet "\%((\s*\)\@<=\<\%(local\|global\)\.\%(get\|set\)\>" contained display |
14432 | 22 " https://webassembly.github.io/spec/core/text/instructions.html#control-instructions |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
23 syn match wastControlInst "\%((\s*\)\@<=\<\%(block\|end\|loop\|if\|then\|else\|unreachable\|nop\|br\|br_if\|br_table\|return\|call\|call_indirect\)\>" contained display |
14432 | 24 " https://webassembly.github.io/spec/core/text/instructions.html#parametric-instructions |
25 syn match wastParamInst "\%((\s*\)\@<=\<\%(drop\|select\)\>" contained display | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
26 " SIMD instructions |
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
27 " https://webassembly.github.io/simd/core/text/instructions.html#simd-instructions |
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
28 syn match wastSimdInst "\<\%(v128\|i8x16\|i16x8\|i32x4\|i64x2\|f32x4\|f64x2)\)\.[[:alnum:]_]\+\%(\s\+\%(i8x16\|i16x8\|i32x4\|i64x2\|f32x4\|f64x2\)\)\=\>" contained display |
14432 | 29 |
30 " Identifiers | |
31 " https://webassembly.github.io/spec/core/text/values.html#text-id | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
32 syn match wastNamedVar "$\+[[:alnum:]!#$%&'∗./:=><?@\\^_`~+-]*" contained contains=wastEscapeUtf8 |
14432 | 33 syn match wastUnnamedVar "$\+\d\+[[:alnum:]!#$%&'∗./:=><?@\\^_`~+-]\@!" contained display |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
34 " Presuming the source text is itself encoded correctly, strings that do not |
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
35 " contain any uses of hexadecimal byte escapes are always valid names. |
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
36 " https://webassembly.github.io/spec/core/text/values.html#names |
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
37 syn match wastEscapedUtf8 "\\\x\{1,6}" contained containedin=wastNamedVar display |
14432 | 38 |
39 " String literals | |
40 " https://webassembly.github.io/spec/core/text/values.html#strings | |
41 syn region wastString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=wastStringSpecial | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
42 syn match wastStringSpecial "\\\x\x\|\\[tnr'\\\"]\|\\u\x\+" contained containedin=wastString display |
14432 | 43 |
44 " Float literals | |
45 " https://webassembly.github.io/spec/core/text/values.html#floating-point | |
46 syn match wastFloat "\<-\=\d\%(_\=\d\)*\%(\.\d\%(_\=\d\)*\)\=\%([eE][-+]\=\d\%(_\=\d\)*\)\=" display contained | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
47 syn match wastFloat "\<-\=0x\x\%(_\=\x\)*\%(\.\x\%(_\=\x\)*\)\=\%([pP][-+]\=\d\%(_\=\d\)*\)\=" display contained |
14432 | 48 syn keyword wastFloat inf nan contained |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
49 syn match wastFloat "nan:0x\x\%(_\=\x\)*" display contained |
14432 | 50 |
51 " Integer literals | |
52 " https://webassembly.github.io/spec/core/text/values.html#integers | |
53 syn match wastNumber "\<-\=\d\%(_\=\d\)*\>" display contained | |
54 syn match wastNumber "\<-\=0x\x\%(_\=\x\)*\>" display contained | |
55 | |
56 " Comments | |
57 " https://webassembly.github.io/spec/core/text/lexical.html#comments | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
58 syn region wastComment start=";;" end="$" |
14432 | 59 syn region wastComment start="(;;\@!" end=";)" |
60 | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
61 syn region wastList matchgroup=wastListDelimiter start="(;\@!" matchgroup=wastListDelimiter end=";\@<!)" contains=@wastNotTop |
14432 | 62 |
63 " Types | |
64 " https://webassembly.github.io/spec/core/text/types.html | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
65 " Note: `mut` was changed to `const`/`var` at Wasm 2.0 |
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
66 syn keyword wastType i64 i32 f64 f32 param result funcref func externref extern mut v128 const var contained |
14432 | 67 syn match wastType "\%((\_s*\)\@<=func\%(\_s*[()]\)\@=" display contained |
68 | |
69 " Modules | |
70 " https://webassembly.github.io/spec/core/text/modules.html | |
71 syn keyword wastModule module type export import table memory global data elem contained | |
72 syn match wastModule "\%((\_s*\)\@<=func\%(\_s\+\$\)\@=" display contained | |
73 | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
74 syn sync maxlines=100 |
14432 | 75 |
76 hi def link wastModule PreProc | |
77 hi def link wastListDelimiter Delimiter | |
78 hi def link wastInstWithType Operator | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
79 hi def link wastInstGetSet Operator |
14432 | 80 hi def link wastInstGeneral Operator |
81 hi def link wastControlInst Statement | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
82 hi def link wastSimdInst Operator |
14432 | 83 hi def link wastParamInst Conditional |
84 hi def link wastString String | |
85 hi def link wastStringSpecial Special | |
86 hi def link wastNamedVar Identifier | |
87 hi def link wastUnnamedVar PreProc | |
88 hi def link wastFloat Float | |
89 hi def link wastNumber Number | |
90 hi def link wastComment Comment | |
91 hi def link wastType Type | |
32699
2023f0835f75
update .wast files syntax highlighting (#12741)
Christian Brabandt <cb@256bit.org>
parents:
14432
diff
changeset
|
92 hi def link wastEscapedUtf8 Special |
14432 | 93 |
94 let b:current_syntax = "wast" | |
95 | |
96 let &cpo = s:cpo_save | |
97 unlet s:cpo_save |