Bug #4544
closedRipperで「:"a \n b \n c"」を正常にパースできない
Description
=begin
Ripper::SexpBuilder.new(%Q!:"a \n b \n c"!).parse にて、on_tstring_content メソッドが二回連続で呼び出されます。
検証済みバージョン
- ruby 1.9.3dev (2011-03-31 trunk 31223) [i686-linux]
- ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
- ruby 1.9.1p431 (2011-02-18 revision 30908) [i686-linux]
検証用スクリプト
require 'ripper'
class Parser < Ripper::SexpBuilder
ms = Ripper::SexpBuilder.new('').methods
defs = ms.map { |s| s.to_s }
.select { |s| s.start_with?('on_') }
.map { |s| %Q{
def #{s}(*args)
print '#{s}: '
p args
end
}}.join
eval(defs)
end
def parse(src)
puts "" + src.inspect + ""
Parser.new(src).parse
puts
end
parse(%Q!:"a \n b \n c"!)
parse(%Q!:"a \n b c"!)
parse(%Q!:"a b c"!)
実行結果
----":"a \n b \n c""----
on_symbeg: [":""]
on_tstring_content: ["a \n b \n"]
on_tstring_content: [" c"]
on_xstring_new: []
on_xstring_add: [[], [" c"]]
on_tstring_end: ["""]
on_dyna_symbol: [[[], [" c"]]]
on_stmts_new: []
on_stmts_add: [[], [[[], [" c"]]]]
on_program: [[[], [[[], [" c"]]]]]
----":"a \n b c""----
on_symbeg: [":""]
on_tstring_content: ["a \n"]
on_tstring_content: [" b c"]
on_xstring_new: []
on_xstring_add: [[], [" b c"]]
on_tstring_end: ["""]
on_dyna_symbol: [[[], [" b c"]]]
on_stmts_new: []
on_stmts_add: [[], [[[], [" b c"]]]]
on_program: [[[], [[[], [" b c"]]]]]
----":"a b c""----
on_symbeg: [":""]
on_tstring_content: ["a b c"]
on_xstring_new: []
on_xstring_add: [[], ["a b c"]]
on_tstring_end: ["""]
on_dyna_symbol: [[[], ["a b c"]]]
on_stmts_new: []
on_stmts_add: [[], [[[], ["a b c"]]]]
on_program: [[[], [[[], ["a b c"]]]]]
=end