allowing capital B in binary literals; see #2021; thanks @BrendanEich

This commit is contained in:
Michael Ficarra 2012-01-12 13:21:29 -05:00
parent ff05575b78
commit 6d33a2e1a0
3 changed files with 3 additions and 2 deletions

View File

@ -113,7 +113,7 @@
if (!(match = NUMBER.exec(this.chunk))) return 0;
number = match[0];
lexedLength = number.length;
if (binaryLiteral = /0b([01]+)/.exec(number)) {
if (binaryLiteral = /0b([01]+)/i.exec(number)) {
number = (parseInt(binaryLiteral[1], 2)).toString();
}
this.token('NUMBER', number);

View File

@ -134,7 +134,7 @@ exports.Lexer = class Lexer
return 0 unless match = NUMBER.exec @chunk
number = match[0]
lexedLength = number.length
if binaryLiteral = /0b([01]+)/.exec number
if binaryLiteral = /0b([01]+)/i.exec number
number = (parseInt binaryLiteral[1], 2).toString()
@token 'NUMBER', number
lexedLength

View File

@ -15,6 +15,7 @@
test "Parser recognises binary numbers", ->
eq 4, 0b100
eq 5, 0B101
# Decimal Integer Literals