terminfo.go

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