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