From cf914834c1dd06d5039c42fdceddcb2b5fa61cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Mon, 7 Mar 2022 20:48:55 +0100 Subject: [PATCH 1/5] Add more preprocessor macros Also expand bsf to include bsfl, bsfq etc. --- syntax/gas.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/gas.vim b/syntax/gas.vim index ae49eeb..949fce6 100644 --- a/syntax/gas.vim +++ b/syntax/gas.vim @@ -512,7 +512,7 @@ syn keyword gasOpcode_286_Base arpl syn keyword gasOpcode_PENT_Base bb0_reset syn keyword gasOpcode_PENT_Base bb1_reset syn keyword gasOpcode_386_Base bound boundb boundw boundl boundq -syn keyword gasOpcode_X64_Base bsf +syn keyword gasOpcode_X64_Base bsf bsfb bsfw bsfl bsfq syn keyword gasOpcode_X64_Base bsr syn keyword gasOpcode_X64_Base bswap syn keyword gasOpcode_X64_Base bt btb btw btl btq @@ -2056,7 +2056,7 @@ if !exists('g:gasDisablePreproc') && !exists('b:gasDisablePreproc') syn include @cPP syntax/c.vim syn match cPPLineCont "\\$" contained - syn region cPPPreProc start=/^\s*#\s*\(if\|else\|endif\|define\|include\)/ end=/$/ contains=@cPP,cPPLineCont + syn region cPPPreProc start=/^\s*#\s*\(if\|else\|endif\|ifdef\|ifndef\|define\|undef\|include\)/ end=/$/ contains=@cPP,cPPLineCont endif " finishing touches From f8f5e0979fa1aac17302d3d4f86814e8b385c297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Mon, 7 Mar 2022 23:03:18 +0100 Subject: [PATCH 2/5] Change to non-capturing groups --- syntax/gas.vim | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/syntax/gas.vim b/syntax/gas.vim index 949fce6..ecd93c2 100644 --- a/syntax/gas.vim +++ b/syntax/gas.vim @@ -27,7 +27,7 @@ syn match gasSpecial /\<[$.]\>/ " constants syn region gasString start=/"/ end=/"/ skip=/\\"/ -syn match gasCharacter /'\(?\|\\?\)/ +syn match gasCharacter /'\%(?\|\\?\)/ syn match gasDecimalNumber /\$\?-\?\d\+/ syn match gasBinaryNumber /\$\?-\?0b[01]\+/ syn match gasOctalNumber /\$\?-\?0\d\+/ @@ -68,24 +68,24 @@ syn keyword gasRegisterX86 %rax %rbx %rcx %rdx %rdi %rsi %rsp %rbp syn keyword gasRegisterX86 %eax %ebx %ecx %edx %ax %bx %cx %dx %ah %al %bh %bl %ch %cl %dh %dl syn keyword gasRegisterX86 %edi %esi %esp %ebp %di %si %sp %bp %sph %spl %bph %bpl syn keyword gasRegisterX86 %cs %ds %es %fs %gs %ss %ip %eip %rip %eflags -syn match gasRegisterX86 /\<%r\([8-9]\|1[0-5]\)[lwd]\?\>/ +syn match gasRegisterX86 /\<%r\%([8-9]\|1[0-5]\)[lwd]\?\>/ " i*86 special registers syn match gasRegisterX86Cr /\<%cr[0-8]\>/ syn match gasRegisterX86Dr /\<%dr[0-8]\>/ syn match gasRegisterX86Tr /\<%tr[0-8]\>/ -syn match gasRegisterX86Fp /\<%sp\(([0-7])\)\?\>/ +syn match gasRegisterX86Fp /\<%sp\%(([0-7])\)\?\>/ syn match gasRegisterX86MMX /\<%x\?mm[0-7]\>/ -syn match gasRegisterAVX /\<%ymm\([0-9]\|1[0-5]\)\>/ -syn match gasRegisterAVX512 /\<%ymm\(1[6-9]\|2[0-9]\|3[0-1]\)\>/ -syn match gasRegisterAVX512 /\<%zmm\([0-9]\|[1-2][0-9]\|3[0-1]\)\>/ +syn match gasRegisterAVX /\<%ymm\%([0-9]\|1[0-5]\)\>/ +syn match gasRegisterAVX512 /\<%ymm\%(1[6-9]\|2[0-9]\|3[0-1]\)\>/ +syn match gasRegisterAVX512 /\<%zmm\%([0-9]\|[1-2][0-9]\|3[0-1]\)\>/ " local label needs to be matched *after* numerics syn match gasLocalLabel /\d\{1,2\}[:fb]/ " comments etc. syn match gasOperator /[+-/*=|&~<>]\|<=\|>=\|<>/ -syn match gasTODO /\<\(TODO\|FIXME\|NOTE\)\>/ contained +syn match gasTODO /\<\%(TODO\|FIXME\|NOTE\)\>/ contained syn region gasComment start=/\/\*/ end=/\*\// contains=gasTODO syn region gasCommentSingle start=/#/ end=/$/ contains=gasTODO syn region gasCommentSingle start=/@/ end=/$/ contains=gasTODO @@ -101,7 +101,7 @@ syn keyword gasDirectiveARM .arch .arch_expression .arm .asciiz .cantunwind .cod " ARM register set " Must be defined after gasSymbol to have higher precedence syn keyword gasRegisterARM sp lr pc -syn match gasRegisterARM /\<%\?r\([0-9]\|1[0-5]\)\>/ +syn match gasRegisterARM /\<%\?r\%([0-9]\|1[0-5]\)\>/ syn keyword gasDirectiveMacroARM .dn .dq .req .unreq .tlsdescseq @@ -902,8 +902,8 @@ syn keyword gasOpcode_8086_Base xlatb syn keyword gasOpcode_8086_Base xlat syn keyword gasOpcode_386_Base xor xorb xorw xorl xorq syn keyword gasOpcode_X64_Base cmovcc -syn match gasOpcode_8086_Base /\/ -syn match gasOpcode_386_Base /\/ +syn match gasOpcode_8086_Base /\/ +syn match gasOpcode_386_Base /\/ "-- Section: VIA (Centaur) security instructions syn keyword gasOpcode_PENT_Base xstore @@ -2056,7 +2056,7 @@ if !exists('g:gasDisablePreproc') && !exists('b:gasDisablePreproc') syn include @cPP syntax/c.vim syn match cPPLineCont "\\$" contained - syn region cPPPreProc start=/^\s*#\s*\(if\|else\|endif\|ifdef\|ifndef\|define\|undef\|include\)/ end=/$/ contains=@cPP,cPPLineCont + syn region cPPPreProc start=/^\s*#\s*\%(if\|else\|endif\|ifdef\|ifndef\|define\|undef\|include\)/ end=/$/ contains=@cPP,cPPLineCont endif " finishing touches From 0c8fce55e0d435b9ec27a2fae68242eac8ca2377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Mon, 7 Mar 2022 23:17:10 +0100 Subject: [PATCH 3/5] Correct cmovcc for x86-64 --- syntax/gas.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/gas.vim b/syntax/gas.vim index ecd93c2..a86e120 100644 --- a/syntax/gas.vim +++ b/syntax/gas.vim @@ -901,7 +901,7 @@ syn keyword gasOpcode_X64_Base xchg syn keyword gasOpcode_8086_Base xlatb syn keyword gasOpcode_8086_Base xlat syn keyword gasOpcode_386_Base xor xorb xorw xorl xorq -syn keyword gasOpcode_X64_Base cmovcc +syn match gasOpcode_X64_Base /\/ syn match gasOpcode_8086_Base /\/ syn match gasOpcode_386_Base /\/ From eca19d5cd428e6a09bc8b8225bd1693f710c73a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Mon, 7 Mar 2022 23:43:57 +0100 Subject: [PATCH 4/5] Change group gasTODO to gasTodo This is because how this is how it is usually stylized (see your local Vim syntax files). --- syntax/gas.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/syntax/gas.vim b/syntax/gas.vim index a86e120..82a5c68 100644 --- a/syntax/gas.vim +++ b/syntax/gas.vim @@ -85,12 +85,12 @@ syn match gasLocalLabel /\d\{1,2\}[:fb]/ " comments etc. syn match gasOperator /[+-/*=|&~<>]\|<=\|>=\|<>/ -syn match gasTODO /\<\%(TODO\|FIXME\|NOTE\)\>/ contained -syn region gasComment start=/\/\*/ end=/\*\// contains=gasTODO -syn region gasCommentSingle start=/#/ end=/$/ contains=gasTODO -syn region gasCommentSingle start=/@/ end=/$/ contains=gasTODO +syn match gasTodo /\<\%(TODO\|FIXME\|NOTE\)\>/ contained +syn region gasComment start=/\/\*/ end=/\*\// contains=gasTodo +syn region gasCommentSingle start=/#/ end=/$/ contains=gasTodo +syn region gasCommentSingle start=/@/ end=/$/ contains=gasTodo if exists('g:gasCppComments') - syn region gasCommentSingle start=/\/\// end=/$/ contains=gasTODO + syn region gasCommentSingle start=/\/\// end=/$/ contains=gasTodo endif " ARM specific directives @@ -1982,7 +1982,7 @@ hi def link gasSpecial Special hi def link gasLabel Function hi def link gasLocalLabel Label hi def link gasOperator Operator -hi def link gasTODO Todo +hi def link gasTodo Todo hi def link gasOpcode Keyword hi def link gasComment Comment hi def link gasCommentSingle Comment From e7628b2d0e7650765ef1ef8e28cecdbc65a52169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Mon, 7 Mar 2022 23:47:36 +0100 Subject: [PATCH 5/5] Add XXX to todo-group --- syntax/gas.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/gas.vim b/syntax/gas.vim index 82a5c68..829135e 100644 --- a/syntax/gas.vim +++ b/syntax/gas.vim @@ -85,7 +85,7 @@ syn match gasLocalLabel /\d\{1,2\}[:fb]/ " comments etc. syn match gasOperator /[+-/*=|&~<>]\|<=\|>=\|<>/ -syn match gasTodo /\<\%(TODO\|FIXME\|NOTE\)\>/ contained +syn match gasTodo /\<\%(TODO\|FIXME\|NOTE\|XXX\)\>/ contained syn region gasComment start=/\/\*/ end=/\*\// contains=gasTodo syn region gasCommentSingle start=/#/ end=/$/ contains=gasTodo syn region gasCommentSingle start=/@/ end=/$/ contains=gasTodo