class SyntaxTree::BEGINBlock
the block. Only braces are permitted.
Interestingly, the BEGIN keyword doesn’t allow the do and end keywords for
}
BEGIN {
when the program starts.
lifecycle of the interpreter. Whatever is inside the block will get executed
BEGINBlock represents the use of the BEGIN keyword, which hooks into the
def ===(other)
def ===(other) other.is_a?(BEGINBlock) && lbrace === other.lbrace && statements === other.statements end
def accept(visitor)
def accept(visitor) visitor.visit_BEGIN(self) end
def child_nodes
def child_nodes [lbrace, statements] end
def copy(lbrace: nil, statements: nil, location: nil)
def copy(lbrace: nil, statements: nil, location: nil) node = BEGINBlock.new( lbrace: lbrace || self.lbrace, statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { lbrace: lbrace, statements: statements, location: location, comments: comments } end
def format(q)
def format(q) q.group do q.text("BEGIN ") q.format(lbrace) q.indent do q.breakable_space q.format(statements) end q.breakable_space q.text("}") end end
def initialize(lbrace:, statements:, location:)
def initialize(lbrace:, statements:, location:) @lbrace = lbrace @statements = statements @location = location @comments = [] end