...

Source file src/github.com/alecthomas/chroma/lexers/c/cmake.go

Documentation: github.com/alecthomas/chroma/lexers/c

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

View as plain text