End of Life Ruby 3.1 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.1.3/ast.rb, line 32
def self.parse string, keep_script_lines: false
Primitive.ast_s_parse string, keep_script_lines
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>