more progress

This commit is contained in:
sevin7676 2015-04-17 10:00:13 -04:00
commit 76ac79f116

View file

@ -43,8 +43,8 @@ var SqlServerHighlightRules = function() {
* Once I'm certain that this is not missing anything it can be 'compiled' into a cleaner/faster format that is not executing stuff on the fly for no reason. * Once I'm certain that this is not missing anything it can be 'compiled' into a cleaner/faster format that is not executing stuff on the fly for no reason.
*/ */
// some of these are other types but I want sytanx highlighting to match SSMS // https://msdn.microsoft.com/en-us/library/ms189773.aspx
var builtinConstants = "TRUE|FALSE|NULL|IS|IN"; var logicalOperators = "ALL|AND|ANY|BETWEEN|EXISTS|IN|LIKE|NOT|OR|SOME";
// multiple pages for built in functions, the following code works for all // multiple pages for built in functions, the following code works for all
@ -115,7 +115,7 @@ var SqlServerHighlightRules = function() {
//remove any other built in things from key word list //remove any other built in things from key word list
keywords = keywords.split('|'); keywords = keywords.split('|');
keywords = keywords.filter(function(value, index, self) { keywords = keywords.filter(function(value, index, self) {
return builtinConstants.split('|').indexOf(value) === -1 && builtinFunctions.split('|').indexOf(value) === -1 && dataTypes.split('|').indexOf(value) === -1; return logicalOperators.split('|').indexOf(value) === -1 && builtinFunctions.split('|').indexOf(value) === -1 && dataTypes.split('|').indexOf(value) === -1;
}); });
keywords = keywords.sort().join('|'); keywords = keywords.sort().join('|');
@ -123,7 +123,7 @@ var SqlServerHighlightRules = function() {
"support.function": builtinFunctions, "support.function": builtinFunctions,
"keyword": keywords, "keyword": keywords,
"keyword.set": setStatements, "keyword.set": setStatements,
"constant.language": builtinConstants, "constant.language": logicalOperators,
"storage.type": dataTypes "storage.type": dataTypes
}, "identifier", true); }, "identifier", true);
@ -135,43 +135,44 @@ var SqlServerHighlightRules = function() {
} }
this.$rules = { this.$rules = {
"start" : [ { "start": [{
token : "comment", token: "comment",
regex : "--.*$" regex: "--.*$"
}, {
token : "comment",
start : "/\\*",
end : "\\*/"
}, { }, {
token : "string", // " string token: "comment",
regex : '".*?"' start: "/\\*",
end: "\\*/"
}, { }, {
token : "string", // ' string token: "string", // " string
regex : "'.*?'" regex: '".*?"'
}, { }, {
token : "constant.numeric", // float token: "string", // ' string
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex: "'.*?'"
}, { }, {
token : keywordMapper, token: "constant.numeric", // float
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token: keywordMapper,
regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b" //up to 2 @symbols for some build in functions
}, {
token: "constant.class",
regex: "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
//https://msdn.microsoft.com/en-us/library/ms174986.aspx
token: "keyword.operator",
regex: "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
}, {
token: "paren.lparen",
regex: "[\\(]"
}, {
token: "paren.rparen",
regex: "[\\)]"
} }
/* this works to make variables designated with @ symbol show as a single token... but it screws up built in functions that start with @ symbol /*, {
, { token : "text",
token : "constant.class", regex : "\\s+"
regex : "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }*/
}*/, { ]
token : "keyword.operator",
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
}, {
token : "paren.lparen",
regex : "[\\(]"
}, {
token : "paren.rparen",
regex : "[\\)]"
}, {
token : "text",
regex : "\\s+"
} ]
}; };
this.normalizeRules(); this.normalizeRules();
}; };