class SyntaxTree::Program
Program
represents the overall syntax tree.
Attributes
Statements
-
the top-level expressions of the program
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 8623 def initialize(statements:, location:) @statements = statements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 8663 def ===(other) other.is_a?(Program) && statements === other.statements end
Source
# File lib/syntax_tree/node.rb, line 8629 def accept(visitor) visitor.visit_program(self) end
Source
# File lib/syntax_tree/node.rb, line 8633 def child_nodes [statements] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 8637 def copy(statements: nil, location: nil) node = Program.new( statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 8650 def deconstruct_keys(_keys) { statements: statements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 8654 def format(q) q.format(statements) # We're going to put a newline on the end so that it always has one unless # it ends with the special __END__ syntax. In that case we want to # replicate the text exactly so we will just let it be. q.breakable_force unless statements.body.last.is_a?(EndContent) end