diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-12 03:42:54 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-12 03:42:54 +0000 |
commit | 214a7f8d49c7b59d06f5e2e3e1a8a3567ab7c570 (patch) | |
tree | 382d9b6a7989ada3d73912c9423e714cd08e8f5f /lib/rdoc/token_stream.rb | |
parent | 65b11a04f10a2438f0d6ba263a78d16367c3aac0 (diff) |
Merge rdoc-6.0.0.beta2 from upstream.
* This version changed lexer used Ripper from lexer based IRB.
see details: https://github.com/ruby/rdoc/pull/512
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/token_stream.rb')
-rw-r--r-- | lib/rdoc/token_stream.rb | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb index 0cfa2f1384..df5232f7ea 100644 --- a/lib/rdoc/token_stream.rb +++ b/lib/rdoc/token_stream.rb @@ -30,28 +30,41 @@ module RDoc::TokenStream token_stream.map do |t| next unless t - style = case t - when RDoc::RubyToken::TkCONSTANT then 'ruby-constant' - when RDoc::RubyToken::TkKW then 'ruby-keyword' - when RDoc::RubyToken::TkIVAR then 'ruby-ivar' - when RDoc::RubyToken::TkOp then 'ruby-operator' - when RDoc::RubyToken::TkId then 'ruby-identifier' - when RDoc::RubyToken::TkREGEXP then 'ruby-regexp' - when RDoc::RubyToken::TkDREGEXP then 'ruby-regexp' - when RDoc::RubyToken::TkNode then 'ruby-node' - when RDoc::RubyToken::TkCOMMENT then 'ruby-comment' - when RDoc::RubyToken::TkXSTRING then 'ruby-string' - when RDoc::RubyToken::TkSTRING then 'ruby-string' - when RDoc::RubyToken::TkVal then 'ruby-value' + style = case t[:kind] + when :on_const then 'ruby-constant' + when :on_kw then 'ruby-keyword' + when :on_ivar then 'ruby-ivar' + when :on_cvar then 'ruby-identifier' + when :on_gvar then 'ruby-identifier' + when '=' != t[:text] && :on_op then + if RDoc::RipperStateLex::EXPR_ARG == t[:state] then + 'ruby-identifier' + else + 'ruby-operator' + end + when :on_tlambda then 'ruby-operator' + when :on_ident then 'ruby-identifier' + when :on_label then 'ruby-value' + when :on_backref, :on_dstring + then 'ruby-node' + when :on_comment then 'ruby-comment' + when :on_embdoc then 'ruby-comment' + when :on_regexp then 'ruby-regexp' + when :on_tstring then 'ruby-string' + when :on_int, :on_float, + :on_rational, :on_imaginary, + :on_heredoc, + :on_symbol, :on_CHAR then 'ruby-value' + when :on_heredoc_beg, :on_heredoc_end + then 'ruby-identifier' end comment_with_nl = false - case t - when RDoc::RubyToken::TkRD_COMMENT, RDoc::RubyToken::TkHEREDOCEND - comment_with_nl = true if t.text =~ /\n$/ - text = t.text.rstrip + if :on_comment == t[:kind] or :on_embdoc == t[:kind] or :on_heredoc_end == t[:kind] + comment_with_nl = true if "\n" == t[:text][-1] + text = t[:text].rstrip else - text = t.text + text = t[:text] end text = CGI.escapeHTML text |