ruby-changes:54993
From: nobu <ko1@a...>
Date: Sat, 9 Mar 2019 19:17:38 +0900 (JST)
Subject: [ruby-changes:54993] nobu:r67200 (trunk): Add ignored_sp event
nobu 2019-03-09 19:17:33 +0900 (Sat, 09 Mar 2019) New Revision: 67200 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67200 Log: Add ignored_sp event * ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer): add ignored_sp event which will be fired from Ripper::Lexer#on_heredoc_dedent method. [ruby-core:91727] [Bug #15648] Modified files: trunk/ext/ripper/lib/ripper/lexer.rb trunk/test/ripper/test_scanner_events.rb Index: ext/ripper/lib/ripper/lexer.rb =================================================================== --- ext/ripper/lib/ripper/lexer.rb (revision 67199) +++ ext/ripper/lib/ripper/lexer.rb (revision 67200) @@ -83,6 +83,12 @@ class Ripper https://github.com/ruby/ruby/blob/trunk/ext/ripper/lib/ripper/lexer.rb#L83 private + unless SCANNER_EVENT_TABLE.key?(:ignored_sp) + SCANNER_EVENT_TABLE[:ignored_sp] = 1 + SCANNER_EVENTS << :ignored_sp + EVENTS << :ignored_sp + end + def on_heredoc_dedent(v, w) ignored_sp = [] heredoc = @buf.last Index: test/ripper/test_scanner_events.rb =================================================================== --- test/ripper/test_scanner_events.rb (revision 67199) +++ test/ripper/test_scanner_events.rb (revision 67200) @@ -888,6 +888,13 @@ class TestRipper::ScannerEvents < Test:: https://github.com/ruby/ruby/blob/trunk/test/ripper/test_scanner_events.rb#L888 scan('ignored_nl', "1;\r\n") end + def test_ignored_sp + assert_equal [], + scan('ignored_sp', "<<~EOS\nheredoc\nEOS") + assert_equal [" "], + scan('ignored_sp', "<<~EOS\n heredoc\nEOS") + end + def test___end__ assert_equal [], scan('__end__', "") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/