Class: Yadriggy::BeginEnd

Inherits:
ASTnode
  • Object
show all
Includes:
AstHelper
Defined in:
lib/yadriggy/ast.rb

Overview

begin-end.

Instance Attribute Summary collapse

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AstHelper

#has_tag?, #to_node, #to_nodes

Methods inherited from ASTnode

#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class

Constructor Details

#initialize(sexp) ⇒ BeginEnd

Returns a new instance of BeginEnd.



1555
1556
1557
1558
1559
1560
1561
# File 'lib/yadriggy/ast.rb', line 1555

def initialize(sexp)
  bodystmt = has_tag?(sexp[1], :bodystmt)
  @body = Exprs.make(bodystmt[1])
  @rescue = Rescue.make(bodystmt[2], bodystmt[3], bodystmt[4])
  add_child(@body)
  add_child(@rescue)
end

Instance Attribute Details

#bodyExprs|ASTnode (readonly)

Returns the body.

Returns:



1549
1550
1551
# File 'lib/yadriggy/ast.rb', line 1549

def body
  @body
end

#rescueRescue|nil (readonly)

Returns the rescue clause.

Returns:

  • (Rescue|nil)

    the rescue clause.



1551
1552
1553
# File 'lib/yadriggy/ast.rb', line 1551

def rescue
  @rescue
end

Class Method Details

.tagObject



1553
# File 'lib/yadriggy/ast.rb', line 1553

def self.tag() :begin end

Instance Method Details

#accept(evaluator) ⇒ void

This method returns an undefined value.

A method for Visitor pattern.

Parameters:

  • evaluator (Eval)

    the visitor of Visitor pattern.



1566
1567
1568
# File 'lib/yadriggy/ast.rb', line 1566

def accept(evaluator)
  evaluator.begin_end(self)
end