1package c
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Cap'N'Proto Proto lexer.
9var CapNProto = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Cap'n Proto",
12 Aliases: []string{"capnp"},
13 Filenames: []string{"*.capnp"},
14 MimeTypes: []string{},
15 },
16 Rules{
17 "root": {
18 {`#.*?$`, CommentSingle, nil},
19 {`@[0-9a-zA-Z]*`, NameDecorator, nil},
20 {`=`, Literal, Push("expression")},
21 {`:`, NameClass, Push("type")},
22 {`\$`, NameAttribute, Push("annotation")},
23 {`(struct|enum|interface|union|import|using|const|annotation|extends|in|of|on|as|with|from|fixed)\b`, Keyword, nil},
24 {`[\w.]+`, Name, nil},
25 {`[^#@=:$\w]+`, Text, nil},
26 },
27 "type": {
28 {`[^][=;,(){}$]+`, NameClass, nil},
29 {`[[(]`, NameClass, Push("parentype")},
30 Default(Pop(1)),
31 },
32 "parentype": {
33 {`[^][;()]+`, NameClass, nil},
34 {`[[(]`, NameClass, Push()},
35 {`[])]`, NameClass, Pop(1)},
36 Default(Pop(1)),
37 },
38 "expression": {
39 {`[^][;,(){}$]+`, Literal, nil},
40 {`[[(]`, Literal, Push("parenexp")},
41 Default(Pop(1)),
42 },
43 "parenexp": {
44 {`[^][;()]+`, Literal, nil},
45 {`[[(]`, Literal, Push()},
46 {`[])]`, Literal, Pop(1)},
47 Default(Pop(1)),
48 },
49 "annotation": {
50 {`[^][;,(){}=:]+`, NameAttribute, nil},
51 {`[[(]`, NameAttribute, Push("annexp")},
52 Default(Pop(1)),
53 },
54 "annexp": {
55 {`[^][;()]+`, NameAttribute, nil},
56 {`[[(]`, NameAttribute, Push()},
57 {`[])]`, NameAttribute, Pop(1)},
58 Default(Pop(1)),
59 },
60 },
61))