@@ -634,27 +634,24 @@ exports.Lexer = class Lexer
634
634
else
635
635
column += string .length
636
636
637
- return [@chunkLine + lineCount, column]
637
+ [@chunkLine + lineCount, column]
638
638
639
639
# Same as "token", exception this just returns the token without adding it
640
640
# to the results.
641
- makeToken : (tag , value , offsetInChunk , length ) ->
642
- offsetInChunk = offsetInChunk || 0
643
- if length is undefined then length = value .length
644
-
641
+ makeToken : (tag , value , offsetInChunk = 0 , length = value .length ) ->
645
642
locationData = {}
646
643
[locationData .first_line , locationData .first_column ] =
647
644
@ getLineAndColumnFromChunk offsetInChunk
648
645
649
646
# Use length - 1 for the final offset - we're supplying the last_line and the last_column,
650
647
# so if last_column == first_column, then we're looking at a character of length 1.
651
- lastCharacter = if length > 0 then ( length - 1 ) else 0
648
+ lastCharacter = Math . max 0 , length - 1
652
649
[locationData .last_line , locationData .last_column ] =
653
650
@ getLineAndColumnFromChunk offsetInChunk + (length - 1 )
654
651
655
652
token = [tag, value, locationData]
656
653
657
- return token
654
+ token
658
655
659
656
# Add a token to the results.
660
657
# `offset` is the offset into the current @chunk where the token starts.
@@ -665,7 +662,7 @@ exports.Lexer = class Lexer
665
662
token : (tag , value , offsetInChunk , length ) ->
666
663
token = @ makeToken tag, value, offsetInChunk, length
667
664
@tokens .push token
668
- return token
665
+ token
669
666
670
667
# Peek at a tag in the current token stream.
671
668
tag : (index , tag ) ->
0 commit comments