...
1 package t
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8 var TOML = internal.Register(MustNewLazyLexer(
9 &Config{
10 Name: "TOML",
11 Aliases: []string{"toml"},
12 Filenames: []string{"*.toml"},
13 MimeTypes: []string{"text/x-toml"},
14 },
15 tomlRules,
16 ))
17
18 func tomlRules() Rules {
19 return Rules{
20 "root": {
21 {`\s+`, Text, nil},
22 {`#.*`, Comment, nil},
23 {Words(``, `\b`, `true`, `false`), KeywordConstant, nil},
24 {`\d\d\d\d-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d\+)?(Z|[+-]\d{2}:\d{2})`, LiteralDate, nil},
25 {`[+-]?[0-9](_?\d)*\.\d+`, LiteralNumberFloat, nil},
26 {`[+-]?[0-9](_?\d)*`, LiteralNumberInteger, nil},
27 {`"(\\\\|\\"|[^"])*"`, StringDouble, nil},
28 {`'(\\\\|\\'|[^'])*'`, StringSingle, nil},
29 {`[.,=\[\]{}]`, Punctuation, nil},
30 {`[A-Za-z0-9_-]+`, NameOther, nil},
31 },
32 }
33 }
34
View as plain text