Skip to content

Commit

Permalink
Support primitive directives in NASM lexer (#1974)
Browse files Browse the repository at this point in the history
  • Loading branch information
tancnle committed Jan 7, 2024
1 parent 0ba3ba9 commit fb9aae2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/rouge/lexers/nasm.rb
Expand Up @@ -14,11 +14,12 @@ class Nasm < RegexLexer
mimetypes 'text/x-nasm'

state :root do
rule %r/^\s*%/, Comment::Preproc, :preproc
rule %r/^\s*%/, Comment::Preproc, :preproc

mixin :whitespace
mixin :whitespace
mixin :punctuation

rule %r/[a-z$._?][\w$.?#@~]*:/i, Name::Label
rule %r/[a-z$._?][\w$.?#@~]*:/i, Name::Label

rule %r/([a-z$._?][\w$.?#@~]*)(\s+)(equ)/i do
groups Name::Constant, Keyword::Declaration, Keyword::Declaration
Expand All @@ -32,7 +33,7 @@ class Nasm < RegexLexer
end

state :instruction_args do
rule %r/"(\\\\"|[^"\\n])*"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`/, Str
rule %r/"(\\\\"|[^"\\n])*"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`/, Str
rule %r/(?:0x[\da-f]+|$0[\da-f]*|\d+[\da-f]*h)/i, Num::Hex
rule %r/[0-7]+q/i, Num::Oct
rule %r/[01]+b/i, Num::Bin
Expand Down
4 changes: 4 additions & 0 deletions spec/visual/samples/nasm
@@ -1,3 +1,7 @@
[global Start]
[BITS 16]
[ORG 0x7C00]

; Simple test of the NASM parser

; Data section, initialized variables
Expand Down

0 comments on commit fb9aae2

Please sign in to comment.