Skip to content

Commit f1d5414

Browse files
authored
Merge pull request #477 from aycabta/fix-handling-hash-rocket-after-symbol
Fix handling hash rocket after symbol
2 parents bfa71b7 + 11e1859 commit f1d5414

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ def identify_identifier
10691069

10701070
if @lex_state == :EXPR_FNAME
10711071
@lex_state = :EXPR_END
1072-
if peek(0) == '='
1072+
if peek(0) == '=' and peek(1) != '>'
10731073
token.concat getc
10741074
end
10751075
elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT ||

test/test_rdoc_ruby_lex.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,24 @@ def test_class_tokenize_percent_w_quote
380380
assert_equal expected, tokens
381381
end
382382

383+
def test_class_tokenize_hash_rocket
384+
tokens = RDoc::RubyLex.tokenize "{ :foo=> 1 }", nil
385+
386+
expected = [
387+
@TK::TkLBRACE .new( 0, 1, 0, '{'),
388+
@TK::TkSPACE .new( 1, 1, 1, ' '),
389+
@TK::TkSYMBOL .new( 2, 1, 2, ':foo'),
390+
@TK::TkHASHROCKET.new( 6, 1, 6, '=>'),
391+
@TK::TkSPACE .new( 8, 1, 8, ' '),
392+
@TK::TkINTEGER .new( 9, 1, 9, '1'),
393+
@TK::TkSPACE .new(10, 1, 10, ' '),
394+
@TK::TkRBRACE .new(11, 1, 11, '}'),
395+
@TK::TkNL .new(12, 1, 12, "\n")
396+
]
397+
398+
assert_equal expected, tokens
399+
end
400+
383401
def test_class_tokenize_percent_sign_quote
384402
tokens = RDoc::RubyLex.tokenize '%%hi%', nil
385403

0 commit comments

Comments
 (0)