Fix NasmLexer to support syntax like <sprintf@plt>

Create issue
Issue #1527 new
Andrea Cardaci created an issue

I'm not sure whether this is a bug or not, if the lexer is for Nasm code then I guess the <...> part is not strictly part of the syntax, it's more something used by disassemblers and should IMHO be treated as a comment. FWIW the Gas lexer does not have this problem. What do you think?

Anyway this snippet reproduces the problem:

import pygments
import pygments.formatters
import pygments.lexers

lexer = pygments.lexers.NasmLexer()
formatter = pygments.formatters.TestcaseFormatter()
source = 'callq  0x5555555545f0 <sprintf@plt>'

print(pygments.highlight(source, lexer, formatter))

as it yields:

Token.Name.Function     u'callq'
Token.Text      u'  '
Token.Literal.Number.Hex        u'0x5555555545f0'
Token.Text      u' '
Token.Operator  u'<'
Token.Name.Builtin      u'sp'
Token.Name.Variable     u'rintf@plt'
Token.Operator  u'>'
Token.Text      u'\n'

As you can see the sp part of sprintf is treated as a register.

Comments (0)

  1. Log in to comment