Class: Yadriggy::Paren

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

Overview

Parenthesis.

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) ⇒ Paren

Returns a new instance of Paren.



412
413
414
415
416
# File 'lib/yadriggy/ast.rb', line 412

def initialize(sexp)
  e = if sexp[1][0].is_a?(Array) then sexp[1][0] else sexp[1] end
  @expression = to_node(e)
  add_child(@expression)
end

Instance Attribute Details

#expressionASTnode (readonly)

Returns the expression surrounded with the parentheses.

Returns:

  • (ASTnode)

    the expression surrounded with the parentheses.



408
409
410
# File 'lib/yadriggy/ast.rb', line 408

def expression
  @expression
end

Class Method Details

.tagObject



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

def self.tag() :paren 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.



421
422
423
# File 'lib/yadriggy/ast.rb', line 421

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