mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
allow leading newlines in coffee scripts
This commit is contained in:
parent
9a61bbf005
commit
27f7ef09af
1 changed files with 7 additions and 0 deletions
|
@ -35,6 +35,7 @@ module CoffeeScript
|
|||
def rewrite(tokens)
|
||||
@tokens = tokens
|
||||
adjust_comments
|
||||
remove_leading_newlines
|
||||
remove_mid_expression_newlines
|
||||
move_commas_outside_outdents
|
||||
add_implicit_indentation
|
||||
|
@ -82,6 +83,12 @@ module CoffeeScript
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue