highlight Ruby floats with underscores

This commit is contained in:
misfo 2011-07-22 08:02:32 -05:00
commit d632427880
2 changed files with 8 additions and 1 deletions

View file

@ -131,7 +131,7 @@ var RubyHighlightRules = function() {
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"

View file

@ -59,6 +59,13 @@ module.exports = {
assertInvalidTokens(this.tokenizer, "string",
[":", ":@", ":$", ":1", ":1thing", ":th?ing", ":thi=ng", ":1thing",
":th!ing", ":thing#"]);
},
"test: float tokenizer" : function() {
assertValidTokens(this.tokenizer, "constant.numeric",
["1", "+1", "-1", "12_345", "0.000_1"]);
assertInvalidTokens(this.tokenizer, "constant.numeric",
["_", "_1", "1_", "1_.0", "0._1"]);
}
};