Skip to content

Commit

Permalink
kotlin: parse package declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
dolik-rce committed Dec 24, 2020
1 parent e1ab236 commit aa1f1cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Units/parser-kotlin.r/kotlin-syntax.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
com.example.helloworld input.kt /^package com.example.helloworld$/;" p
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
Expand Down
2 changes: 2 additions & 0 deletions Units/parser-kotlin.r/kotlin-syntax.d/input.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.example.helloworld

interface AbstractWorker {
abstract fun process(): String
}
Expand Down
6 changes: 6 additions & 0 deletions optlib/kotlin.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ static void initializeKotlinParser (const langType language)
addLanguageTagMultiTableRegex (language, "toplevel",
"^'.{1,2}'",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^package[[:space:]]+([^\n]+)",
"\\1", "p", "", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^val[[:space:]]+\\([[:space:]]*",
"", "", "{tenter=vals}", NULL);
Expand Down Expand Up @@ -127,6 +130,9 @@ extern parserDefinition* KotlinParser (void)
};

static kindDefinition KotlinKindTable [] = {
{
true, 'p', "package", "packages",
},
{
true, 'c', "class", "classes",
},
Expand Down
2 changes: 2 additions & 0 deletions optlib/kotlin.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
--map-Kotlin=+.kt
--map-Kotlin=+.kts

--kinddef-Kotlin=p,package,packages
--kinddef-Kotlin=c,class,classes
--kinddef-Kotlin=o,object,objects
--kinddef-Kotlin=i,interface,interfaces
Expand Down Expand Up @@ -70,6 +71,7 @@
--_mtable-regex-Kotlin=toplevel/"""//{tenter=mlstring}
--_mtable-regex-Kotlin=toplevel/"//{tenter=string}
--_mtable-regex-Kotlin=toplevel/'.{1,2}'//
--_mtable-regex-Kotlin=toplevel/package[[:space:]]+([^\n]+)/\1/p/
--_mtable-regex-Kotlin=toplevel/val[[:space:]]+\([[:space:]]*//{tenter=vals}
--_mtable-regex-Kotlin=toplevel/var[[:space:]]+\([[:space:]]*//{tenter=vars}
--_mtable-regex-Kotlin=toplevel/class[[:space:]]+([[:alnum:]_]+)/\1/c/
Expand Down

0 comments on commit aa1f1cd

Please sign in to comment.