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.

cheetah.go 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package c
  2. import (
  3. . "github.com/alecthomas/chroma" // nolint
  4. "github.com/alecthomas/chroma/lexers/internal"
  5. . "github.com/alecthomas/chroma/lexers/p" // nolint
  6. )
  7. // Cheetah lexer.
  8. var Cheetah = internal.Register(MustNewLexer(
  9. &Config{
  10. Name: "Cheetah",
  11. Aliases: []string{"cheetah", "spitfire"},
  12. Filenames: []string{"*.tmpl", "*.spt"},
  13. MimeTypes: []string{"application/x-cheetah", "application/x-spitfire"},
  14. },
  15. Rules{
  16. "root": {
  17. {`(##[^\n]*)$`, ByGroups(Comment), nil},
  18. {`#[*](.|\n)*?[*]#`, Comment, nil},
  19. {`#end[^#\n]*(?:#|$)`, CommentPreproc, nil},
  20. {`#slurp$`, CommentPreproc, nil},
  21. {`(#[a-zA-Z]+)([^#\n]*)(#|$)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
  22. {`(\$)([a-zA-Z_][\w.]*\w)`, ByGroups(CommentPreproc, Using(Python)), nil},
  23. {`(\$\{!?)(.*?)(\})(?s)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
  24. {`(?sx)
  25. (.+?) # anything, followed by:
  26. (?:
  27. (?=\#[#a-zA-Z]*) | # an eval comment
  28. (?=\$[a-zA-Z_{]) | # a substitution
  29. \Z # end of string
  30. )
  31. `, Other, nil},
  32. {`\s+`, Text, nil},
  33. },
  34. },
  35. ))