Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve NASM lexer #2212

Merged
merged 1 commit into from Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions pygments/lexers/asm.py
Expand Up @@ -730,8 +730,9 @@ class NasmLexer(RegexLexer):
declkw = r'(?:res|d)[bwdqt]|times'
register = (r'(r[0-9][0-5]?[bwd]?|'
r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|'
r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7])\b')
wordop = r'seg|wrt|strict'
r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]|k[0-7]|'
r'[xyz]mm(?:[12][0-9]?|3[01]?|[04-9]))\b')
wordop = r'seg|wrt|strict|rel|abs'
type = r'byte|[dq]?word'
# Directives must be followed by whitespace, otherwise CPU will match
# cpuid for instance.
Expand Down Expand Up @@ -778,7 +779,7 @@ class NasmLexer(RegexLexer):
(r'#.*', Comment.Single)
],
'punctuation': [
(r'[,():\[\]]+', Punctuation),
(r'[,{}():\[\]]+', Punctuation),
(r'[&|^<>+*/%~-]+', Operator),
(r'[$]+', Keyword.Constant),
(wordop, Operator.Word),
Expand Down
13 changes: 13 additions & 0 deletions tests/examplefiles/nasm/nasm_simd.asm
@@ -0,0 +1,13 @@
; test source for SIMD operations
; not intended to be executable
bits 64

kmovq k1, [rel mask]
vpxor xmm0, xmm0, xmm0
vmovdqa32 zmm30, [abs data]
vpaddd zmm0{k1}, zmm0, zmm30
vpxor xmm1, xmm1, [rel xmm01]

mask dq 0xAAAAAAAA55555555
data: times 16 dd 0x12345678
xmm01: times 4 dd 0
102 changes: 102 additions & 0 deletions tests/examplefiles/nasm/nasm_simd.asm.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.