[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs clang.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs clang.c |
Date: |
Wed, 16 Sep 2015 12:58:33 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 15/09/16 12:58:33
Modified files:
. : clang.c
Log message:
clang: add colorizer for JetBrains Kotlin language
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.99&r2=1.100
Patches:
Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- clang.c 16 Sep 2015 12:56:04 -0000 1.99
+++ clang.c 16 Sep 2015 12:58:33 -0000 1.100
@@ -62,6 +62,7 @@
CLANG_SWIFT,
CLANG_ICON,
CLANG_GROOVY,
+ CLANG_KOTLIN,
CLANG_FLAVOR = 0x3F,
};
@@ -897,7 +898,7 @@
goto normal;
case '\"': /* string literal */
- if ((flavor == CLANG_SCALA || flavor == CLANG_DART)
+ if ((flavor == CLANG_SCALA || flavor == CLANG_DART || flavor ==
CLANG_KOTLIN)
&& (str[i] == '\"' && str[i + 1] == '\"')) {
/* multiline """ quoted string */
i += 2;
@@ -906,7 +907,7 @@
parse_string3:
while (i < n) {
c = str[i++];
- if (c == '\\') {
+ if (c == '\\' && flavor != CLANG_KOTLIN) {
if (i < n)
i++;
} else
@@ -2170,6 +2171,40 @@
#include "icon.c"
#include "groovy.c"
+static const char kotlin_keywords[] = {
+ /* language keywords */
+ "package|import|as|fun|val|var|if|else|is|return|for|do|while|"
+ "break|continue|when|it|to|by|in|out|try|catch|throw|finally|"
+ "class|object|interface|public|private|protected|internal|inner|"
+ "constructor|this|super|open|override|final|abstract|enum|companion|"
+ "vararg|inline|reified|annotation|data|"
+ //"get|set|" // do not colorize as keyword because used as function
+ //"case|def|extends|forSome|implicit|lazy|" // unused java keywords
+ //"match|new|sealed|trait|type|with|yield|" // unused java keywords
+ /* boolean and null literals */
+ "false|true|null|"
+};
+
+/* numbers: hex, binary, L suffix for Long, f/F suffix for Float */
+/* escape keywords as identifiers with backticks: a.`if` */
+
+static const char kotlin_types[] = {
+ /* all mixed case identifiers starting with an uppercase letter are types
*/
+ "dynamic|"
+};
+
+static ModeDef kotlin_mode = {
+ .name = "Kotlin",
+ .extensions = "kt",
+ .colorize_func = c_colorize_line,
+ .colorize_flags = CLANG_KOTLIN | CLANG_CAP_TYPE,
+ .keywords = kotlin_keywords,
+ .types = kotlin_types,
+ .indent_func = c_indent_line,
+ .auto_indent = 1,
+ .fallback = &c_mode,
+};
+
static int c_init(void)
{
const char *p;
@@ -2221,6 +2256,7 @@
swift_init();
icon_init();
groovy_init();
+ qe_register_mode(&kotlin_mode, MODEF_SYNTAX);
return 0;
}