From d4cb3202e5e77dc84f84a2cb2a586fa46e128044 Mon Sep 17 00:00:00 2001 From: Code Ass Date: Tue, 8 Aug 2017 13:25:23 +0900 Subject: [PATCH 1/2] Fix n-ary detecting condition for rational and imaginary --- lib/rdoc/ruby_lex.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index a1d29e943d..a46e06c7ae 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -1107,7 +1107,7 @@ def identify_number(op = "") num = op - if peek(0) == "0" && peek(1) !~ /[.eE]/ + if peek(0) == "0" && peek(1) !~ /[.eEri]/ num << getc case peek(0) From a353417483e1e192bd0c86dc8e3d3d6eb5bb33c4 Mon Sep 17 00:00:00 2001 From: Code Ass Date: Tue, 8 Aug 2017 13:27:44 +0900 Subject: [PATCH 2/2] Fix test_rational_imaginary_tokenize for confusable with a-ary --- test/test_rdoc_ruby_lex.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index c89748449b..57f425dddc 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -486,7 +486,7 @@ def test_unary_minus end def test_rational_imaginary_tokenize - tokens = RDoc::RubyLex.tokenize '1.11r + 2.34i + 5.55ri', nil + tokens = RDoc::RubyLex.tokenize '1.11r + 2.34i + 5.55ri + 0i', nil expected = [ @TK::TkRATIONAL .new( 0, 1, 0, '1.11r'), @@ -498,7 +498,11 @@ def test_rational_imaginary_tokenize @TK::TkPLUS .new(14, 1, 14, '+'), @TK::TkSPACE .new(15, 1, 15, ' '), @TK::TkIMAGINARY.new(16, 1, 16, '5.55ri'), - @TK::TkNL .new(22, 1, 22, "\n"), + @TK::TkSPACE .new(22, 1, 22, ' '), + @TK::TkPLUS .new(23, 1, 23, '+'), + @TK::TkSPACE .new(24, 1, 24, ' '), + @TK::TkIMAGINARY.new(25, 1, 25, '0i'), + @TK::TkNL .new(27, 1, 27, "\n"), ] assert_equal expected, tokens