Skip to content

Commit 0d8ce07

Browse files
ayosecda-x
authored andcommitted
Syntax for asm! macro (RFC 2850)
1 parent 953b100 commit 0d8ce07

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

syntax/rust.vim

+25
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,27 @@ syn region rustCommentBlockDocNestError matchgroup=rustCommentBlockDocError star
230230

231231
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
232232

233+
" asm! macro {{{2
234+
syn region rustAsmMacro matchgroup=rustMacro start="\<asm!\s*(" end=")" contains=rustAsmDirSpec,rustAsmSym,rustAsmConst,rustAsmOptionsGroup,rustComment.*,rustString.*
235+
236+
" Clobbered registers
237+
syn keyword rustAsmDirSpec in out lateout inout inlateout contained nextgroup=rustAsmReg skipwhite skipempty
238+
syn region rustAsmReg start="(" end=")" contained contains=rustString
239+
240+
" Symbol operands
241+
syn keyword rustAsmSym sym contained nextgroup=rustAsmSymPath skipwhite skipempty
242+
syn region rustAsmSymPath start="\S" end=",\|)"me=s-1 contained contains=rustComment.*,rustIdentifier
243+
244+
" Const
245+
syn region rustAsmConstBalancedParens start="("ms=s+1 end=")" contained contains=@rustAsmConstExpr
246+
syn cluster rustAsmConstExpr contains=rustComment.*,rust.*Number,rustString,rustAsmConstBalancedParens
247+
syn region rustAsmConst start="const" end=",\|)"me=s-1 contained contains=rustStorage,@rustAsmConstExpr
248+
249+
" Options
250+
syn region rustAsmOptionsGroup start="options\s*(" end=")" contained contains=rustAsmOptions,rustAsmOptionsKey
251+
syn keyword rustAsmOptionsKey options contained
252+
syn keyword rustAsmOptions pure nomem readonly preserves_flags noreturn nostack att_syntax contained
253+
233254
" Folding rules {{{2
234255
" Trivial folding rules to begin with.
235256
" FIXME: use the AST to make really good folding
@@ -345,6 +366,10 @@ hi def link rustObsoleteExternMod Error
345366
hi def link rustQuestionMark Special
346367
hi def link rustAsync rustKeyword
347368
hi def link rustAwait rustKeyword
369+
hi def link rustAsmDirSpec rustKeyword
370+
hi def link rustAsmSym rustKeyword
371+
hi def link rustAsmOptions rustKeyword
372+
hi def link rustAsmOptionsKey rustAttribute
348373

349374
" Other Suggestions:
350375
" hi rustAttribute ctermfg=cyan

0 commit comments

Comments
 (0)