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);
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",
regex : "%[^\r\n]*"
}, {
token : "string", // " string
regex : '".*?"'
}, {
token : "string", // ' string
regex : "'.*?'"
token : "string",
regex : '"',
stateName : "qqstring",
next : [{
token : "constant.language.escape",
regex : /\\./
}, {
token : "string",
regex : "\\\\$",
next : "qqstring"
}, {
token : "string",
regex : '"|$',
next : "start"
}, {
defaultToken: "string"
}]
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
@ -181,21 +219,41 @@ var keywords = (
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=",
next: "start"
}, {
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\."
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.",
next: "start"
}, {
token : "paren.lparen",
regex : "[\\(]"
regex : "[({\\[]",
next: "start"
}, {
token : "paren.rparen",
regex : "[\\)]"
regex : "[\\]})]"
}, {
token : "text",
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);