making all postfix forms close out implicit calls, as in Ruby
This commit is contained in:
parent
a5d39efdd2
commit
8d63d269b8
|
@ -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
|
||||
|
|
|
@ -46,3 +46,9 @@ Math: {
|
|||
print Math.Add(5, 5) is 10
|
||||
print Math.AnonymousAdd(10, 10) is 20
|
||||
print Math.FastAdd(20, 20) is 40
|
||||
|
||||
|
||||
# Parens are optional on simple function calls.
|
||||
print 100 > 1 if 1 > 0
|
||||
print true unless false
|
||||
print true for i in [1..3]
|
||||
|
|
Loading…
Reference in New Issue