Update Eiffel programming language definition.

- Disable comments into strings
- Enable concise form for real numbers
- Enable juxtaposed digit separators
- Check char and string content.
This commit is contained in:
Victorien ELVINGER 2014-12-06 19:50:52 +01:00
commit 29597325d9

View file

@ -58,45 +58,44 @@ var EiffelHighlightRules = function() {
"keyword": keywords "keyword": keywords
}, "identifier", true); }, "identifier", true);
var simpleString = /(?:[^"%\b\f\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)+?/;
this.$rules = { this.$rules = {
"start": [{ "start": [{
token : "comment.line.double-dash", token : "string.quoted.other", // Aligned-verbatim-strings (verbatim option not supported)
regex : /--.*$/
}, {
token : "string.quoted.double",
regex : /"(?:%"|[^%])*?"/
}, {
token : "string.quoted.other", // "[ ]" aligned verbatim string
regex : /"\[/, regex : /"\[/,
next: "aligned_verbatim_string" next: "aligned_verbatim_string"
}, { }, {
token : "string.quoted.other", // "{ }" non-aligned verbatim string token : "string.quoted.other", // Non-aligned-verbatim-strings (verbatim option not supported)
regex : /"\{/, regex : /"\{/,
next: "non-aligned_verbatim_string" next: "non-aligned_verbatim_string"
}, {
token : "string.quoted.double",
regex : /"(?:[^%\b\f\n\r\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)*?"/
}, {
token : "comment.line.double-dash",
regex : /--.*/
}, { }, {
token : "constant.character", token : "constant.character",
regex : /'(?:%%|%T|%R|%N|%F|%'|[^%])'/ regex : /'(?:[^%\b\f\n\r\t\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)'/
}, { }, {
token : "constant.numeric", // real token : "constant.numeric", // hexa | octal | bin
regex : /(?:\d(?:_?\d)*\.|\.\d)(?:\d*[eE][+-]?\d+)?\b/ regex : /\b0(?:[xX][\da-fA-F](?:_*[\da-fA-F])*|[cC][0-7](?:_*[0-7])*|[bB][01](?:_*[01])*)\b/
}, { }, {
token : "constant.numeric", // integer token : "constant.numeric",
regex : /\d(?:_?\d)*\b/ regex : /(?:(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*)|\d(?:_*\d)*\.?/
}, { }, {
token : "constant.numeric", // hex token : "paren.lparen",
regex : /0[xX][a-fA-F\d](?:_?[a-fA-F\d])*\b/ regex : /[\[({]|<<|\|\(/
}, { }, {
token : "constant.numeric", // octal token : "paren.rparen",
regex : /0[cC][0-7](?:_?[0-7])*\b/ regex : /[\])}]|>>|\|\)/
},{
token : "constant.numeric", // bin
regex : /0[bB][01](?:_?[01])*\b/
}, {
token : "keyword.operator",
regex : /\+|\-|\*|\/|\\\\|\/\/|\^|~|\/~|<|>|<=|>=|\/=|=|:=|\|\.\.\||\.\./
}, { }, {
token : "keyword.operator", // punctuation token : "keyword.operator", // punctuation
regex : /\.|:|,|;\b/ regex : /:=|->|\.(?=\w)|[;,:?]/
}, {
token : "keyword.operator",
regex : /\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/
}, { }, {
token : function (v) { token : function (v) {
var result = keywordMapper (v); var result = keywordMapper (v);
@ -106,33 +105,27 @@ var EiffelHighlightRules = function() {
return result; return result;
}, },
regex : /[a-zA-Z][a-zA-Z\d_]*\b/ regex : /[a-zA-Z][a-zA-Z\d_]*\b/
}, {
token : "paren.lparen",
regex : /[\[({]/
}, {
token : "paren.rparen",
regex : /[\])}]/
}, { }, {
token : "text", token : "text",
regex : /\s+/ regex : /\s+/
} }
], ],
"aligned_verbatim_string" : [{ "aligned_verbatim_string" : [{
token : "string", // closing multi-line comment token : "string",
regex : /]"/, regex : /]"/,
next : "start" next : "start"
}, { }, {
token : "string", // comment spanning whole line token : "string",
regex : /[^(?:\]")]+/ regex : simpleString
} }
], ],
"non-aligned_verbatim_string" : [{ "non-aligned_verbatim_string" : [{
token : "string.quoted.other", // closing multi-line comment token : "string.quoted.other",
regex : /}"/, regex : /}"/,
next : "start" next : "start"
}, { }, {
token : "string.quoted.other", // comment spanning whole line token : "string.quoted.other",
regex : /[^(?:\}")]+/ regex : simpleString
} }
]}; ]};
}; };