You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

capnproto.go 1.5KB

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