Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

RubyVM::AbstractSyntaxTree.parse_file

RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false) → RubyVM::AbstractSyntaxTree::Node

Reads the file from pathname, then parses it like ::parse, returning the root node of the abstract syntax tree.

SyntaxError is raised if pathname’s contents are not valid Ruby syntax.

Example
RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb")
# => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>

See ::parse for explanation of keyword argument meaning and usage.

See also .parse .of also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0