-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
352 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
a input.kt /^val (a, b) = functionReturningPair()$/;" C | ||
b input.kt /^val (a, b) = functionReturningPair()$/;" C | ||
c input.kt /^val (c: Int, d: String) = functionReturningPair()$/;" C | ||
d input.kt /^val (c: Int, d: String) = functionReturningPair()$/;" C | ||
e input.kt /^var (e, f) = functionReturningPair()$/;" v | ||
f input.kt /^var (e, f) = functionReturningPair()$/;" v | ||
g input.kt /^var (g: Int, h: String) = functionReturningPair()$/;" v | ||
h input.kt /^var (g: Int, h: String) = functionReturningPair()$/;" v |
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,4 @@ | ||
val (a, b) = functionReturningPair() | ||
val (c: Int, d: String) = functionReturningPair() | ||
var (e, f) = functionReturningPair() | ||
var (g: Int, h: String) = functionReturningPair() |
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,3 @@ | ||
A input.kt /^class A$/;" c | ||
test input.kt /^fun A.test() = true$/;" m | ||
value input.kt /^val A.value$/;" C |
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 @@ | ||
class A | ||
|
||
fun A.test() = true | ||
|
||
val A.value | ||
get() = "AAA" |
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,5 @@ | ||
Bar input.kt /^class Bar<T, U>(val a: T, val b: U): Foo<T>$/;" c | ||
Foo input.kt /^interface Foo<T> {$/;" i | ||
a input.kt /^class Bar<T, U>(val a: T, val b: U): Foo<T>$/;" C | ||
b input.kt /^class Bar<T, U>(val a: T, val b: U): Foo<T>$/;" C | ||
genericFunction input.kt /^ fun<T: Any> genericFunction() = 42$/;" m |
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,5 @@ | ||
interface Foo<T> { | ||
fun<T: Any> genericFunction() = 42 | ||
} | ||
|
||
class Bar<T, U>(val a: T, val b: U): Foo<T> |
3 changes: 3 additions & 0 deletions
3
Units/parser-kotlin.r/kotlin-multilinestrings.d/expected.tags
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,3 @@ | ||
used1 input.kt /^var used1 = """var unused1 = 1"""$/;" v | ||
used2 input.kt /^var used2 = """$/;" v | ||
used3 input.kt /^var used3 = """var unused3 = 3""" + """var unused4 = 4"""$/;" v |
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,5 @@ | ||
var used1 = """var unused1 = 1""" | ||
var used2 = """ | ||
var unused2 = 2 | ||
""" | ||
var used3 = """var unused3 = 3""" + """var unused4 = 4""" |
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 @@ | ||
f input.kt /^\/* comment *\/ var f = 6 \/* another comment *\/$/;" v |
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,15 @@ | ||
// var a = 1 | ||
|
||
/* var b = 2 */ | ||
|
||
/* | ||
var c = 3 | ||
*/ | ||
|
||
/** var d = 4 */ | ||
|
||
/** | ||
* var e = 5 | ||
*/ | ||
|
||
/* comment */ var f = 6 /* another comment */ |
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,2 @@ | ||
used1 input.kt /^var used1 = "var unused1 = 1"$/;" v | ||
used2 input.kt /^var used2 = "\\"var\\" unused2 = 2"$/;" v |
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,2 @@ | ||
var used1 = "var unused1 = 1" | ||
var used2 = "\"var\" unused2 = 2" |
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 @@ | ||
--sort=no |
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,10 @@ | ||
AbstractWorker input.kt /^interface AbstractWorker {$/;" i | ||
process input.kt /^ abstract fun process(): String$/;" m | ||
Worker input.kt /^class Worker<T>(val name: T): AbstractWorker {$/;" c | ||
name input.kt /^class Worker<T>(val name: T): AbstractWorker {$/;" C | ||
process input.kt /^ override fun process(): String = name.toString()$/;" m | ||
Global input.kt /^object Global {$/;" o | ||
greeting input.kt /^ const val greeting = "Hello"$/;" C | ||
StringWorker input.kt /^typealias StringWorker = Worker<String>$/;" T | ||
main input.kt /^fun main() {$/;" m | ||
result input.kt /^ var result: String = Global.greeting$/;" v |
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,20 @@ | ||
interface AbstractWorker { | ||
abstract fun process(): String | ||
} | ||
|
||
class Worker<T>(val name: T): AbstractWorker { | ||
override fun process(): String = name.toString() | ||
} | ||
|
||
object Global { | ||
const val greeting = "Hello" | ||
} | ||
|
||
typealias StringWorker = Worker<String> | ||
|
||
fun main() { | ||
var result: String = Global.greeting | ||
result = "$result " + StringWorker("World").process() | ||
result += "!" | ||
println(result) | ||
} |
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
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
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,165 @@ | ||
/* | ||
* Generated by ./misc/optlib2c from optlib/kotlin.ctags, Don't edit this manually. | ||
*/ | ||
#include "general.h" | ||
#include "parse.h" | ||
#include "routines.h" | ||
#include "field.h" | ||
#include "xtag.h" | ||
|
||
|
||
static void initializeKotlinParser (const langType language) | ||
{ | ||
|
||
addLanguageRegexTable (language, "toplevel"); | ||
addLanguageRegexTable (language, "comment"); | ||
addLanguageRegexTable (language, "string"); | ||
addLanguageRegexTable (language, "mlstring"); | ||
addLanguageRegexTable (language, "vals"); | ||
addLanguageRegexTable (language, "vars"); | ||
|
||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^/\\*", | ||
"", "", "{tenter=comment}", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^//[^\n]*\n", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^\"\"\"", | ||
"", "", "{tenter=mlstring}", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^\"", | ||
"", "", "{tenter=string}", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^'.{1,2}'", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^val\\s+\\(\\s*", | ||
"", "", "{tenter=vals}", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^var\\s+\\(\\s*", | ||
"", "", "{tenter=vars}", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^class\\s+([[:alnum:]_]+)", | ||
"\\1", "c", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^interface\\s+([[:alnum:]_]+)", | ||
"\\1", "i", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^object\\s+([[:alnum:]_]+)", | ||
"\\1", "o", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^typealias\\s+([[:alnum:]_]+)", | ||
"\\1", "T", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^fun(<.*>)*\\s+([[:alnum:]_]+\\.)*([[:alnum:]_]+)", | ||
"\\3", "m", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^val\\s+([[:alnum:]_]+\\.)*([[:alnum:]_]+)", | ||
"\\2", "C", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^var\\s+([[:alnum:]_]+\\.)*([[:alnum:]_]+)", | ||
"\\2", "v", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^[[:alnum:]]+", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "toplevel", | ||
"^.", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "comment", | ||
"^\\*/", | ||
"", "", "{tleave}", NULL); | ||
addLanguageTagMultiTableRegex (language, "comment", | ||
"^[^*]+", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "comment", | ||
"^.", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "string", | ||
"^[^\\\\\"]+", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "string", | ||
"^\\\\.", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "string", | ||
"^\"", | ||
"", "", "{tleave}", NULL); | ||
addLanguageTagMultiTableRegex (language, "string", | ||
"^.", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "mlstring", | ||
"^\"\"\"", | ||
"", "", "{tleave}", NULL); | ||
addLanguageTagMultiTableRegex (language, "mlstring", | ||
"^[^\\\\\"]+", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "mlstring", | ||
"^.", | ||
"", "", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "vals", | ||
"^([[:alnum:]_]+)\\s*(:\\s*[[:alnum:]_]+)*\\s*,*\\s*", | ||
"\\1", "C", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "vals", | ||
"^\\)", | ||
"", "", "{tleave}", NULL); | ||
addLanguageTagMultiTableRegex (language, "vars", | ||
"^([[:alnum:]_]+)\\s*(:\\s*[[:alnum:]_]+)*\\s*,*\\s*", | ||
"\\1", "v", "", NULL); | ||
addLanguageTagMultiTableRegex (language, "vars", | ||
"^\\)", | ||
"", "", "{tleave}", NULL); | ||
} | ||
|
||
extern parserDefinition* KotlinParser (void) | ||
{ | ||
static const char *const extensions [] = { | ||
"kt", | ||
"kts", | ||
NULL | ||
}; | ||
|
||
static const char *const aliases [] = { | ||
NULL | ||
}; | ||
|
||
static const char *const patterns [] = { | ||
NULL | ||
}; | ||
|
||
static kindDefinition KotlinKindTable [] = { | ||
{ | ||
true, 'c', "class", "classes", | ||
}, | ||
{ | ||
true, 'o', "object", "objects", | ||
}, | ||
{ | ||
true, 'i', "interface", "interfaces", | ||
}, | ||
{ | ||
true, 'T', "typealias", "typealiases", | ||
}, | ||
{ | ||
true, 'm', "method", "methods", | ||
}, | ||
{ | ||
true, 'C', "constant", "constants", | ||
}, | ||
{ | ||
true, 'v', "variable", "variables", | ||
}, | ||
}; | ||
|
||
parserDefinition* const def = parserNew ("Kotlin"); | ||
|
||
def->enabled = true; | ||
def->extensions = extensions; | ||
def->patterns = patterns; | ||
def->aliases = aliases; | ||
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; | ||
def->kindTable = KotlinKindTable; | ||
def->kindCount = ARRAY_SIZE(KotlinKindTable); | ||
def->initialize = initializeKotlinParser; | ||
|
||
return def; | ||
} |
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,91 @@ | ||
# | ||
# Copyright (c) 2020, Jan Dolinár | ||
# | ||
# Author: Jan Dolinár <dolik.rce@gmail.com> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
# USA. | ||
# | ||
|
||
# Reference documentation for Kotlin language can be found | ||
# at https://kotlinlang.org/docs/reference/, including its | ||
# grammar (https://kotlinlang.org/docs/reference/grammar.html). | ||
|
||
# Known issues: | ||
# - annotations are not handled correctly | ||
|
||
# Regex for Kotlin | ||
--langdef=Kotlin | ||
--map-Kotlin=+.kt | ||
--map-Kotlin=+.kts | ||
|
||
--kinddef-Kotlin=c,class,classes | ||
--kinddef-Kotlin=o,object,objects | ||
--kinddef-Kotlin=i,interface,interfaces | ||
--kinddef-Kotlin=T,typealias,typealiases | ||
--kinddef-Kotlin=m,method,methods | ||
--kinddef-Kotlin=C,constant,constants | ||
--kinddef-Kotlin=v,variable,variables | ||
|
||
--_tabledef-Kotlin=toplevel | ||
--_tabledef-Kotlin=comment | ||
--_tabledef-Kotlin=string | ||
--_tabledef-Kotlin=mlstring | ||
--_tabledef-Kotlin=vals | ||
--_tabledef-Kotlin=vars | ||
|
||
# ignore anything in comment | ||
--_mtable-regex-Kotlin=toplevel/\/\*//{tenter=comment} | ||
--_mtable-regex-Kotlin=toplevel/\/\/[^\n]*\n// | ||
--_mtable-regex-Kotlin=comment/\*\///{tleave} | ||
--_mtable-regex-Kotlin=comment/[^*]+// | ||
--_mtable-regex-Kotlin=comment/.// | ||
|
||
# ignore anything in multiline strings | ||
--_mtable-regex-Kotlin=toplevel/"""//{tenter=mlstring} | ||
--_mtable-regex-Kotlin=mlstring/"""//{tleave} | ||
--_mtable-regex-Kotlin=mlstring/[^\\"]+// | ||
--_mtable-regex-Kotlin=mlstring/.// | ||
|
||
# ignore anything in strings | ||
--_mtable-regex-Kotlin=toplevel/"//{tenter=string} | ||
--_mtable-regex-Kotlin=string/[^\\"]+// | ||
--_mtable-regex-Kotlin=string/\\.// | ||
--_mtable-regex-Kotlin=string/"//{tleave} | ||
--_mtable-regex-Kotlin=string/.// | ||
|
||
# ignore character literals | ||
--_mtable-regex-Kotlin=toplevel/'.{1,2}'// | ||
|
||
# handle destructuring declarations | ||
--_mtable-regex-Kotlin=toplevel/val\s+\(\s*//{tenter=vals} | ||
--_mtable-regex-Kotlin=vals/([[:alnum:]_]+)\s*(:\s*[[:alnum:]_]+)*\s*,*\s*/\1/C/ | ||
--_mtable-regex-Kotlin=vals/\)//{tleave} | ||
--_mtable-regex-Kotlin=toplevel/var\s+\(\s*//{tenter=vars} | ||
--_mtable-regex-Kotlin=vars/([[:alnum:]_]+)\s*(:\s*[[:alnum:]_]+)*\s*,*\s*/\1/v/ | ||
--_mtable-regex-Kotlin=vars/\)//{tleave} | ||
|
||
# parse the language constructs | ||
--_mtable-regex-Kotlin=toplevel/class\s+([[:alnum:]_]+)/\1/c/ | ||
--_mtable-regex-Kotlin=toplevel/interface\s+([[:alnum:]_]+)/\1/i/ | ||
--_mtable-regex-Kotlin=toplevel/object\s+([[:alnum:]_]+)/\1/o/ | ||
--_mtable-regex-Kotlin=toplevel/typealias\s+([[:alnum:]_]+)/\1/T/ | ||
--_mtable-regex-Kotlin=toplevel/fun(<.*>)*\s+([[:alnum:]_]+\.)*([[:alnum:]_]+)/\3/m/ | ||
--_mtable-regex-Kotlin=toplevel/val\s+([[:alnum:]_]+\.)*([[:alnum:]_]+)/\2/C/ | ||
--_mtable-regex-Kotlin=toplevel/var\s+([[:alnum:]_]+\.)*([[:alnum:]_]+)/\2/v/ | ||
|
||
# ignore anything else | ||
--_mtable-regex-Kotlin=toplevel/[[:alnum:]]+// | ||
--_mtable-regex-Kotlin=toplevel/.// |
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
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