diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index cc8837637e..43132655bc 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -112,6 +112,7 @@ def initialize(content, options) @indent_stack = [] @lex_state = :EXPR_BEG @space_seen = false + @after_question = false @continue = false @line = "" @@ -383,6 +384,8 @@ def token set_token_position tk.seek, tk.line_no, tk.char_no tk = Token(tk1.class, tk.text + tk1.text) end + @after_question = false if @after_question and !(TkQUESTION === tk) + # Tracer.off tk end @@ -597,6 +600,7 @@ def lex_init() |op, io| if @lex_state == :EXPR_END @lex_state = :EXPR_BEG + @after_question = true Token(TkQUESTION) else ch = getc @@ -1365,7 +1369,10 @@ def identify_string(ltype, quoted = ltype, type = nil) end end - if subtype + if peek(0) == ':' and !peek_match?(/^::/) and :EXPR_BEG == @lex_state and !@after_question + str.concat getc + return Token(TkSYMBOL, str) + elsif subtype Token(DLtype2Token[ltype], str) else Token(Ltype2Token[ltype], str) diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index 5d5d931dff..30134bdfeb 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -805,6 +805,36 @@ def test_class_tokenize_particular_kind_of_symbols assert_equal expected, tokens end + def test_class_tokenize_symbol_with_quote + tokens = RDoc::RubyLex.tokenize <