mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
allow leading newlines in coffee scripts
This commit is contained in:
@@ -35,6 +35,7 @@ module CoffeeScript
|
|||||||
def rewrite(tokens)
|
def rewrite(tokens)
|
||||||
@tokens = tokens
|
@tokens = tokens
|
||||||
adjust_comments
|
adjust_comments
|
||||||
|
remove_leading_newlines
|
||||||
remove_mid_expression_newlines
|
remove_mid_expression_newlines
|
||||||
move_commas_outside_outdents
|
move_commas_outside_outdents
|
||||||
add_implicit_indentation
|
add_implicit_indentation
|
||||||
@@ -82,6 +83,12 @@ module CoffeeScript
|
|||||||
end
|
end
|
||||||
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
|
# Some blocks occur in the middle of expressions -- when we're expecting
|
||||||
# this, remove their trailing newlines.
|
# this, remove their trailing newlines.
|
||||||
def remove_mid_expression_newlines
|
def remove_mid_expression_newlines
|
||||||
|
|||||||
Reference in New Issue
Block a user