diff --git a/lib/coffee_script/grammar.y b/lib/coffee_script/grammar.y index 469716e2..f821370d 100644 --- a/lib/coffee_script/grammar.y +++ b/lib/coffee_script/grammar.y @@ -5,7 +5,7 @@ token IF ELSE UNLESS token NUMBER STRING REGEX token TRUE FALSE YES NO ON OFF token IDENTIFIER PROPERTY_ACCESS -token CODE PARAM NEW RETURN +token CODE PARAM PARAM_SPLAT NEW RETURN token TRY CATCH FINALLY THROW token BREAK CONTINUE token FOR IN BY WHILE @@ -17,12 +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 '!' '!!' '~' '++' '--' '?' + nonassoc UMINUS PARAM_SPLAT SPLAT NOT '!' '!!' '~' '++' '--' '?' left '*' '/' '%' left '+' '-' left '<<' '>>' '>>>' @@ -203,7 +200,7 @@ rule Param: PARAM - | '*' PARAM = SPLAT { result = ParamSplatNode.new(val[1]) } + | PARAM_SPLAT PARAM { result = ParamSplatNode.new(val[1]) } ; Splat: diff --git a/lib/coffee_script/lexer.rb b/lib/coffee_script/lexer.rb index 0e593e55..706b1d51 100644 --- a/lib/coffee_script/lexer.rb +++ b/lib/coffee_script/lexer.rb @@ -219,7 +219,8 @@ module CoffeeScript i -= 1 tok = @tokens[i] return if !tok - next if ['*', ','].include?(tok[0]) + next if tok[0] == ',' + next tok[0] = :PARAM_SPLAT if tok[0] == '*' return if tok[0] != :IDENTIFIER tok[0] = :PARAM end diff --git a/test/fixtures/execution/test_blocks.coffee b/test/fixtures/execution/test_blocks.coffee new file mode 100644 index 00000000..a28eecc9 --- /dev/null +++ b/test/fixtures/execution/test_blocks.coffee @@ -0,0 +1,4 @@ +results: [1, 2, 3].map() x => + x * x + +print(results.join(' ') is '1 4 9') \ No newline at end of file