Bug on ruby_parser gem?

  • Thread starter Andrea C. Granata
  • Start date
A

Andrea C. Granata

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:in
`block 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:in
`yylex'
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:in
`next_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:in
`do_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 `<main>'

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.
 
C

Charles Oliver Nutter

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 =3D RubyParser.new

text =3D<<EOF
# encoding: utf-8
#=C3=A0=C3=A8
puts "text"
# '
EOF
out =3D 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)

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 :) 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top