improve matlab highlighting fixes #2042, #2043

This commit is contained in:
nightwing 2014-09-07 17:21:36 +04:00
commit e6660cd47c
2 changed files with 87 additions and 13 deletions

View file

@ -1 +1,17 @@
TODO %{
%{
Ace Matlab demo
%}
%}
classdef hello
methods
function greet(this)
disp('Hello!') % say hi
end
end
end
% transpose
a = [ 'x''y', "x\n\
y", 1' ]' + 2'

View file

@ -164,15 +164,53 @@ var keywords = (
}, "identifier", true); }, "identifier", true);
this.$rules = { this.$rules = {
"start" : [ { // allowQstring
start: [{
token : "string",
regex : "'",
stateName : "qstring",
next : [{
token : "constant.language.escape",
regex : "''"
}, {
token : "string",
regex : "'|$",
next : "start"
}, {
defaultToken: "string"
}]
}, {
token : "text",
regex : "\\s+"
}, {
regex: "",
next: "noQstring"
}],
noQstring : [{
regex: "^\\s*%{\\s*$",
token: "comment.start",
push: "blockComment"
}, {
token : "comment", token : "comment",
regex : "%[^\r\n]*" regex : "%[^\r\n]*"
}, { }, {
token : "string", // " string token : "string",
regex : '".*?"' regex : '"',
}, { stateName : "qqstring",
token : "string", // ' string next : [{
regex : "'.*?'" token : "constant.language.escape",
regex : /\\./
}, {
token : "string",
regex : "\\\\$",
next : "qqstring"
}, {
token : "string",
regex : '"|$',
next : "start"
}, {
defaultToken: "string"
}]
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
@ -181,21 +219,41 @@ var keywords = (
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 : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=",
next: "start"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\." regex : "\\?|\\:|\\,|\\;|\\.",
next: "start"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[\\(]" regex : "[({\\[]",
next: "start"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\)]" regex : "[\\]})]"
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
} ] }, {
token : "text",
regex : "$",
next : "start"
}],
blockComment: [{
regex: "^\\s*%{\\s*$",
token: "comment.start",
push: "blockComment"
}, {
regex: "^\\s*%}\\s*$",
token: "comment.end",
next: "pop"
}, {
defaultToken: "comment"
}],
}; };
this.normalizeRules();
}; };
oop.inherits(MatlabHighlightRules, TextHighlightRules); oop.inherits(MatlabHighlightRules, TextHighlightRules);