diff --git a/src/lexer.coffee b/src/lexer.coffee index e0d3febd9b..19a86436f5 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -191,8 +191,10 @@ exports.Lexer = class Lexer # Be careful not to interfere with ranges-in-progress. numberToken: -> return 0 unless match = NUMBER.exec @chunk + number = match[0] lexedLength = number.length + if /^0[BOX]/.test number @error "radix prefix in '#{number}' must be lowercase", offset: 1 else if /E/.test(number) and not /^0x/.test number @@ -202,14 +204,12 @@ exports.Lexer = class Lexer @error "decimal literal '#{number}' must not be prefixed with '0'", length: lexedLength else if /^0\d+/.test number @error "octal literal '#{number}' must be prefixed with '0o'", length: lexedLength - if octalLiteral = /^0o([0-7]+)/.exec number - numberValue = parseInt(octalLiteral[1], 8) - number = "0x#{numberValue.toString 16}" - else if binaryLiteral = /^0b([01]+)/.exec number - numberValue = parseInt(binaryLiteral[1], 2) - number = "0x#{numberValue.toString 16}" - else + + numberValue = number + + unless /^(0o[0-7]+)/.test(number) or /^(0b[01]+)/.test(number) numberValue = parseFloat(number) + tag = if numberValue is Infinity then 'INFINITY' else 'NUMBER' @token tag, number, 0, lexedLength lexedLength