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.



1539
1540
1541
1542
1543
1544
1545
# File 'lib/yadriggy/ast.rb', line 1539

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:



1533
1534
1535
# File 'lib/yadriggy/ast.rb', line 1533

def body
  @body
end

#rescueRescue|nil (readonly)

Returns the rescue clause.

Returns:

  • (Rescue|nil)

    the rescue clause.



1535
1536
1537
# File 'lib/yadriggy/ast.rb', line 1535

def rescue
  @rescue
end

Class Method Details

.tagObject



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

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.



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

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