making all postfix forms close out implicit calls, as in Ruby

This commit is contained in:
Jeremy Ashkenas
2010-01-24 23:56:27 -05:00
parent a5d39efdd2
commit 8d63d269b8
2 changed files with 8 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ module CoffeeScript
# Tokens pairs that, in immediate succession, indicate an implicit call.
IMPLICIT_FUNC = [:IDENTIFIER, :SUPER]
IMPLICIT_END = [:IF, :UNLESS, :FOR, :WHILE, "\n"]
IMPLICIT_CALL = [:IDENTIFIER, :NUMBER, :STRING, :JS, :REGEX, :NEW, :PARAM,
:TRY, :DELETE, :INSTANCEOF, :TYPEOF, :SWITCH, :ARGUMENTS,
:TRUE, :FALSE, :YES, :NO, :ON, :OFF, '!', '!!', :NOT]
@@ -153,7 +154,7 @@ module CoffeeScript
def add_implicit_parentheses
open = false
scan_tokens do |prev, token, post, i|
if open && token[0] == "\n"
if open && IMPLICIT_END.include?(token[0])
@tokens.insert(i, [')', Value.new(')', token[1].line)])
open = false
next 2