[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs extra-modes.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs extra-modes.c |
Date: |
Mon, 10 Mar 2014 22:07:35 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/03/10 22:07:35
Modified files:
. : extra-modes.c
Log message:
improve ruby mode
* use '\"' everywhere for consistency.
* improve HERE document syntax support, including <<"XXX" and <<'XXX'
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/extra-modes.c?cvsroot=qemacs&r1=1.5&r2=1.6
Patches:
Index: extra-modes.c
===================================================================
RCS file: /sources/qemacs/qemacs/extra-modes.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- extra-modes.c 10 Mar 2014 02:03:39 -0000 1.5
+++ extra-modes.c 10 Mar 2014 22:07:35 -0000 1.6
@@ -123,7 +123,7 @@
i = n;
continue;
case '\'':
- case '"':
+ case '\"':
/* parse string const */
for (j = i + 1; j < n; j++) {
if (str[j] == str[i]) {
@@ -262,7 +262,7 @@
SET_COLOR(str, i, n, BASIC_COMMENT);
i = n;
continue;
- case '"':
+ case '\"':
/* parse string const */
for (j = i + 1; j < n; j++) {
if (str[j] == str[i]) {
@@ -574,10 +574,10 @@
continue;
}
break;
- case '"':
+ case '\"':
/* parse string const */
for (j = i + 1; j < n; j++) {
- if (str[j] == '"') {
+ if (str[j] == '\"') {
j++;
break;
}
@@ -864,7 +864,7 @@
i = j;
continue;
case '\'':
- case '"':
+ case '\"':
case '`':
/* parse string const */
for (j = i + 1; j < n; j++) {
@@ -984,7 +984,7 @@
goto parse_string;
}
if (state & IN_STRING2) {
- sep = '"';
+ sep = '\"';
state = 0;
goto parse_string;
}
@@ -1004,7 +1004,7 @@
}
break;
case '\'':
- case '"':
+ case '\"':
/* parse string const */
sep = str[i];
j = i + 1;
@@ -1225,7 +1225,7 @@
continue;
case '\'':
- case '"':
+ case '\"':
/* parse string const */
sep = str[i];
j = i + 1;
@@ -1421,14 +1421,14 @@
continue;
case '\'':
- case '"':
+ case '\"':
/* parse string const */
j = i;
has_quote:
sep = str[j++];
if (str[j] == sep && str[j + 1] == sep) {
/* long string */
- state = (sep == '"') ? IN_LONG_STRING2 : IN_LONG_STRING;
+ state = (sep == '\"') ? IN_LONG_STRING2 : IN_LONG_STRING;
j += 2;
parse_long_string:
while (j < n) {
@@ -1445,7 +1445,7 @@
}
}
} else {
- state = (sep == '"') ? IN_STRING2 : IN_STRING;
+ state = (sep == '\"') ? IN_STRING2 : IN_STRING;
parse_string:
while (j < n) {
c = str[j++];
@@ -1624,6 +1624,11 @@
"|"
};
+/* Ruby operators:
+ * ` + - +@ -@ * / % << >> < <= > >= =
+ * == === <=> [] []= ** ! ~ != !~ =~ & | ^
+ */
+
#define IN_HEREDOC 0x80
#define IN_HD_INDENT 0x40
#define IN_HD_SIG 0x3f
@@ -1646,7 +1651,7 @@
RUBY_NUMBER = QE_STYLE_NUMBER,
RUBY_KEYWORD = QE_STYLE_KEYWORD,
RUBY_FUNCTION = QE_STYLE_FUNCTION,
- RUBY_VARIABLE = QE_STYLE_VARIABLE,
+ RUBY_MEMBER = QE_STYLE_VARIABLE,
RUBY_HEREDOC = QE_STYLE_PREPROCESS,
};
@@ -1682,9 +1687,12 @@
while (qe_isspace(str[j]))
j++;
}
- for (sig = 0; qe_isupper_(str[j]); j++) {
+ if (qe_isalpha_(str[j])) {
+ sig = str[j++] % 61;
+ for (; qe_isalnum_(str[j]); j++) {
sig = ((sig << 6) + str[j]) % 61;
}
+ }
for (; qe_isspace(str[j]); j++)
continue;
SET_COLOR(str, i, n, RUBY_HEREDOC);
@@ -1884,7 +1892,7 @@
i = j;
continue;
- case '"':
+ case '\"':
/* parse double quoted string const */
c = '\0';
j = i + 1;
@@ -1901,11 +1909,11 @@
while (j < n && str[j++] != '}')
continue;
} else
- if (c == '"') {
+ if (c == '\"') {
break;
}
}
- if (c == '"') {
+ if (c == '\"') {
if (state == IN_STRING2)
state = 0;
} else {
@@ -1927,13 +1935,27 @@
* space.
* XXX: should parse full here document syntax.
*/
+ sig = 0;
j = i + 2;
if (str[j] == '-') {
j++;
}
- for (sig = 0; qe_isupper_(str[j]); j++) {
+ if ((str[j] == '\'' || str[j] == '\"')
+ && qe_isalpha_(str[j + 1])) {
+ sep = str[j++];
+ sig = str[j++] % 61;
+ for (; qe_isalnum_(str[j]); j++) {
+ sig = ((sig << 6) + str[j]) % 61;
+ }
+ if (str[j++] != sep)
+ break;
+ } else
+ if (qe_isalpha_(str[j])) {
+ sig = str[j++] % 61;
+ for (; qe_isalnum_(str[j]); j++) {
sig = ((sig << 6) + str[j]) % 61;
}
+ }
if (sig) {
/* Multiple here documents can be specified on the
* same line, only the last one will prevail, which
@@ -1980,7 +2002,7 @@
case '@':
j = i + 1;
j += ruby_get_name(kbuf, countof(kbuf), str + j);
- SET_COLOR(str, i, j, RUBY_VARIABLE);
+ SET_COLOR(str, i, j, RUBY_MEMBER);
i = j;
continue;