mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
allowing capital B in binary literals; see #2021; thanks @BrendanEich
This commit is contained in:
parent
ff05575b78
commit
6d33a2e1a0
3 changed files with 3 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
test "Parser recognises binary numbers", ->
|
||||
eq 4, 0b100
|
||||
eq 5, 0B101
|
||||
|
||||
# Decimal Integer Literals
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue