1package c
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Cfengine3 lexer.
9var Cfengine3 = internal.Register(MustNewLexer(
10 &Config{
11 Name: "CFEngine3",
12 Aliases: []string{"cfengine3", "cf3"},
13 Filenames: []string{"*.cf"},
14 MimeTypes: []string{},
15 },
16 Rules{
17 "root": {
18 {`#.*?\n`, Comment, nil},
19 {`(body)(\s+)(\S+)(\s+)(control)`, ByGroups(Keyword, Text, Keyword, Text, Keyword), nil},
20 {`(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()`, ByGroups(Keyword, Text, Keyword, Text, NameFunction, Punctuation), Push("arglist")},
21 {`(body|bundle)(\s+)(\S+)(\s+)(\w+)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil},
22 {`(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)`, ByGroups(Punctuation, NameVariable, Punctuation, Text, KeywordType, Text, Operator, Text), nil},
23 {`(\S+)(\s*)(=>)(\s*)`, ByGroups(KeywordReserved, Text, Operator, Text), nil},
24 {`"`, LiteralString, Push("string")},
25 {`(\w+)(\()`, ByGroups(NameFunction, Punctuation), nil},
26 {`([\w.!&|()]+)(::)`, ByGroups(NameClass, Punctuation), nil},
27 {`(\w+)(:)`, ByGroups(KeywordDeclaration, Punctuation), nil},
28 {`@[{(][^)}]+[})]`, NameVariable, nil},
29 {`[(){},;]`, Punctuation, nil},
30 {`=>`, Operator, nil},
31 {`->`, Operator, nil},
32 {`\d+\.\d+`, LiteralNumberFloat, nil},
33 {`\d+`, LiteralNumberInteger, nil},
34 {`\w+`, NameFunction, nil},
35 {`\s+`, Text, nil},
36 },
37 "string": {
38 {`\$[{(]`, LiteralStringInterpol, Push("interpol")},
39 {`\\.`, LiteralStringEscape, nil},
40 {`"`, LiteralString, Pop(1)},
41 {`\n`, LiteralString, nil},
42 {`.`, LiteralString, nil},
43 },
44 "interpol": {
45 {`\$[{(]`, LiteralStringInterpol, Push()},
46 {`[})]`, LiteralStringInterpol, Pop(1)},
47 {`[^${()}]+`, LiteralStringInterpol, nil},
48 },
49 "arglist": {
50 {`\)`, Punctuation, Pop(1)},
51 {`,`, Punctuation, nil},
52 {`\w+`, NameVariable, nil},
53 {`\s+`, Text, nil},
54 },
55 },
56))