Adding kamatsu's proposed block literal syntax
This commit is contained in:
parent
7eff8786bc
commit
21a0cc83ae
|
@ -17,6 +17,9 @@ token COMMENT
|
|||
token JS
|
||||
token INDENT OUTDENT
|
||||
|
||||
# We expect one shift-reduce conflict. Because of the lexer, it will never occur.
|
||||
expect 1
|
||||
|
||||
# Declare order of operations.
|
||||
prechigh
|
||||
nonassoc UMINUS SPLAT NOT '!' '!!' '~' '++' '--' '?'
|
||||
|
@ -260,8 +263,14 @@ rule
|
|||
|
||||
# A generic function invocation.
|
||||
Invocation:
|
||||
Value "(" ArgList ")" { result = CallNode.new(val[0], val[2]) }
|
||||
| Invocation "(" ArgList ")" { result = CallNode.new(val[0], val[2]) }
|
||||
Value Arguments { result = CallNode.new(val[0], val[1]) }
|
||||
| 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.
|
||||
|
|
|
@ -220,6 +220,10 @@ module CoffeeScript
|
|||
@arguments.any? {|a| a.is_a?(ArgSplatNode) }
|
||||
end
|
||||
|
||||
def <<(argument)
|
||||
@arguments << argument
|
||||
end
|
||||
|
||||
def compile(o={})
|
||||
o = super(o)
|
||||
return write(compile_splat(o)) if splat?
|
||||
|
|
Loading…
Reference in New Issue