mirror of
https://github.com/cheat/cheat.git
synced 2024-11-01 13:41:01 +01:00
55b18b4897
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 commit6956f51cae
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. commit0aca411279
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:23:24 2021 -0400 chore(deps): update dependencies commite847956b02
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
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package g
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Gas lexer.
|
|
var Gas = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "GAS",
|
|
Aliases: []string{"gas", "asm"},
|
|
Filenames: []string{"*.s", "*.S"},
|
|
MimeTypes: []string{"text/x-gas"},
|
|
},
|
|
gasRules,
|
|
))
|
|
|
|
func gasRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
Include("whitespace"),
|
|
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+):`, NameLabel, nil},
|
|
{`\.(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameAttribute, Push("directive-args")},
|
|
{`lock|rep(n?z)?|data\d+`, NameAttribute, nil},
|
|
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameFunction, Push("instruction-args")},
|
|
{`[\r\n]+`, Text, nil},
|
|
},
|
|
"directive-args": {
|
|
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameConstant, nil},
|
|
{`"(\\"|[^"])*"`, LiteralString, nil},
|
|
{`@(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameAttribute, nil},
|
|
{`(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil},
|
|
{`[\r\n]+`, Text, Pop(1)},
|
|
Include("punctuation"),
|
|
Include("whitespace"),
|
|
},
|
|
"instruction-args": {
|
|
{`([a-z0-9]+)( )(<)((?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+))(>)`, ByGroups(LiteralNumberHex, Text, Punctuation, NameConstant, Punctuation), nil},
|
|
{`([a-z0-9]+)( )(<)((?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+))([-+])((?:0[xX][a-zA-Z0-9]+|\d+))(>)`, ByGroups(LiteralNumberHex, Text, Punctuation, NameConstant, Punctuation, LiteralNumberInteger, Punctuation), nil},
|
|
{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameConstant, nil},
|
|
{`(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil},
|
|
{`%(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameVariable, nil},
|
|
{`$(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil},
|
|
{`$'(.|\\')'`, LiteralStringChar, nil},
|
|
{`[\r\n]+`, Text, Pop(1)},
|
|
Include("punctuation"),
|
|
Include("whitespace"),
|
|
},
|
|
"whitespace": {
|
|
{`\n`, Text, nil},
|
|
{`\s+`, Text, nil},
|
|
{`[;#].*?\n`, Comment, nil},
|
|
},
|
|
"punctuation": {
|
|
{`[-*,.()\[\]!:]+`, Punctuation, nil},
|
|
},
|
|
}
|
|
}
|