Skip to content

Commit

Permalink
allow leading newlines in coffee scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Jan 12, 2010
1 parent 9a61bbf commit 27f7ef0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/coffee_script/rewriter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Rewriter
def rewrite(tokens)
@tokens = tokens
adjust_comments
remove_leading_newlines
remove_mid_expression_newlines
move_commas_outside_outdents
add_implicit_indentation
Expand Down Expand Up @@ -82,6 +83,12 @@ def adjust_comments
end
end

# Leading newlines would introduce an ambiguity in the grammar, so we
# dispatch them here.
def remove_leading_newlines
@tokens.shift if @tokens[0][0] == "\n"
end

# Some blocks occur in the middle of expressions -- when we're expecting
# this, remove their trailing newlines.
def remove_mid_expression_newlines
Expand Down

0 comments on commit 27f7ef0

Please sign in to comment.