How do I access the Ruby AST from C degree code?

I recognize that the Ruby 1.8 AST is gone across at runtime making use of a large button declaration, and also several points like calling a method in a class or moms and dad component entail the interpreter looking up and also down the tree as it goes. Exists an uncomplicated means of accessing this AST in a Ruby C expansion? Does it entail the Ruby expansion API, or demand hacking the inner information frameworks straight?

2019-12-02 02:51:13
Source Share
Answers: 2

Thanks for the pointer. You are appropriate - ParseTree appears to be the only code around with any kind of adjustment of the AST taking place, other than that it is in fact created in RubyInline.

So, it is a weird combination in between Ruby and also C code. Really intriguing analysis, however.

The various other reference certainly is eval.c from Ruby itself.

It is mosting likely to take a reasonable little analysis of both, to get my head around it.

2019-12-04 04:07:40

An excellent beginning factor is possibly to read the resource of the ParseTree collection, which allows you access and also tinker the AST from ruby.

2019-12-03 04:15:21