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.

cmake.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package c
  2. import (
  3. . "github.com/alecthomas/chroma" // nolint
  4. "github.com/alecthomas/chroma/lexers/internal"
  5. )
  6. // Cmake lexer.
  7. var Cmake = internal.Register(MustNewLexer(
  8. &Config{
  9. Name: "CMake",
  10. Aliases: []string{"cmake"},
  11. Filenames: []string{"*.cmake", "CMakeLists.txt"},
  12. MimeTypes: []string{"text/x-cmake"},
  13. },
  14. Rules{
  15. "root": {
  16. {`\b(\w+)([ \t]*)(\()`, ByGroups(NameBuiltin, Text, Punctuation), Push("args")},
  17. Include("keywords"),
  18. Include("ws"),
  19. },
  20. "args": {
  21. {`\(`, Punctuation, Push()},
  22. {`\)`, Punctuation, Pop(1)},
  23. {`(\$\{)(.+?)(\})`, ByGroups(Operator, NameVariable, Operator), nil},
  24. {`(\$ENV\{)(.+?)(\})`, ByGroups(Operator, NameVariable, Operator), nil},
  25. {`(\$<)(.+?)(>)`, ByGroups(Operator, NameVariable, Operator), nil},
  26. {`(?s)".*?"`, LiteralStringDouble, nil},
  27. {`\\\S+`, LiteralString, nil},
  28. {`[^)$"# \t\n]+`, LiteralString, nil},
  29. {`\n`, Text, nil},
  30. Include("keywords"),
  31. Include("ws"),
  32. },
  33. "string": {},
  34. "keywords": {
  35. {`\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|MSVC70|MSVC71|MSVC80|MSVC90)\b`, Keyword, nil},
  36. },
  37. "ws": {
  38. {`[ \t]+`, Text, nil},
  39. {`#.*\n`, Comment, nil},
  40. },
  41. },
  42. ))