fix go string highlighting
This commit is contained in:
parent
4b398798c0
commit
b9190d1e8d
1 changed files with 15 additions and 29 deletions
|
|
@ -5,7 +5,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var GolangHighlightRules = function() {
|
var GolangHighlightRules = function() {
|
||||||
var keywords = (
|
var keywords = (
|
||||||
"true|else|false|break|case|return|goto|if|const|" +
|
"else|break|case|return|goto|if|const|" +
|
||||||
"continue|struct|default|switch|for|" +
|
"continue|struct|default|switch|for|" +
|
||||||
"func|import|package|chan|defer|fallthrough|go|interface|map|range" +
|
"func|import|package|chan|defer|fallthrough|go|interface|map|range" +
|
||||||
"select|type|var"
|
"select|type|var"
|
||||||
|
|
@ -13,7 +13,6 @@ define(function(require, exports, module) {
|
||||||
var buildinConstants = ("nil|true|false|iota");
|
var buildinConstants = ("nil|true|false|iota");
|
||||||
|
|
||||||
var keywordMapper = this.createKeywordMapper({
|
var keywordMapper = this.createKeywordMapper({
|
||||||
"variable.language": "this",
|
|
||||||
"keyword": keywords,
|
"keyword": keywords,
|
||||||
"constant.language": buildinConstants
|
"constant.language": buildinConstants
|
||||||
}, "identifier");
|
}, "identifier");
|
||||||
|
|
@ -32,35 +31,29 @@ define(function(require, exports, module) {
|
||||||
}, {
|
}, {
|
||||||
token : "string", // single line
|
token : "string", // single line
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||||
}, {
|
|
||||||
token : "string", // multi line string start
|
|
||||||
regex : '["].*\\\\$',
|
|
||||||
next : "qqstring"
|
|
||||||
}, {
|
}, {
|
||||||
token : "string", // single line
|
token : "string", // single line
|
||||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
regex : '[`](?:[^`]*)[`]'
|
||||||
}, {
|
}, {
|
||||||
token : "string", // multi line string start
|
token : "string", // multi line string start
|
||||||
regex : "['].*\\\\$",
|
merge : true,
|
||||||
next : "qstring"
|
regex : '[`](?:[^`]*)$',
|
||||||
|
next : "bqstring"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // rune
|
||||||
|
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))[']"
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // hex
|
token : "constant.numeric", // hex
|
||||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // float
|
token : "constant.numeric", // float
|
||||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
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,
|
token : keywordMapper,
|
||||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator",
|
token : "keyword.operator",
|
||||||
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
|
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^="
|
||||||
}, {
|
}, {
|
||||||
token : "punctuation.operator",
|
token : "punctuation.operator",
|
||||||
regex : "\\?|\\:|\\,|\\;|\\."
|
regex : "\\?|\\:|\\,|\\;|\\."
|
||||||
|
|
@ -70,6 +63,9 @@ define(function(require, exports, module) {
|
||||||
}, {
|
}, {
|
||||||
token : "paren.rparen",
|
token : "paren.rparen",
|
||||||
regex : "[\\])}]"
|
regex : "[\\])}]"
|
||||||
|
}, {
|
||||||
|
token: "invalid",
|
||||||
|
regex: "\\s+$"
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
|
|
@ -85,20 +81,10 @@ define(function(require, exports, module) {
|
||||||
regex : ".+"
|
regex : ".+"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"qqstring" : [
|
"bqstring" : [
|
||||||
{
|
{
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
|
regex : '(?:[^`]*)`',
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
token : "string",
|
|
||||||
regex : '.+'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"qstring" : [
|
|
||||||
{
|
|
||||||
token : "string",
|
|
||||||
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
|
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
|
|
@ -109,7 +95,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||||
[ DocCommentHighlightRules.getEndRule("start") ]);
|
[ DocCommentHighlightRules.getEndRule("start") ]);
|
||||||
}
|
};
|
||||||
oop.inherits(GolangHighlightRules, TextHighlightRules);
|
oop.inherits(GolangHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
exports.GolangHighlightRules = GolangHighlightRules;
|
exports.GolangHighlightRules = GolangHighlightRules;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue