highlight Ruby hexidecimals with underscores

This commit is contained in:
misfo 2011-07-22 08:03:34 -05:00
commit bea1c05001
2 changed files with 8 additions and 1 deletions

View file

@ -128,7 +128,7 @@ var RubyHighlightRules = function() {
regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"

View file

@ -61,6 +61,13 @@ module.exports = {
":th!ing", ":thing#"]);
},
"test: hex tokenizer" : function() {
assertValidTokens(this.tokenizer, "constant.numeric",
["0x9a", "0XA1", "0x9_a"]);
assertInvalidTokens(this.tokenizer, "constant.numeric",
["0x", "0x_9a", "0x9a_"]);
},
"test: float tokenizer" : function() {
assertValidTokens(this.tokenizer, "constant.numeric",
["1", "+1", "-1", "12_345", "0.000_1"]);