A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ruby-syntax-tree.github.io/syntax_tree/SyntaxTree/BEGINBlock.html below:

class SyntaxTree::BEGINBlock - RDoc Documentation

  1. SyntaxTree::
  2. BEGINBlock
class SyntaxTree::BEGINBlock

BEGINBlock represents the use of the BEGIN keyword, which hooks into the lifecycle of the interpreter. Whatever is inside the block will get executed when the program starts.

BEGIN {
}

Interestingly, the BEGIN keyword doesn’t allow the do and end keywords for the block. Only braces are permitted.

Attributes
LBrace

the left brace that is seen after the keyword

Public Class Methods

Source

def initialize(lbrace:, statements:, location:)
  @lbrace = lbrace
  @statements = statements
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(BEGINBlock) && lbrace === other.lbrace &&
    statements === other.statements
end

Source

def accept(visitor)
  visitor.visit_BEGIN(self)
end

Source

def child_nodes
  [lbrace, statements]
end

Source

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

Source

def deconstruct_keys(_keys)
  {
    lbrace: lbrace,
    statements: statements,
    location: location,
    comments: comments
  }
end

Source

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4