package k

import "github.com/alecthomas/chroma/lexers/k"

Index

Variables

var Kotlin = internal.Register(MustNewLexer(
	&Config{
		Name:      "Kotlin",
		Aliases:   []string{"kotlin"},
		Filenames: []string{"*.kt"},
		MimeTypes: []string{"text/x-kotlin"},
		DotAll:    true,
	},
	Rules{
		"root": {
			{`^\s*\[.*?\]`, NameAttribute, nil},
			{`[^\S\n]+`, Text, nil},
			{`\\\n`, Text, nil},
			{`//[^\n]*\n?`, CommentSingle, nil},
			{`/[*].*?[*]/`, CommentMultiline, nil},
			{`\n`, Text, nil},
			{`::|!!|\?[:.]`, Operator, nil},
			{`[~!%^&*()+=|\[\]:;,.<>/?-]`, Punctuation, nil},
			{`[{}]`, Punctuation, nil},
			{`"""[^"]*"""`, LiteralString, nil},
			{`"(\\\\|\\"|[^"\n])*["\n]`, LiteralString, nil},
			{`'\\.'|'[^\\]'`, LiteralStringChar, nil},
			{`0[xX][0-9a-fA-F]+[Uu]?[Ll]?|[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?[fF]?[Uu]?[Ll]?`, LiteralNumber, nil},
			{`(companion)(\s+)(object)`, ByGroups(Keyword, Text, Keyword), nil},
			{`(class|interface|object)(\s+)`, ByGroups(Keyword, Text), Push("class")},
			{`(package|import)(\s+)`, ByGroups(Keyword, Text), Push("package")},
			{`(val|var)(\s+)`, ByGroups(Keyword, Text), Push("property")},
			{`(fun)(\s+)(<[^>]*>\s+)?`, ByGroups(Keyword, Text, Text), Push("function")},
			{"" /* 423 byte string literal not displayed */, Keyword, nil},
			{"(@?[" + kotlinIdentifier + "]*`)", Name, nil},
		},
		"package": {
			{`\S+`, NameNamespace, Pop(1)},
		},
		"class": {
			{"(@?[" + kotlinIdentifier + "]*`)", NameClass, Pop(1)},
		},
		"property": {
			{"(@?[" + kotlinIdentifier + " ]*`)", NameProperty, Pop(1)},
		},
		"function": {
			{"(@?[" + kotlinIdentifier + " ]*`)", NameFunction, Pop(1)},
		},
	},
))

Kotlin lexer.

Source Files

kotlin.go

Version
v0.6.9
Published
Nov 5, 2019
Platform
js/wasm
Imports
2 packages
Last checked
1 hour ago

Tools for package owners.