1 package p
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8
9 var Pkgconfig = internal.Register(MustNewLazyLexer(
10 &Config{
11 Name: "PkgConfig",
12 Aliases: []string{"pkgconfig"},
13 Filenames: []string{"*.pc"},
14 MimeTypes: []string{},
15 },
16 pkgconfigRules,
17 ))
18
19 func pkgconfigRules() Rules {
20 return Rules{
21 "root": {
22 {`#.*$`, CommentSingle, nil},
23 {`^(\w+)(=)`, ByGroups(NameAttribute, Operator), nil},
24 {`^([\w.]+)(:)`, ByGroups(NameTag, Punctuation), Push("spvalue")},
25 Include("interp"),
26 {`[^${}#=:\n.]+`, Text, nil},
27 {`.`, Text, nil},
28 },
29 "interp": {
30 {`\$\$`, Text, nil},
31 {`\$\{`, LiteralStringInterpol, Push("curly")},
32 },
33 "curly": {
34 {`\}`, LiteralStringInterpol, Pop(1)},
35 {`\w+`, NameAttribute, nil},
36 },
37 "spvalue": {
38 Include("interp"),
39 {`#.*$`, CommentSingle, Pop(1)},
40 {`\n`, Text, Pop(1)},
41 {`[^${}#\n]+`, Text, nil},
42 {`.`, Text, nil},
43 },
44 }
45 }
46
View as plain text