1
0
mirror of https://github.com/cheat/cheat.git synced 2024-12-24 05:29:44 +01:00
cheat/vendor/github.com/alecthomas/chroma/lexers/n/nasm.go
Chris Lane 55b18b4897 Squashed commit of the following:
commit 95479c8ad744db48386a5c78e54ef8da80e9120b
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:26:32 2021 -0400

    chore(version): bump version to 4.2.1

commit 6956f51cae
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:24:21 2021 -0400

    fix(Makefile): `vendor-update`

    Update the `vendor-update` build target to run `go mod vendor` after
    updating dependencies.

commit 0aca411279
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:23:24 2021 -0400

    chore(deps): update dependencies

commit e847956b02
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 08:26:51 2021 -0400

    chore(deps): build updates

    - Upgrade `go` to `1.16.3`

    - Attempt to fix build errors regarding dependencies
2021-04-28 12:35:32 -04:00

64 lines
2.1 KiB
Go

package n
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Nasm lexer.
var Nasm = internal.Register(MustNewLazyLexer(
&Config{
Name: "NASM",
Aliases: []string{"nasm"},
Filenames: []string{"*.asm", "*.ASM"},
MimeTypes: []string{"text/x-nasm"},
CaseInsensitive: true,
},
nasmRules,
))
func nasmRules() Rules {
return Rules{
"root": {
{`^\s*%`, CommentPreproc, Push("preproc")},
Include("whitespace"),
{`[a-z$._?][\w$.?#@~]*:`, NameLabel, nil},
{`([a-z$._?][\w$.?#@~]*)(\s+)(equ)`, ByGroups(NameConstant, KeywordDeclaration, KeywordDeclaration), Push("instruction-args")},
{`BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE`, Keyword, Push("instruction-args")},
{`(?:res|d)[bwdqt]|times`, KeywordDeclaration, Push("instruction-args")},
{`[a-z$._?][\w$.?#@~]*`, NameFunction, Push("instruction-args")},
{`[\r\n]+`, Text, nil},
},
"instruction-args": {
{"\"(\\\\\"|[^\"\\n])*\"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`", LiteralString, nil},
{`(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)`, LiteralNumberHex, nil},
{`[0-7]+q`, LiteralNumberOct, nil},
{`[01]+b`, LiteralNumberBin, nil},
{`[0-9]+\.e?[0-9]+`, LiteralNumberFloat, nil},
{`[0-9]+`, LiteralNumberInteger, nil},
Include("punctuation"),
{`r[0-9][0-5]?[bwd]|[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]`, NameBuiltin, nil},
{`[a-z$._?][\w$.?#@~]*`, NameVariable, nil},
{`[\r\n]+`, Text, Pop(1)},
Include("whitespace"),
},
"preproc": {
{`[^;\n]+`, CommentPreproc, nil},
{`;.*?\n`, CommentSingle, Pop(1)},
{`\n`, CommentPreproc, Pop(1)},
},
"whitespace": {
{`\n`, Text, nil},
{`[ \t]+`, Text, nil},
{`;.*`, CommentSingle, nil},
},
"punctuation": {
{`[,():\[\]]+`, Punctuation, nil},
{`[&|^<>+*/%~-]+`, Operator, nil},
{`[$]+`, KeywordConstant, nil},
{`seg|wrt|strict`, OperatorWord, nil},
{`byte|[dq]?word`, KeywordType, nil},
},
}
}