Skip to content

Commit

Permalink
Pass through octal and binary literals as-is
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Pánek authored and JimPanic committed Sep 26, 2016
1 parent 189dc2d commit 54f429b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,16 @@ exports.Lexer = class Lexer
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
@error "exponential notation in '#{number}' must be indicated with a lowercase 'e'",
offset: number.indexOf('E')
else if /^0\d*[89]/.test number
@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
switch
when /^0[BOX]/.test number
@error "radix prefix in '#{number}' must be lowercase", offset: 1
when /^(?!0x).*E/.test number
@error "exponential notation in '#{number}' must be indicated with a lowercase 'e'",
offset: number.indexOf('E')
when /^0\d*[89]/.test number
@error "decimal literal '#{number}' must not be prefixed with '0'", length: lexedLength
when /^0\d+/.test number
@error "octal literal '#{number}' must be prefixed with '0o'", length: lexedLength

numberValue = number

Expand Down

0 comments on commit 54f429b

Please sign in to comment.