qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.h clang.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.h clang.c
Date: Tue, 20 May 2014 04:48:36 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        14/05/20 04:48:36

Modified files:
        .              : qe.h clang.c 

Log message:
        add coorizer for Pike language

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.173&r2=1.174
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.66&r2=1.67

Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -b -r1.173 -r1.174
--- qe.h        19 May 2014 19:11:43 -0000      1.173
+++ qe.h        20 May 2014 04:48:36 -0000      1.174
@@ -1963,7 +1963,7 @@
 
 /* C mode flavors */
 enum {
-    CLANG_SYNTAX,
+    CLANG_GENERIC,
     CLANG_C,
     CLANG_CPP,
     CLANG_OBJC,
@@ -1983,6 +1983,7 @@
     CLANG_JSX,
     CLANG_HAXE,
     CLANG_DART,
+    CLANG_PIKE,
     CLANG_FLAVOR = 0x1F,
 };
 

Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- clang.c     19 May 2014 19:11:44 -0000      1.66
+++ clang.c     20 May 2014 04:48:36 -0000      1.67
@@ -301,12 +301,25 @@
 
 static const char dart_types[] = {
     "bool|double|dynamic|int|num|var|void|"
-    
"String|StringBuffer|Object|RegExp|Date|DateTime|TimeZone|Duration|Stopwatch|DartType|"
-    "Collection|Comparable|Completer|Function|Future|Match|Options|Pattern|"
+    "String|StringBuffer|Object|RegExp|Function|"
+    "Date|DateTime|TimeZone|Duration|Stopwatch|DartType|"
+    "Collection|Comparable|Completer|Future|Match|Options|Pattern|"
     "HashMap|HashSet|Iterable|Iterator|LinkedHashMap|List|Map|Queue|Set|"
     "Dynamic|Exception|Error|AssertionError|TypeError|FallThroughError|" 
 };
 
+static const char pike_keywords[] = {
+    "break|case|catch|class|constant|continue|default|do|else|enum|extern|"
+    "final|for|foreach|function|gauge|global|if|import|inherit|inline|"
+    "lambda|local|mapping|multiset|nomask|optional|program|predef|"
+    "private|protected|public|return|sscanf|static|switch|typedef|typeof|"
+    "while|__attribute__|__deprecated__|__func__|"
+};
+
+static const char pike_types[] = {
+    "array|float|int|mixed|object|string|variant|void|"
+};
+
 struct QEModeFlavor {
     const char *keywords;
     const char *types;
@@ -331,11 +344,12 @@
     { jsx_keywords,      jsx_types },      /* CLANG_JSX */
     { haxe_keywords,     haxe_types },     /* CLANG_HAXE */
     { dart_keywords,     dart_types },     /* CLANG_DART */
+    { pike_keywords,     pike_types },     /* CLANG_PIKE */
 };
 
 static const char c_mode_extensions[] = {
     "c|h|i|C|H|I|"      /* C language */
-    "y|l|lex|"          /* yacc, lex */
+    "y|yacc|l|lex|"     /* yacc, lex */
     "cc|hh|cpp|hpp|cxx|hxx|CPP|CC|c++|"   /* C++ */
     "m|mm|"             /* Objective-C, Limbo */
     "cs|"               /* C Sharp */
@@ -346,6 +360,7 @@
     "jsx|"              /* JSX (extended Javascript) */
     "hx|"               /* Haxe (extended Javascript) */
     "dart|"             /* Dart (extended Javascript) */
+    "pike|"             /* Pike */
     "go|"               /* Go language */
     "d|di|"             /* D language */
     "cyc|cyl|cys|"      /* Cyclone language */
@@ -365,14 +380,15 @@
 /* grab a C identifier from a uint buf, stripping color.
  * return char count.
  */
-static int get_c_identifier(char *buf, int buf_size, unsigned int *p, int 
flavor)
+static int get_c_identifier(char *buf, int buf_size, unsigned int *p,
+                            int flavor)
 {
     unsigned int c;
     int i, j;
 
     i = j = 0;
     c = p[i] & CHAR_MASK;
-    if (qe_isalpha_(c) || c == '$' || c == '@') {
+    if (qe_isalpha_(c) || c == '$' || (c == '@' && flavor != CLANG_PIKE)) {
         for (;;) {
             if (j < buf_size - 1)
                 buf[j++] = c;
@@ -592,6 +608,14 @@
                 SET_COLOR(str, start, i, C_STYLE_PREPROCESS);
                 continue;
             }
+            if (flavor == CLANG_PIKE) {
+                if (str[i] == '\"') {
+                    i++;
+                    goto parse_string;
+                }
+                state = IN_C_PREPROCESS;
+                style = style0 = C_STYLE_PREPROCESS;
+            }
             break;
         case 'L':       /* wide character and string literals */
             if (mode_flags & CLANG_CC) {
@@ -720,7 +744,7 @@
                 SET_COLOR(str, start, i, C_STYLE_NUMBER);
                 continue;
             }
-            if (qe_isalpha_(c) || c == '$' || c == '@') {
+            if (qe_isalpha_(c) || c == '$' || (c == '@' && flavor != 
CLANG_PIKE)) {
                 /* XXX: should support :: */
                 klen = get_c_identifier(kbuf, countof(kbuf), str + start, 
flavor);
                 i = start + klen;
@@ -741,7 +765,7 @@
                     i2++;
 
                 if ((start == 0 || str[start - 1] != '.')
-                &&  !qe_findchar(".(:", str[i])
+                &&  (!qe_findchar(".(:", str[i]) || flavor == CLANG_PIKE)
                 &&  ((types && strfind(types, kbuf))
                 ||   ((mode_flags & CLANG_CC) && strfind(c_types, kbuf))
                 ||   (((mode_flags & CLANG_CC) || (flavor == CLANG_D)) &&
@@ -754,7 +778,7 @@
                         type_decl = 1;
                     }
                     style1 = C_STYLE_TYPE;
-                    if (str[i1] == '(') {
+                    if (str[i1] == '(' && flavor != CLANG_PIKE) {
                         /* function style cast */
                         style1 = C_STYLE_KEYWORD;
                     }
@@ -1325,7 +1349,7 @@
     if (match_extension(base, "c|h|i|C|H|I")) {
         s->mode_flags = CLANG_C | CLANG_CC;
     } else
-    if (match_extension(base, "y")) {
+    if (match_extension(base, "y|yacc")) {
         s->mode_name = "Yacc";
         s->mode_flags = CLANG_C | CLANG_CC | CLANG_YACC;
     } else
@@ -1344,6 +1368,7 @@
     if (match_extension(base, "m|mm")) {
         int offset = 0;
         if (eb_nextc(s->b, offset, &offset) == '/') {
+            // XXX: should also check for #import
             s->mode_name = "ObjC";
             s->mode_flags = CLANG_OBJC | CLANG_CC;
         } else {
@@ -1379,6 +1404,10 @@
         s->mode_name = "Dart";
         s->mode_flags = CLANG_DART;
     } else
+    if (match_extension(base, "pike")) {
+        s->mode_name = "Pike";
+        s->mode_flags = CLANG_PIKE;
+    } else
     if (match_extension(base, "go")) {
         s->mode_name = "Go";
         s->mode_flags = CLANG_GO;



reply via email to

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