qemacs-commit
[Top][All Lists]
Advanced

[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: Tue, 04 Aug 2015 17:14:30 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        15/08/04 17:14:30

Modified files:
        .              : clang.c 

Log message:
        simplify and improve java support
        
        - parse @annotations generically
        - assume all words with an initial capital and at least one lowercase 
letter
          are type names.
        - colorize shebang line as preprocessor

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.89&r2=1.90

Patches:
Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -b -r1.89 -r1.90
--- clang.c     28 Jul 2015 19:03:24 -0000      1.89
+++ clang.c     4 Aug 2015 17:14:29 -0000       1.90
@@ -142,15 +142,10 @@
     "this|throw|throws|transient|try|volatile|while|"
     /* boolean and null literals */
     "false|null|true|"
-    /* other stuff */
-    "@Override|@SuppressWarnings|@Deprecated|"
-    //"function|in|instanceof|var|with|"
 };
 
 static const char java_types[] = {
     "boolean|byte|char|double|float|int|long|short|void|"
-    "String|Object|List|Set|Exception|Thread|Class|HashMap|Integer|"
-    "Collection|Block|"
 };
 
 static const char scala_keywords[] = {
@@ -161,14 +156,10 @@
     "trait|try|type|val|var|while|with|yield|"
     /* boolean and null literals */
     "false|null|true|_|"
-    /* other stuff */
-    "@serializable|@suspendable|@specialized|@inline|@deprecated|@tailrec|"
 };
 
 static const char scala_types[] = {
-    /* all identifiers starting with an uppercase letter are types */
-    //"Boolean|Byte|Char|Double|Float|Int|Integer|Long|Short|String|Unit|"
-    //"Comparable|Iterator|Iterable|List|Object|Nothing|Any|Set|"
+    /* all mixed case identifiers starting with an uppercase letter are types 
*/
 };
 
 static const char css_keywords[] = {
@@ -567,6 +558,13 @@
     return i;
 }
 
+static int qe_haslower(const char *str) {
+    while (*str) {
+        if (qe_islower(*str++)) return 1;
+    }
+    return 0;
+}
+
 enum {
     C_STYLE_DEFAULT    = 0,
     C_STYLE_PREPROCESS = QE_STYLE_PREPROCESS,
@@ -755,6 +753,13 @@
             }
             break;
         case '#':       /* preprocessor */
+            if (start == 0 && str[i] == '!') {
+                /* recognize a shebang comment line */
+                style = style0 = C_STYLE_PREPROCESS;
+                i = n;
+                SET_COLOR(str, start, i, C_STYLE_PREPROCESS);
+                break;
+            }
             if (mode_flags & CLANG_PREPROC) {
                 state = IN_C_PREPROCESS;
                 style = style0 = C_STYLE_PREPROCESS;
@@ -868,6 +873,14 @@
                     continue;
                 }
             }
+            if ((flavor == CLANG_JAVA || flavor == CLANG_SCALA) && 
qe_isalpha(str[i])) {
+                /* Java annotations */
+                while (qe_isalnum_(str[i]) || str[i] == '.')
+                    i++;
+                if (start == 0 || str[start - 1] != '.')
+                    SET_COLOR(str, start, i, C_STYLE_PREPROCESS);
+                continue;
+            }
             goto normal;
 
         case '\"':      /* string literal */
@@ -960,8 +973,7 @@
 
                 if (strfind(syn->keywords, kbuf)
                 ||  ((mode_flags & CLANG_CC) && strfind(c_keywords, kbuf))
-                ||  ((flavor == CLANG_CSS) && str[i] == ':')
-                   ) {
+                ||  ((flavor == CLANG_CSS) && str[i] == ':')) {
                     SET_COLOR(str, start, i, C_STYLE_KEYWORD);
                     continue;
                 }
@@ -979,9 +991,9 @@
                 ||   ((mode_flags & CLANG_CC) && strfind(c_types, kbuf))
                 ||   (((mode_flags & CLANG_CC) || (flavor == CLANG_D)) &&
                      strend(kbuf, "_t", NULL))
-                ||   (flavor == CLANG_SCALA && qe_isupper(kbuf[0]))
-                ||   (flavor == CLANG_HAXE && qe_isupper(kbuf[0]) &&
-                      qe_islower(kbuf[1]) && 
+                ||   ((flavor == CLANG_JAVA || flavor == CLANG_SCALA) &&
+                      qe_isupper(c) && qe_haslower(kbuf))
+                ||   (flavor == CLANG_HAXE && qe_isupper(c) && 
qe_haslower(kbuf) &&
                       (start == 0 || !qe_findchar("(", str[start - 1]))))) {
                     /* if not cast, assume type declaration */
                     if (str[i2] != ')') {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]