Skip to content

Commit d68cee2

Browse files
committed
Support quoted symbol for JSON-style hash literal
Like below: { 'first': 1, "second": 2 }
1 parent 1261ff6 commit d68cee2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def initialize(content, options)
112112
@indent_stack = []
113113
@lex_state = :EXPR_BEG
114114
@space_seen = false
115+
@after_question = false
115116

116117
@continue = false
117118
@line = ""
@@ -379,6 +380,8 @@ def token
379380
tk = tk1
380381
end
381382
end
383+
@after_question = false if @after_question and !(TkQUESTION === tk)
384+
382385
# Tracer.off
383386
tk
384387
end
@@ -593,6 +596,7 @@ def lex_init()
593596
|op, io|
594597
if @lex_state == :EXPR_END
595598
@lex_state = :EXPR_BEG
599+
@after_question = true
596600
Token(TkQUESTION)
597601
else
598602
ch = getc
@@ -1359,7 +1363,10 @@ def identify_string(ltype, quoted = ltype, type = nil)
13591363
end
13601364
end
13611365

1362-
if subtype
1366+
if peek(0) == ':' and !peek_match?(/^::/) and :EXPR_BEG == @lex_state and !@after_question
1367+
str.concat getc
1368+
return Token(TkSYMBOL, str)
1369+
elsif subtype
13631370
Token(DLtype2Token[ltype], str)
13641371
else
13651372
Token(Ltype2Token[ltype], str)

0 commit comments

Comments
 (0)