mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
Adding kamatsu's proposed block literal syntax
This commit is contained in:
@@ -17,6 +17,9 @@ token COMMENT
|
|||||||
token JS
|
token JS
|
||||||
token INDENT OUTDENT
|
token INDENT OUTDENT
|
||||||
|
|
||||||
|
# We expect one shift-reduce conflict. Because of the lexer, it will never occur.
|
||||||
|
expect 1
|
||||||
|
|
||||||
# Declare order of operations.
|
# Declare order of operations.
|
||||||
prechigh
|
prechigh
|
||||||
nonassoc UMINUS SPLAT NOT '!' '!!' '~' '++' '--' '?'
|
nonassoc UMINUS SPLAT NOT '!' '!!' '~' '++' '--' '?'
|
||||||
@@ -260,8 +263,14 @@ rule
|
|||||||
|
|
||||||
# A generic function invocation.
|
# A generic function invocation.
|
||||||
Invocation:
|
Invocation:
|
||||||
Value "(" ArgList ")" { result = CallNode.new(val[0], val[2]) }
|
Value Arguments { result = CallNode.new(val[0], val[1]) }
|
||||||
| Invocation "(" ArgList ")" { result = CallNode.new(val[0], val[2]) }
|
| Invocation Arguments { result = CallNode.new(val[0], val[1]) }
|
||||||
|
# | Invocation Code { result = val[0] << val[1] }
|
||||||
|
;
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
"(" ArgList ")" { result = val[1] }
|
||||||
|
| "(" ArgList ")" Code { result = val[1] << val[3] }
|
||||||
;
|
;
|
||||||
|
|
||||||
# Calling super.
|
# Calling super.
|
||||||
|
|||||||
@@ -220,6 +220,10 @@ module CoffeeScript
|
|||||||
@arguments.any? {|a| a.is_a?(ArgSplatNode) }
|
@arguments.any? {|a| a.is_a?(ArgSplatNode) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def <<(argument)
|
||||||
|
@arguments << argument
|
||||||
|
end
|
||||||
|
|
||||||
def compile(o={})
|
def compile(o={})
|
||||||
o = super(o)
|
o = super(o)
|
||||||
return write(compile_splat(o)) if splat?
|
return write(compile_splat(o)) if splat?
|
||||||
|
|||||||
Reference in New Issue
Block a user