Skip to content

Commit

Permalink
Octal and binary literals are more appropriately converted to hex
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Mar 28, 2012
1 parent 6a88ce7 commit 22db7ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/coffee-script/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ exports.Lexer = class Lexer
else if /^0\d+/.test number
@error "octal literal '#{number}' must be prefixed with '0o'"
lexedLength = number.length
if octalLiteral = /0o([0-7]+)/.exec number
number = (parseInt octalLiteral[1], 8).toString()
if binaryLiteral = /0b([01]+)/.exec number
number = (parseInt binaryLiteral[1], 2).toString()
if octalLiteral = /^0o([0-7]+)/.exec number
number = '0x' + (parseInt octalLiteral[1], 8).toString 16
if binaryLiteral = /^0b([01]+)/.exec number
number = '0x' + (parseInt binaryLiteral[1], 2).toString 16
@token 'NUMBER', number
lexedLength

Expand Down

0 comments on commit 22db7ae

Please sign in to comment.