Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions langs/extensions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ c# cs
c++ h hh hpp hxx h++ cc cpp cxx c++
html html htm xhtml xhtm xml xsd
java java class jar
kotlin kt
mel mel ma
objc m mm
papyrus psc
Expand Down
43 changes: 43 additions & 0 deletions langs/kotlin/function.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
with
print
println
arrayOf
arrayOfNulls
booleanArrayOf
byteArrayOf
charArrayOf
doubleArrayOf
emptyArray
enumValueOf
enumValues
floatArrayOf
intArrayOf
longArrayOf
shortArrayOf
emptyArray
emptyList
emptySet
emptyMap
emptySequence
listOf
listOfNotNull
arrayListOf
mutableListOf
mapOf
hashMapOf
linkedMapOf
mutableMapOf
sortedMapOf
setOf
hashSetOf
linkedSetOf
mutableSetOf
sortedSetOf
assert
check
checkNotNull
error
require
requireNotNull
lazy
lazyOf
8 changes: 8 additions & 0 deletions langs/kotlin/infix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
shl
shr
ushr
and
xor
or
until
to
29 changes: 29 additions & 0 deletions langs/kotlin/kotlin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### KOTLIN LANGUAGE ###

# ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION

CASE_INSENSITIVE = OFF

NAME Kotlin
VERSION 1.0.0

COMMENT (?default)
STRING (?:(?<!\\)""".*?(?<!\\)""")|(?default)
MARK_AT:TAG (?<=this|super|return|break|continue)@[A-Za-z_]\w*|\b[A-Za-z_]\w*@(?!\w)

FUNCTION:KEYWORD \b(?alt:function.txt)\b|(?<=\s)(?alt:infix.txt)(?=\s)
NOTATION (?<= |)@[\w.]+
STATEMENT \b(?alt:statement.txt)\b
RESERVED \b(?alt:reserved.txt)\b
TYPE \b(?alt:type.txt)\b
MODIFIER \b(?alt:modifier.txt)\b

ENTITY \b[A-Za-z_]\w*(?=\s*(\w+@\s*)?\{)|\b[A-Za-z_]\w*\b(?=\s*\([^\)]*\))|(?<!\.)\b[A-Za-z_]\w*\b(?=[^}=|,.:;"'\)]*{)
GENERIC:ENTITY (?<=<)[A-Za-z_]\w*(?=>|\s*:\s*[A-Za-z_]\w*>)|(?<=in|out|:)\s+[A-Za-z_]\w*(?=>)
VARIABLE [A-Za-z_]\w*(?=\s*(?alt:operator.txt)|\s*(?alt:symbol.txt)|\s+[A-Za-z_]\w*\s+\S|\s*$)

IDENTIFIER (?default)

CONSTANT (?<!\w)((\.\d[\d_]*|\d[\d_]*\.?)[\d_]*([eE]\d[\d_]*)?[fF]?|((0[bB])?[\d_]+|0[xX][\d_a-fA-F]*)[uUlL]?)\b
OPERATOR (?alt:operator.txt)
SYMBOL (?alt:symbol.txt)
26 changes: 26 additions & 0 deletions langs/kotlin/modifier.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
abstract
final
enum
open
annotation
sealed
data
override
lateinit
in
out
noinline
crossinline
vararg
reified
tailrec
operator
companion
infix
inline
external
private
internal
public
const
suspend
27 changes: 27 additions & 0 deletions langs/kotlin/operator.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
!!
?:
?.
..
!=
==
<=
>=
+=
-=
*=
/=
++
--
&&
||

+
-
*
/
%
?
=
>
<
!
19 changes: 19 additions & 0 deletions langs/kotlin/reserved.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package
import
typealias
class
this
super
val
get
set
var
fun
null
true
false
object
interface
typeof
init
constructor
17 changes: 17 additions & 0 deletions langs/kotlin/statement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
as
is
in
for
if
else
try
catch
finally
while
do
when
continue
break
return
throw
by
17 changes: 17 additions & 0 deletions langs/kotlin/symbol.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
->
:
!
@
$
%
(
)
_
{
}
[
]
\
;
,
.
44 changes: 44 additions & 0 deletions langs/kotlin/type.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Any
Boolean
Int
Double
Float
Short
Number
Long
Char
String
Byte
Unit
Nothing
UByte
UInt
ULong
UShort
Array
IntArray
DoubleArray
FloatArray
ShortArray
ByteArray
CharArray
BooleanArray
LongArray
UByteArray
UIntArray
ULongArray
UShortArray
Sequence
false
null
true
Enum
Annotation
CharSequence
Comparable
Throwable
Exception
package
interface
class
Class
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ See the <a href="http://aramk.com/blog/2011/09/23/crayon-language-file-specifica
* MySQL (thanks to <a href="http://assemblysys.com/" target="_blank">AssemblySys.com</a> and <a href="http://ansas-meyer.de/" target="_blank">ansas-meyer.de</a>)
* Java
* JavaScript
* Kotlin
* Objective-C
* Papyrus
* Perl
Expand Down
25 changes: 25 additions & 0 deletions util/sample/kotlin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import kotlin.math.abs
import kotlin.math.sqrt

data class Point(val x: Int, val y: Int) {
infix fun distance(point: Point): Double {
val dx = abs(point.x - x)
val dy = abs(point.y - y)
return sqrt(dx * dx + dy * dy.toDouble())
}
override fun toString(): String = "($x, $y)"
}

object Distance {
class Wrapper(private val p1: Point) {
infix fun to(p2: Point) = p1.distance(p2)
}
infix fun from(p: Point): Wrapper = Wrapper(p)
}

fun main(args: Array<String>) {
val p1 = Point(1, 1)
val p2 = Point(2, 2)
val dis: Double = Distance from p1 to p2
println("The distance from $p1 to $p2 is $dis.")
}