Skip to content

Commit 434f9c6

Browse files
committed
Handle JSON-style hash key as symbol
1 parent 20af2f6 commit 434f9c6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,12 @@ def identify_identifier
948948
@indent_stack.push token_c
949949
end
950950
else
951-
token_c = TkIDENTIFIER
951+
if peek(0) == ':'
952+
token.concat getc
953+
token_c = TkSYMBOL
954+
else
955+
token_c = TkIDENTIFIER
956+
end
952957
end
953958

954959
elsif DEINDENT_CLAUSE.include?(token)
@@ -981,7 +986,12 @@ def identify_identifier
981986
elsif token[token.size - 1, 1] =~ /[!?]/
982987
return Token(TkFID, token)
983988
else
984-
return Token(TkIDENTIFIER, token)
989+
if peek(0) == ':'
990+
token.concat getc
991+
return Token(TkSYMBOL, token)
992+
else
993+
return Token(TkIDENTIFIER, token)
994+
end
985995
end
986996
end
987997

0 commit comments

Comments
 (0)