1package p
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Puppet lexer.
9var Puppet = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Puppet",
12 Aliases: []string{"puppet"},
13 Filenames: []string{"*.pp"},
14 MimeTypes: []string{},
15 },
16 Rules{
17 "root": {
18 Include("comments"),
19 Include("keywords"),
20 Include("names"),
21 Include("numbers"),
22 Include("operators"),
23 Include("strings"),
24 {`[]{}:(),;[]`, Punctuation, nil},
25 {`[^\S\n]+`, Text, nil},
26 },
27 "comments": {
28 {`\s*#.*$`, Comment, nil},
29 {`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
30 },
31 "operators": {
32 {`(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)`, Operator, nil},
33 {`(in|and|or|not)\b`, OperatorWord, nil},
34 },
35 "names": {
36 {`[a-zA-Z_]\w*`, NameAttribute, nil},
37 {`(\$\S+)(\[)(\S+)(\])`, ByGroups(NameVariable, Punctuation, LiteralString, Punctuation), nil},
38 {`\$\S+`, NameVariable, nil},
39 },
40 "numbers": {
41 {`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?`, LiteralNumberFloat, nil},
42 {`\d+[eE][+-]?[0-9]+j?`, LiteralNumberFloat, nil},
43 {`0[0-7]+j?`, LiteralNumberOct, nil},
44 {`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
45 {`\d+L`, LiteralNumberIntegerLong, nil},
46 {`\d+j?`, LiteralNumberInteger, nil},
47 },
48 "keywords": {
49 {Words(`(?i)`, `\b`, `absent`, `alert`, `alias`, `audit`, `augeas`, `before`, `case`, `check`, `class`, `computer`, `configured`, `contained`, `create_resources`, `crit`, `cron`, `debug`, `default`, `define`, `defined`, `directory`, `else`, `elsif`, `emerg`, `err`, `exec`, `extlookup`, `fail`, `false`, `file`, `filebucket`, `fqdn_rand`, `generate`, `host`, `if`, `import`, `include`, `info`, `inherits`, `inline_template`, `installed`, `interface`, `k5login`, `latest`, `link`, `loglevel`, `macauthorization`, `mailalias`, `maillist`, `mcx`, `md5`, `mount`, `mounted`, `nagios_command`, `nagios_contact`, `nagios_contactgroup`, `nagios_host`, `nagios_hostdependency`, `nagios_hostescalation`, `nagios_hostextinfo`, `nagios_hostgroup`, `nagios_service`, `nagios_servicedependency`, `nagios_serviceescalation`, `nagios_serviceextinfo`, `nagios_servicegroup`, `nagios_timeperiod`, `node`, `noop`, `notice`, `notify`, `package`, `present`, `purged`, `realize`, `regsubst`, `resources`, `role`, `router`, `running`, `schedule`, `scheduled_task`, `search`, `selboolean`, `selmodule`, `service`, `sha1`, `shellquote`, `split`, `sprintf`, `ssh_authorized_key`, `sshkey`, `stage`, `stopped`, `subscribe`, `tag`, `tagged`, `template`, `tidy`, `true`, `undef`, `unmounted`, `user`, `versioncmp`, `vlan`, `warning`, `yumrepo`, `zfs`, `zone`, `zpool`), Keyword, nil},
50 },
51 "strings": {
52 {`"([^"])*"`, LiteralString, nil},
53 {`'(\\'|[^'])*'`, LiteralString, nil},
54 },
55 },
56))