forked from highlightjs/highlight.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request highlightjs#778 from cy6erGn0m/kotlin
Introduce Kotlin language
- Loading branch information
Showing
8 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,3 +162,4 @@ Contributors: | |
- Gu Yiling <[email protected]> | ||
- Thomas Applencourt <[email protected]> | ||
- Andrew Farmer <[email protected]> | ||
- Sergey Mashkov <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,3 +159,4 @@ URL: https://highlightjs.org/ | |
- Гу Илинь <[email protected]> | ||
- Томас Аппленкур <[email protected]> | ||
- Эндрю Фармер <[email protected]> | ||
- Сергей Машков <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
Language: Kotlin | ||
Author: Sergey Mashkov <[email protected]> | ||
Category: misc | ||
*/ | ||
|
||
|
||
function (hljs) { | ||
var KEYWORDS = 'val var get set class trait object public open private protected ' + | ||
'final enum if else do while for when break continue throw try catch finally ' + | ||
'import package is as in return fun override default companion reified inline volatile transient native'; | ||
|
||
return { | ||
keywords: { | ||
typename : 'Byte Short Char Int Long Boolean Float Double Void Unit Nothing', | ||
literal : 'true false null', | ||
keyword: KEYWORDS | ||
}, | ||
contains : [ | ||
hljs.C_LINE_COMMENT_MODE, | ||
{ | ||
className: 'javadoc', | ||
begin: '/\\*\\*', end: '\\*//*', | ||
relevance: 0, | ||
contains: [ | ||
{ | ||
className: 'javadoctag', begin: '(^|\\s)@[A-Za-z]+' | ||
} | ||
] | ||
}, | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
{ | ||
className: 'type', | ||
begin: /</, end: />/, | ||
returnBegin: true, | ||
excludeEnd: false, | ||
relevance: 0 | ||
}, | ||
{ | ||
className: 'function', | ||
beginKeywords: 'fun', end: '[(]|$', | ||
returnBegin: true, | ||
excludeEnd : true, | ||
keywords: KEYWORDS, | ||
illegal: /fun\s+(<.*>)?[^\s\(]+(\s+[^\s\(]+)\s*=/, | ||
relevance : 5, | ||
contains: [ | ||
{ | ||
begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, | ||
relevance: 0, | ||
contains: [hljs.UNDERSCORE_TITLE_MODE] | ||
}, | ||
{ | ||
className : 'type', | ||
begin: /</, end : />/, keywords: 'reified', | ||
relevance: 0 | ||
}, | ||
{ | ||
className: 'params', | ||
begin: /\(/, end: /\)/, | ||
keywords: KEYWORDS, | ||
relevance: 0, | ||
illegal : /\([^\(,\s:]+,/, | ||
contains: [ | ||
{ | ||
className: 'typename', | ||
begin: /:\s*/, end: /\s*[=\)]/, excludeBegin: true, returnEnd: true, | ||
relevance: 0 | ||
} | ||
] | ||
}, | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.C_BLOCK_COMMENT_MODE | ||
] | ||
}, | ||
{ | ||
className: 'class', | ||
beginKeywords: 'class trait', end: /[:\{(]|$/, | ||
excludeEnd : true, | ||
illegal: 'extends implements', | ||
contains: [ | ||
hljs.UNDERSCORE_TITLE_MODE, | ||
{ | ||
className : 'type', | ||
begin: /</, end : />/, excludeBegin: true, excludeEnd: true, | ||
relevance: 0 | ||
}, | ||
{ | ||
className : 'typename', | ||
begin : /[,:]\s*/, end : /[<\(,]|$/, excludeBegin: true, returnEnd: true | ||
} | ||
] | ||
}, | ||
{ | ||
className: 'variable', beginKeywords: 'var val', end : /\s*[=:$]/, excludeEnd: true | ||
}, | ||
hljs.QUOTE_STRING_MODE, | ||
{ | ||
className: 'shebang', | ||
begin: "^#!/usr/bin/env", end: '$', | ||
illegal: '\n' | ||
}, | ||
hljs.C_NUMBER_MODE | ||
] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import kotlin.lang.test | ||
|
||
trait A { | ||
fun x() | ||
} | ||
|
||
fun xxx() : Int { | ||
return 888 | ||
} | ||
|
||
public fun main(args : Array<String>) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">A</span> </span>{ | ||
} | ||
|
||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">B</span></span>() | ||
|
||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">C</span></span>() {} | ||
|
||
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">D</span></span> | ||
|
||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">E1</span><<span class="hljs-type">T</span>></span> | ||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">E2</span><<span class="hljs-type">T, R</span>></span> | ||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">E3</span><<span class="hljs-type">T,R</span>></span> | ||
|
||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">F1</span> : <span class="hljs-typename">A</span></span> | ||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">F2</span> : <span class="hljs-typename">A</span>, <span class="hljs-typename">B</span></span> | ||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">F3</span> : <span class="hljs-typename">A</span><<span class="hljs-type">T</span>></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class A { | ||
} | ||
|
||
class B() | ||
|
||
class C() {} | ||
|
||
public class D | ||
|
||
class E1<T> | ||
class E2<T, R> | ||
class E3<T,R> | ||
|
||
class F1 : A | ||
class F2 : A, B | ||
class F3 : A<T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">a</span><span class="hljs-params">()</span> = 1</span> | ||
<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">b</span><span class="hljs-params">(a : <span class="hljs-typename">Int</span>)</span> = a</span> | ||
|
||
|
||
<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-type"><T></span> <span class="hljs-title">c</span><span class="hljs-params">()</span> = 1</span> | ||
<span class="hljs-keyword">inline</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-type"><<span class="hljs-keyword">reified</span> T></span> <span class="hljs-title">d</span><span class="hljs-params">()</span> = 1</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fun a() = 1 | ||
fun b(a : Int) = a | ||
|
||
|
||
fun <T> c() = 1 | ||
inline fun <reified T> d() = 1 |