End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
RubyVM::AbstractSyntaxTree.parse
RubyVM::AbstractSyntaxTree.parse(string) → RubyVM::AbstractSyntaxTree::Node
ast.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/ast.rb, line 34
def self.parse string
Primitive.ast_s_parse string
end
Parses the given string into an abstract syntax tree, returning the root node of that tree.
SyntaxError is raised if the given string is invalid syntax.
Example
RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>