1 package t
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8
9 var Terminfo = internal.Register(MustNewLazyLexer(
10 &Config{
11 Name: "Terminfo",
12 Aliases: []string{"terminfo"},
13 Filenames: []string{"terminfo", "terminfo.src"},
14 MimeTypes: []string{},
15 },
16 terminfoRules,
17 ))
18
19 func terminfoRules() Rules {
20 return Rules{
21 "root": {
22 {`^#.*$`, Comment, nil},
23 {`^[^\s#,|]+`, NameTag, Push("names")},
24 },
25 "names": {
26 {`\n`, Text, Pop(1)},
27 {`(,)([ \t]*)`, ByGroups(Punctuation, Text), Push("defs")},
28 {`\|`, Punctuation, nil},
29 {`[^,|]+`, NameAttribute, nil},
30 },
31 "defs": {
32 {`\n[ \t]+`, Text, nil},
33 {`\n`, Text, Pop(2)},
34 {`(#)([0-9]+)`, ByGroups(Operator, LiteralNumber), nil},
35 {`=`, Operator, Push("data")},
36 {`(,)([ \t]*)`, ByGroups(Punctuation, Text), nil},
37 {`[^\s,=#]+`, NameClass, nil},
38 },
39 "data": {
40 {`\\[,\\]`, Literal, nil},
41 {`(,)([ \t]*)`, ByGroups(Punctuation, Text), Pop(1)},
42 {`[^\\,]+`, Literal, nil},
43 {`.`, Literal, nil},
44 },
45 }
46 }
47
View as plain text