1 package a
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8 var ArmAsm = internal.Register(MustNewLazyLexer(
9 &Config{
10 Name: "ArmAsm",
11 Aliases: []string{"armasm"},
12 EnsureNL: true,
13 Filenames: []string{"*.s", "*.S"},
14 MimeTypes: []string{"text/x-armasm", "text/x-asm"},
15 },
16 armasmRules,
17 ))
18
19 func armasmRules() Rules {
20 return Rules{
21 "commentsandwhitespace": {
22 {`\s+`, Text, nil},
23 {`[@;].*?\n`, CommentSingle, nil},
24 {`/\*.*?\*/`, CommentMultiline, nil},
25 },
26 "literal": {
27
28 {`0b[01]+`, NumberBin, Pop(1)},
29
30 {`0x\w{1,8}`, NumberHex, Pop(1)},
31
32 {`0\d+`, NumberOct, Pop(1)},
33
34 {`\d+?\.\d+?`, NumberFloat, Pop(1)},
35
36 {`\d+`, NumberInteger, Pop(1)},
37
38 {`(")(.+)(")`, ByGroups(Punctuation, StringDouble, Punctuation), Pop(1)},
39
40 {`(')(.{1}|\\.{1})(')`, ByGroups(Punctuation, StringChar, Punctuation), Pop(1)},
41 },
42 "opcode": {
43
44 {`\n`, Text, Pop(1)},
45
46 {`(@|;).*\n`, CommentSingle, Pop(1)},
47
48 {`(\s+|,)`, Text, nil},
49
50 {`[rapcfxwbhsdqv]\d{1,2}`, NameClass, nil},
51
52 {`=0x\w+`, ByGroups(Text, NameLabel), nil},
53
54 {`(=)(\w+)`, ByGroups(Text, NameLabel), nil},
55
56 {`#`, Text, Push("literal")},
57 },
58 "root": {
59 Include("commentsandwhitespace"),
60
61 {`(\.\w+)([ \t]+\w+\s+?)?`, ByGroups(KeywordNamespace, NameLabel), nil},
62
63 {`(\w+)(:)(\s+\.\w+\s+)`, ByGroups(NameLabel, Punctuation, KeywordNamespace), Push("literal")},
64
65 {`(\w+)(:)`, ByGroups(NameLabel, Punctuation), nil},
66
67 {`svc\s+\w+`, NameNamespace, nil},
68
69 {`[a-zA-Z]+`, Text, Push("opcode")},
70 },
71 }
72 }
73
View as plain text