1 package h
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8
9 var HLB = internal.Register(MustNewLazyLexer(
10 &Config{
11 Name: "HLB",
12 Aliases: []string{"hlb"},
13 Filenames: []string{"*.hlb"},
14 MimeTypes: []string{},
15 },
16 hlbRules,
17 ))
18
19 func hlbRules() Rules {
20 return Rules{
21 "root": {
22 {`(#.*)`, ByGroups(CommentSingle), nil},
23 {`((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))`, ByGroups(LiteralNumber), nil},
24 {`((\b(true|false)\b))`, ByGroups(NameBuiltin), nil},
25 {`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)`, ByGroups(KeywordType), nil},
26 {`(\b[a-zA-Z_][a-zA-Z0-9]*\b)(\()`, ByGroups(NameFunction, Punctuation), Push("params")},
27 {`(\{)`, ByGroups(Punctuation), Push("block")},
28 {`(\n|\r|\r\n)`, Text, nil},
29 {`.`, Text, nil},
30 },
31 "string": {
32 {`"`, LiteralString, Pop(1)},
33 {`\\"`, LiteralString, nil},
34 {`[^\\"]+`, LiteralString, nil},
35 },
36 "block": {
37 {`(\})`, ByGroups(Punctuation), Pop(1)},
38 {`(#.*)`, ByGroups(CommentSingle), nil},
39 {`((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))`, ByGroups(LiteralNumber), nil},
40 {`((\b(true|false)\b))`, ByGroups(KeywordConstant), nil},
41 {`"`, LiteralString, Push("string")},
42 {`(with)`, ByGroups(KeywordReserved), nil},
43 {`(as)([\t ]+)(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(KeywordReserved, Text, NameFunction), nil},
44 {`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)([\t ]+)(\{)`, ByGroups(KeywordType, Text, Punctuation), Push("block")},
45 {`(?!\b(?:scratch|image|resolve|http|checksum|chmod|filename|git|keepGitDir|local|includePatterns|excludePatterns|followPaths|generate|frontendInput|shell|run|readonlyRootfs|env|dir|user|network|security|host|ssh|secret|mount|target|localPath|uid|gid|mode|readonly|tmpfs|sourcePath|cache|mkdir|createParents|chown|createdTime|mkfile|rm|allowNotFound|allowWildcards|copy|followSymlinks|contentsOnly|unpack|createDestPath)\b)(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(NameOther), nil},
46 {`(\n|\r|\r\n)`, Text, nil},
47 {`.`, Text, nil},
48 },
49 "params": {
50 {`(\))`, ByGroups(Punctuation), Pop(1)},
51 {`(variadic)`, ByGroups(Keyword), nil},
52 {`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)`, ByGroups(KeywordType), nil},
53 {`(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(NameOther), nil},
54 {`(\n|\r|\r\n)`, Text, nil},
55 {`.`, Text, nil},
56 },
57 }
58 }
59
View as plain text