diff --git a/documentation/coffee/switch.coffee b/documentation/coffee/switch.coffee index ee6963a3..7d9605e6 100644 --- a/documentation/coffee/switch.coffee +++ b/documentation/coffee/switch.coffee @@ -1,9 +1,9 @@ switch day -when "Tuesday" then eat_breakfast() -when "Wednesday" then go_to_the_park() -when "Saturday" - if day is bingo_day - go_to_bingo() - go_dancing() -when "Sunday" then go_to_church() -else go_to_work() \ No newline at end of file + when "Tuesday" then eat_breakfast() + when "Wednesday" then go_to_the_park() + when "Saturday" + if day is bingo_day + go_to_bingo() + go_dancing() + when "Sunday" then go_to_church() + else go_to_work() \ No newline at end of file diff --git a/lib/coffee_script/lexer.rb b/lib/coffee_script/lexer.rb index 37fe5fce..9f3cd912 100644 --- a/lib/coffee_script/lexer.rb +++ b/lib/coffee_script/lexer.rb @@ -42,13 +42,13 @@ module CoffeeScript BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], [:INDENT, :OUTDENT]] # Outdents that come before these tokens don't signify the end of the - # expression. TODO: Is this safe? - EXPRESSION_TAIL = [:CATCH, :WHEN, :ELSE, ')', ']', '}'] + # expression. + EXPRESSION_TAIL = [:CATCH, :WHEN, :ELSE, :FINALLY, ')', ']', '}'] # Single-line flavors of block expressions that have unclosed endings. # The grammar can't disambiguate them, so we insert the implicit indentation. SINGLE_LINERS = [:ELSE, "=>", :TRY, :FINALLY, :THEN] - SINGLE_CLOSERS = ["\n", :CATCH, :FINALLY, :ELSE] + SINGLE_CLOSERS = ["\n", :CATCH, :FINALLY, :ELSE, :OUTDENT] # The inverse mappings of token pairs we're trying to fix up. INVERSES = {:INDENT => :OUTDENT, :OUTDENT => :INDENT, '(' => ')', ')' => '('} diff --git a/test/fixtures/execution/test_everything.coffee b/test/fixtures/execution/test_everything.coffee index 512f219b..87d44492 100644 --- a/test/fixtures/execution/test_everything.coffee +++ b/test/fixtures/execution/test_everything.coffee @@ -8,6 +8,8 @@ func: => c: { "text": b + other: null + something_else: x => x + 5 } c: 'error' unless 42 > 41 diff --git a/test/unit/test_parser.rb b/test/unit/test_parser.rb index 83d6ac64..95ee835e 100644 --- a/test/unit/test_parser.rb +++ b/test/unit/test_parser.rb @@ -78,9 +78,9 @@ class ParserTest < Test::Unit::TestCase end def test_no_wrapping_parens_around_statements - @par.parse("try thing() catch error fail()").compile + @par.parse("try thing() catch error then fail()").compile assert_raises(SyntaxError) do - @par.parse("(try thing() catch error fail())").compile + @par.parse("(try thing() catch error then fail())").compile end end