fix go string highlighting

This commit is contained in:
nightwing 2013-06-23 22:25:50 +04:00
commit b9190d1e8d

View file

@ -5,7 +5,7 @@ define(function(require, exports, module) {
var GolangHighlightRules = function() {
var keywords = (
"true|else|false|break|case|return|goto|if|const|" +
"else|break|case|return|goto|if|const|" +
"continue|struct|default|switch|for|" +
"func|import|package|chan|defer|fallthrough|go|interface|map|range" +
"select|type|var"
@ -13,7 +13,6 @@ define(function(require, exports, module) {
var buildinConstants = ("nil|true|false|iota");
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"constant.language": buildinConstants
}, "identifier");
@ -32,35 +31,29 @@ define(function(require, exports, module) {
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
regex : '[`](?:[^`]*)[`]'
}, {
token : "string", // multi line string start
regex : "['].*\\\\$",
next : "qstring"
merge : true,
regex : '[`](?:[^`]*)$',
next : "bqstring"
}, {
token : "constant.numeric", // rune
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant", // <CONSTANT>
regex : "<[a-zA-Z0-9.]+>"
}, {
token : "keyword", // pre-compiler directivs
regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
}, {
token : keywordMapper,
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^="
}, {
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\."
@ -70,6 +63,9 @@ define(function(require, exports, module) {
}, {
token : "paren.rparen",
regex : "[\\])}]"
}, {
token: "invalid",
regex: "\\s+$"
}, {
token : "text",
regex : "\\s+"
@ -85,20 +81,10 @@ define(function(require, exports, module) {
regex : ".+"
}
],
"qqstring" : [
"bqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
regex : '(?:[^`]*)`',
next : "start"
}, {
token : "string",
@ -109,7 +95,7 @@ define(function(require, exports, module) {
this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]);
}
};
oop.inherits(GolangHighlightRules, TextHighlightRules);
exports.GolangHighlightRules = GolangHighlightRules;