diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index 44cca09f73..a101f0d135 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -483,7 +483,7 @@ def lex_init() "=", "==", "===", "=~", "<=>", "<", "<=", - ">", ">=", ">>") do + ">", ">=", ">>", "=>") do |op, io| case @lex_state when :EXPR_FNAME, :EXPR_DOT diff --git a/lib/rdoc/ruby_token.rb b/lib/rdoc/ruby_token.rb index ea01631dcf..0feee63638 100644 --- a/lib/rdoc/ruby_token.rb +++ b/lib/rdoc/ruby_token.rb @@ -355,6 +355,7 @@ def Token(token, value = nil) [:TkNEQ, TkOp, "!="], [:TkGEQ, TkOp, ">="], [:TkLEQ, TkOp, "<="], + [:TkHASHROCKET, TkOp, "=>"], [:TkANDOP, TkOp, "&&"], [:TkOROP, TkOp, "||"], [:TkMATCH, TkOp, "=~"], diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index a57bfe3a80..3577c39de5 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -90,6 +90,25 @@ def test_class_tokenize_hash_symbol assert_equal expected, tokens end + def test_class_tokenize_hash_rocket + tokens = RDoc::RubyLex.tokenize '{ :class => "foo" }', nil + + expected = [ + @TK::TkLBRACE .new( 0, 1, 0, '{'), + @TK::TkSPACE .new( 1, 1, 1, ' '), + @TK::TkSYMBOL .new( 2, 1, 2, ':class'), + @TK::TkSPACE .new( 8, 1, 8, ' '), + @TK::TkHASHROCKET.new( 9, 1, 9, '=>'), + @TK::TkSPACE .new(11, 1, 11, ' '), + @TK::TkSTRING .new(12, 1, 12, '"foo"'), + @TK::TkSPACE .new(17, 1, 17, ' '), + @TK::TkRBRACE .new(18, 1, 18, '}'), + @TK::TkNL .new(19, 1, 19, "\n"), + ] + + assert_equal expected, tokens + end + def test_class_tokenize_heredoc_CR_NL tokens = RDoc::RubyLex.tokenize <<-RUBY, nil string = <<-STRING\r