Open gazayas opened 1 year ago
In the pry gem, binding.pry
is usually placed somewhere inside the code, but msmn.pry
would be placed outside of the code block that we instantiate Masamune::AbstractSyntaxTree.new(code)
with. Then we would just call pry
afterwards.
So, something like this.
code = <<~CODE
10.times do |n|
puts n
end
CODE
msmn = Masamune::AbstractSyntaxTree.new(code)
msmn.pry(type: :variables, token: "n")
I'd recommend shifting this to irb
instead, since IRB has pretty supplanted pry
in terms of features and isn't as needed anymore.
I'd like to have a method in
Masamune::AbstractSyntaxTree
calledpry
which will stop at each point in the code where the node matchespry
's parameters:Ideally I want to show the node class (i.e. -
Masamune::AbstractSyntaxTree::VarField
), the data from Ripper specifically for that node, and the correspondingMasamune::AbstractSyntaxTree::LexNode
.Then you could press enter to show the next node in the tree until you reach the final node.