class method
RubyVM::AbstractSyntaxTree.parse_file
(::path string, ?keep_script_lines: bool, ?error_tolerant: bool, ?keep_tokens: bool) -> ::RubyVM::AbstractSyntaxTree::Node
RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) → RubyVM::AbstractSyntaxTree::Node
ast.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ast.rb, line 74
def self.parse_file pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_parse_file pathname, keep_script_lines, error_tolerant, keep_tokens
end
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.