improvement to comment handling that should ensure that they have no effect on indentation

This commit is contained in:
Jeremy Ashkenas
2010-03-02 19:23:21 -05:00
parent 70cb195e6f
commit 5fd0972b5d
6 changed files with 39 additions and 32 deletions

View File

@@ -134,8 +134,8 @@ exports.Lexer: class Lexer
return if @string_token()
return if @js_token()
return if @regex_token()
return if @line_token()
return if @comment_token()
return if @line_token()
return if @whitespace_token()
return @literal_token()
@@ -199,7 +199,8 @@ exports.Lexer: class Lexer
comment_token: ->
return false unless comment: @match COMMENT, 1
@line += (comment.match(MULTILINER) or []).length
@token 'COMMENT', comment.replace(COMMENT_CLEANER, '').split(MULTILINER)
lines: comment.replace(COMMENT_CLEANER, '').split(MULTILINER)
@token 'COMMENT', compact lines
@token 'TERMINATOR', "\n"
@i += comment.length
true
@@ -375,6 +376,9 @@ exports.Lexer: class Lexer
include: (list, value) ->
list.indexOf(value) >= 0
# Trim out all falsy values from an array.
compact: (array) -> item for item in array when item
# Count the number of occurences of a character in a string.
count: (string, letter) ->
num: 0