Skip to content

Commit

Permalink
Remove unnecessary returns and use default parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
epidemian committed Feb 25, 2013
1 parent c39723c commit f609036
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 5 additions & 3 deletions lib/coffee-script/lexer.js

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

13 changes: 5 additions & 8 deletions src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -634,27 +634,24 @@ exports.Lexer = class Lexer
else
column += string.length

return [@chunkLine + lineCount, column]
[@chunkLine + lineCount, column]

# Same as "token", exception this just returns the token without adding it
# to the results.
makeToken: (tag, value, offsetInChunk, length) ->
offsetInChunk = offsetInChunk || 0
if length is undefined then length = value.length

makeToken: (tag, value, offsetInChunk = 0, length = value.length) ->
locationData = {}
[locationData.first_line, locationData.first_column] =
@getLineAndColumnFromChunk offsetInChunk

# Use length - 1 for the final offset - we're supplying the last_line and the last_column,
# so if last_column == first_column, then we're looking at a character of length 1.
lastCharacter = if length > 0 then (length - 1) else 0
lastCharacter = Math.max 0, length - 1
[locationData.last_line, locationData.last_column] =
@getLineAndColumnFromChunk offsetInChunk + (length - 1)

token = [tag, value, locationData]

return token
token

# Add a token to the results.
# `offset` is the offset into the current @chunk where the token starts.
Expand All @@ -665,7 +662,7 @@ exports.Lexer = class Lexer
token: (tag, value, offsetInChunk, length) ->
token = @makeToken tag, value, offsetInChunk, length
@tokens.push token
return token
token

# Peek at a tag in the current token stream.
tag: (index, tag) ->
Expand Down

0 comments on commit f609036

Please sign in to comment.