Bug on ruby_parser gem?

Hi there,

I think i just found a bug on ruby_parser gem on ruby 1.9.1

This is my code:

encoding: utf-8

require ‘rubygems’
require ‘ruby_parser’
parser = RubyParser.new

text =<<EOF

encoding: utf-8

#àèputs “text”

EOF
out = parser.process(text)
puts out.inspect

When I run the code on ruby 1.9.1p376 (2009-12-07 revision 26041)
[i386-darwin10.2.0] i get this error:

bash-3.2$ ruby test_parser.rb
/Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_lexer.rb:381:in
rb_compile_error': Invalid char "'" in expression. near line 5: "#" (SyntaxError) from /Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_lexer.rb:1222:inblock in yylex’
from
/Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_lexer.rb:635:in
loop' from /Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_lexer.rb:635:inyylex’
from
/Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_lexer.rb:54:in
advance' from /Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:712:innext_token’
from
/Users/andreag/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/racc/parser.rb:99:in
_racc_do_parse_c' from /Users/andreag/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/racc/parser.rb:99:indo_parse’
from
/Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:749:in
process' from test_parser.rb:14:in

On ruby 1.8.7 (2008-08-11 patchlevel 72) and on jruby 1.4.0 (ruby
1.9.2dev trunk 24787) the output is:
s(:call, nil, :puts, s(:arglist, s(:str, “text”))) as expected.

Did I miss something or this is a real bug?

Ciao,
Andrea.

On Wed, Jan 6, 2010 at 6:21 AM, Andrea C. Granata
[email protected] wrote:

parser = RubyParser.new
When I run the code on ruby 1.9.1p376 (2009-12-07 revision 26041)
[i386-darwin10.2.0] i get this error:

bash-3.2$ ruby test_parser.rb
/Users/andreag/.rvm/gems/ruby/1.9.1/gems/ruby_parser-2.0.4/lib/ruby_lexer.rb:381:in
`rb_compile_error’: Invalid char “'” in expression. near line 5: “#”
(SyntaxError)

This looks like an incompatibility rather than a bug. As far as I
know, ruby_parser primarily supports 1.8, and I don’t know how much
testing has happened against 1.9. Either way, you should probably try
to report it…somewhere :slight_smile: I think ruby_parser is a great project to
have, since it allows equivalent parser support across all Ruby
implementations without any native code.

  • Charlie

On Jan 6, 2010, at 06:19 , Charles Oliver N. wrote:

Either way, you should probably try
to report it…somewhere :slight_smile:

that somewhere is the parsetree project on rubyforge:

http://rubyforge.org/projects/parsetree/