1*d2855f54SBram Moolenaar" Vim syntax file 2*d2855f54SBram Moolenaar" Language: WebAssembly 3*d2855f54SBram Moolenaar" Maintainer: rhysd <[email protected]> 4*d2855f54SBram Moolenaar" Last Change: Jul 29, 2018 5*d2855f54SBram Moolenaar" For bugs, patches and license go to https://github.com/rhysd/vim-wasm 6*d2855f54SBram Moolenaar 7*d2855f54SBram Moolenaarif exists("b:current_syntax") 8*d2855f54SBram Moolenaar finish 9*d2855f54SBram Moolenaarendif 10*d2855f54SBram Moolenaar 11*d2855f54SBram Moolenaarlet s:cpo_save = &cpo 12*d2855f54SBram Moolenaarset cpo&vim 13*d2855f54SBram Moolenaar 14*d2855f54SBram Moolenaarsyn cluster wastCluster contains=wastModule,wastInstWithType,wastInstGeneral,wastParamInst,wastControlInst,wastString,wastNamedVar,wastUnnamedVar,wastFloat,wastNumber,wastComment,wastList,wastType 15*d2855f54SBram Moolenaar 16*d2855f54SBram Moolenaar" Instructions 17*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/instructions.html 18*d2855f54SBram Moolenaar" Note: memarg (align=,offset=) can be added to memory instructions 19*d2855f54SBram Moolenaarsyn match wastInstWithType "\%((\s*\)\@<=\<\%(i32\|i64\|f32\|f64\|memory\)\.[[:alnum:]_]\+\%(/\%(i32\|i64\|f32\|f64\)\)\=\>\%(\s\+\%(align\|offset\)=\)\=" contained display 20*d2855f54SBram Moolenaarsyn match wastInstGeneral "\%((\s*\)\@<=\<[[:alnum:]_]\+\>" contained display 21*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/instructions.html#control-instructions 22*d2855f54SBram Moolenaarsyn match wastControlInst "\%((\s*\)\@<=\<\%(block\|end\|loop\|if\|else\|unreachable\|nop\|br\|br_if\|br_table\|return\|call\|call_indirect\)\>" contained display 23*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/instructions.html#parametric-instructions 24*d2855f54SBram Moolenaarsyn match wastParamInst "\%((\s*\)\@<=\<\%(drop\|select\)\>" contained display 25*d2855f54SBram Moolenaar 26*d2855f54SBram Moolenaar" Identifiers 27*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/values.html#text-id 28*d2855f54SBram Moolenaarsyn match wastNamedVar "$\+[[:alnum:]!#$%&'∗./:=><?@\\^_`~+-]*" contained display 29*d2855f54SBram Moolenaarsyn match wastUnnamedVar "$\+\d\+[[:alnum:]!#$%&'∗./:=><?@\\^_`~+-]\@!" contained display 30*d2855f54SBram Moolenaar 31*d2855f54SBram Moolenaar" String literals 32*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/values.html#strings 33*d2855f54SBram Moolenaarsyn region wastString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=wastStringSpecial 34*d2855f54SBram Moolenaarsyn match wastStringSpecial "\\\x\x\|\\[tnr'\\\"]\|\\u\x\+" contained containedin=wastString 35*d2855f54SBram Moolenaar 36*d2855f54SBram Moolenaar" Float literals 37*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/values.html#floating-point 38*d2855f54SBram Moolenaarsyn match wastFloat "\<-\=\d\%(_\=\d\)*\%(\.\d\%(_\=\d\)*\)\=\%([eE][-+]\=\d\%(_\=\d\)*\)\=" display contained 39*d2855f54SBram Moolenaarsyn match wastFloat "\<-\=0x\x\%(_\=\d\)*\%(\.\x\%(_\=\x\)*\)\=\%([pP][-+]\=\d\%(_\=\d\)*\)\=" display contained 40*d2855f54SBram Moolenaarsyn keyword wastFloat inf nan contained 41*d2855f54SBram Moolenaar 42*d2855f54SBram Moolenaar" Integer literals 43*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/values.html#integers 44*d2855f54SBram Moolenaarsyn match wastNumber "\<-\=\d\%(_\=\d\)*\>" display contained 45*d2855f54SBram Moolenaarsyn match wastNumber "\<-\=0x\x\%(_\=\x\)*\>" display contained 46*d2855f54SBram Moolenaar 47*d2855f54SBram Moolenaar" Comments 48*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/lexical.html#comments 49*d2855f54SBram Moolenaarsyn region wastComment start=";;" end="$" display 50*d2855f54SBram Moolenaarsyn region wastComment start="(;;\@!" end=";)" 51*d2855f54SBram Moolenaar 52*d2855f54SBram Moolenaarsyn region wastList matchgroup=wastListDelimiter start="(;\@!" matchgroup=wastListDelimiter end=";\@<!)" contains=@wastCluster 53*d2855f54SBram Moolenaar 54*d2855f54SBram Moolenaar" Types 55*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/types.html 56*d2855f54SBram Moolenaarsyn keyword wastType i64 i32 f64 f32 param result anyfunc mut contained 57*d2855f54SBram Moolenaarsyn match wastType "\%((\_s*\)\@<=func\%(\_s*[()]\)\@=" display contained 58*d2855f54SBram Moolenaar 59*d2855f54SBram Moolenaar" Modules 60*d2855f54SBram Moolenaar" https://webassembly.github.io/spec/core/text/modules.html 61*d2855f54SBram Moolenaarsyn keyword wastModule module type export import table memory global data elem contained 62*d2855f54SBram Moolenaarsyn match wastModule "\%((\_s*\)\@<=func\%(\_s\+\$\)\@=" display contained 63*d2855f54SBram Moolenaar 64*d2855f54SBram Moolenaarsyn sync lines=100 65*d2855f54SBram Moolenaar 66*d2855f54SBram Moolenaarhi def link wastModule PreProc 67*d2855f54SBram Moolenaarhi def link wastListDelimiter Delimiter 68*d2855f54SBram Moolenaarhi def link wastInstWithType Operator 69*d2855f54SBram Moolenaarhi def link wastInstGeneral Operator 70*d2855f54SBram Moolenaarhi def link wastControlInst Statement 71*d2855f54SBram Moolenaarhi def link wastParamInst Conditional 72*d2855f54SBram Moolenaarhi def link wastString String 73*d2855f54SBram Moolenaarhi def link wastStringSpecial Special 74*d2855f54SBram Moolenaarhi def link wastNamedVar Identifier 75*d2855f54SBram Moolenaarhi def link wastUnnamedVar PreProc 76*d2855f54SBram Moolenaarhi def link wastFloat Float 77*d2855f54SBram Moolenaarhi def link wastNumber Number 78*d2855f54SBram Moolenaarhi def link wastComment Comment 79*d2855f54SBram Moolenaarhi def link wastType Type 80*d2855f54SBram Moolenaar 81*d2855f54SBram Moolenaarlet b:current_syntax = "wast" 82*d2855f54SBram Moolenaar 83*d2855f54SBram Moolenaarlet &cpo = s:cpo_save 84*d2855f54SBram Moolenaarunlet s:cpo_save 85