From 29597325d97f324442e76b9f2c36ceb013ba332e Mon Sep 17 00:00:00 2001 From: Victorien ELVINGER Date: Sat, 6 Dec 2014 19:50:52 +0100 Subject: [PATCH] Update Eiffel programming language definition. - Disable comments into strings - Enable concise form for real numbers - Enable juxtaposed digit separators - Check char and string content. --- lib/ace/mode/eiffel_highlight_rules.js | 67 ++++++++++++-------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/lib/ace/mode/eiffel_highlight_rules.js b/lib/ace/mode/eiffel_highlight_rules.js index f2cc8bd6..a95a4f37 100644 --- a/lib/ace/mode/eiffel_highlight_rules.js +++ b/lib/ace/mode/eiffel_highlight_rules.js @@ -39,7 +39,7 @@ var EiffelHighlightRules = function() { "class|convert|create|debug|deferred|detachable|do|else|elseif|end|" + "ensure|expanded|export|external|feature|from|frozen|if|inherit|" + "inspect|invariant|like|local|loop|not|note|obsolete|old|once|" + - "Precursor|redefine|rename|require|rescue|retry|select|separate|" + + "Precursor|redefine|rename|require|rescue|retry|select|separate|" + "some|then|undefine|until|variant|when"; var operatorKeywords = "and|implies|or|xor"; @@ -58,45 +58,44 @@ var EiffelHighlightRules = function() { "keyword": keywords }, "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 = { "start": [{ - token : "comment.line.double-dash", - regex : /--.*$/ - }, { - token : "string.quoted.double", - regex : /"(?:%"|[^%])*?"/ - }, { - token : "string.quoted.other", // "[ ]" aligned verbatim string + token : "string.quoted.other", // Aligned-verbatim-strings (verbatim option not supported) regex : /"\[/, 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 : /"\{/, 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", - 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 - regex : /(?:\d(?:_?\d)*\.|\.\d)(?:\d*[eE][+-]?\d+)?\b/ + token : "constant.numeric", // hexa | octal | bin + regex : /\b0(?:[xX][\da-fA-F](?:_*[\da-fA-F])*|[cC][0-7](?:_*[0-7])*|[bB][01](?:_*[01])*)\b/ }, { - token : "constant.numeric", // integer - regex : /\d(?:_?\d)*\b/ + token : "constant.numeric", + regex : /(?:(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*)|\d(?:_*\d)*\.?/ }, { - token : "constant.numeric", // hex - regex : /0[xX][a-fA-F\d](?:_?[a-fA-F\d])*\b/ + token : "paren.lparen", + regex : /[\[({]|<<|\|\(/ }, { - token : "constant.numeric", // octal - regex : /0[cC][0-7](?:_?[0-7])*\b/ - },{ - token : "constant.numeric", // bin - regex : /0[bB][01](?:_?[01])*\b/ - }, { - token : "keyword.operator", - regex : /\+|\-|\*|\/|\\\\|\/\/|\^|~|\/~|<|>|<=|>=|\/=|=|:=|\|\.\.\||\.\./ + token : "paren.rparen", + regex : /[\])}]|>>|\|\)/ }, { token : "keyword.operator", // punctuation - regex : /\.|:|,|;\b/ + regex : /:=|->|\.(?=\w)|[;,:?]/ + }, { + token : "keyword.operator", + regex : /\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/ }, { token : function (v) { var result = keywordMapper (v); @@ -106,33 +105,27 @@ var EiffelHighlightRules = function() { return result; }, regex : /[a-zA-Z][a-zA-Z\d_]*\b/ - }, { - token : "paren.lparen", - regex : /[\[({]/ - }, { - token : "paren.rparen", - regex : /[\])}]/ }, { token : "text", regex : /\s+/ } ], "aligned_verbatim_string" : [{ - token : "string", // closing multi-line comment + token : "string", regex : /]"/, next : "start" }, { - token : "string", // comment spanning whole line - regex : /[^(?:\]")]+/ + token : "string", + regex : simpleString } ], "non-aligned_verbatim_string" : [{ - token : "string.quoted.other", // closing multi-line comment + token : "string.quoted.other", regex : /}"/, next : "start" }, { - token : "string.quoted.other", // comment spanning whole line - regex : /[^(?:\}")]+/ + token : "string.quoted.other", + regex : simpleString } ]}; };