diff --git a/History.rdoc b/History.rdoc index 6e34ba06af..e21b1d2b7e 100644 --- a/History.rdoc +++ b/History.rdoc @@ -7,6 +7,7 @@ Noria. * Fixed tokenization of % when it is not followed by a $-string type * Fixed display of __END__ in documentation examples in HTML output + * Fixed tokenization of reserved words used as new-style hash keys === 3.12.1 / 2013-02-05 diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index f3cb0046a0..845569b0bc 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -936,6 +936,8 @@ def identify_identifier @indent += 1 @indent_stack.push token_c end + else + token_c = TkIDENTIFIER end elsif DEINDENT_CLAUSE.include?(token) diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index 4029c1472a..1dc11e95a3 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -77,6 +77,23 @@ def x assert_equal expected, tokens end + def test_class_tokenize_hash_symbol + tokens = RDoc::RubyLex.tokenize '{ class:"foo" }', nil + + expected = [ + @TK::TkLBRACE .new( 0, 1, 0, '{'), + @TK::TkSPACE .new( 1, 1, 1, ' '), + @TK::TkIDENTIFIER.new( 2, 1, 2, 'class'), + @TK::TkSYMBEG .new( 7, 1, 7, ':'), + @TK::TkSTRING .new( 8, 1, 8, '"foo"'), + @TK::TkSPACE .new(13, 1, 13, ' '), + @TK::TkRBRACE .new(14, 1, 14, '}'), + @TK::TkNL .new(15, 1, 15, "\n"), + ] + + assert_equal expected, tokens + end + def test_class_tokenize_heredoc_indent tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil string = <<-STRING