Hi guys,
I've been playing around with Ripper for the first time today. Parsing
method calls with and without parentheses gives me different output and
I'm not sure why. When using brackets, Ripper outputs a 'method',
without them gives me a 'command'.
Are these actually different things inside Ruby, or is this just a
difference in the way Ripper outputs them?
If there is a internal difference between them, could someone please
point me to either some more information, or the relevant bit of the
Ruby source code I need to read to learn more.
If they are not different internally, what is the reason that Ripper
displays them as such?
I suspect I may have more questions. Are there any good resources for
Ripper, or anyone specific I should be pestering? I'm happy to put some
documentation together as I explore further if people feel that would be
useful?
Sample code and my output follow.
Thanks for your time.
···
-----
I'm running:
content = <<-EOS
x(1)
y 1
EOS
Sexp.from_array(Ripper::SexpBuilder.new(content).parse)[1]
The sexp I get out is
s(:stmts_add,
s(:stmts_add,
s(:stmts_new),
s(:method_add_arg,
s(:fcall,
s(:@ident, "x", s(1, 0))
),
s(:arg_paren,
s(:args_add_block,
s(:args_add,
s(:args_new),
s(:@int, "1", s(1, 2))
), false
)
)
)
),
s(:command,
s(:@ident, "y", s(2, 0)),
s(:args_add_block,
s(:args_add,
s(:args_new),
s(:@int, "1", s(2, 2))
), false
)
)
)
--
Posted via http://www.ruby-forum.com/.