mirror of
https://github.com/cheat/cheat.git
synced 2024-11-16 08:58:28 +01:00
55b18b4897
commit 95479c8ad744db48386a5c78e54ef8da80e9120b Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:26:32 2021 -0400 chore(version): bump version to 4.2.1 commit6956f51cae
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:24:21 2021 -0400 fix(Makefile): `vendor-update` Update the `vendor-update` build target to run `go mod vendor` after updating dependencies. commit0aca411279
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:23:24 2021 -0400 chore(deps): update dependencies commite847956b02
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 08:26:51 2021 -0400 chore(deps): build updates - Upgrade `go` to `1.16.3` - Attempt to fix build errors regarding dependencies
60 lines
2.8 KiB
Go
60 lines
2.8 KiB
Go
package p
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Puppet lexer.
|
|
var Puppet = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "Puppet",
|
|
Aliases: []string{"puppet"},
|
|
Filenames: []string{"*.pp"},
|
|
MimeTypes: []string{},
|
|
},
|
|
puppetRules,
|
|
))
|
|
|
|
func puppetRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
Include("comments"),
|
|
Include("keywords"),
|
|
Include("names"),
|
|
Include("numbers"),
|
|
Include("operators"),
|
|
Include("strings"),
|
|
{`[]{}:(),;[]`, Punctuation, nil},
|
|
{`[^\S\n]+`, Text, nil},
|
|
},
|
|
"comments": {
|
|
{`\s*#.*$`, Comment, nil},
|
|
{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
|
|
},
|
|
"operators": {
|
|
{`(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)`, Operator, nil},
|
|
{`(in|and|or|not)\b`, OperatorWord, nil},
|
|
},
|
|
"names": {
|
|
{`[a-zA-Z_]\w*`, NameAttribute, nil},
|
|
{`(\$\S+)(\[)(\S+)(\])`, ByGroups(NameVariable, Punctuation, LiteralString, Punctuation), nil},
|
|
{`\$\S+`, NameVariable, nil},
|
|
},
|
|
"numbers": {
|
|
{`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?`, LiteralNumberFloat, nil},
|
|
{`\d+[eE][+-]?[0-9]+j?`, LiteralNumberFloat, nil},
|
|
{`0[0-7]+j?`, LiteralNumberOct, nil},
|
|
{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
|
|
{`\d+L`, LiteralNumberIntegerLong, nil},
|
|
{`\d+j?`, LiteralNumberInteger, nil},
|
|
},
|
|
"keywords": {
|
|
{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},
|
|
},
|
|
"strings": {
|
|
{`"([^"])*"`, LiteralString, nil},
|
|
{`'(\\'|[^'])*'`, LiteralString, nil},
|
|
},
|
|
}
|
|
}
|