Class: Yadriggy::Command

Inherits:
Call show all
Defined in:
lib/yadriggy/ast.rb

Overview

A method call without parentheses.

Instance Attribute Summary

Attributes inherited from Call

#args, #block, #block_arg, #name, #op, #receiver

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Call

make, #value, #value_in_class

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

Returns a new instance of Command.



974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
# File 'lib/yadriggy/ast.rb', line 974

def initialize(sexp)
  if sexp[0] == :command
    initialize_call([:call, nil, nil, sexp[1]])
    arg_exp = sexp[2]
  elsif sexp[0] == :command_call
    initialize_call([:call, sexp[1], sexp[2], sexp[3]])
    arg_exp = sexp[4]
  else
    raise "unknown pattern " + sexp.to_s
  end

  if arg_exp[0] == :args_add_block
    initialize_args(arg_exp)
  else
    @args = to_nodes(arg_exp)
    @block_arg = nil
    add_children(@args)
  end

  @block = nil
end

Class Method Details

.tagsObject



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

def self.tags() [:command, :command_call] 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.



999
1000
1001
# File 'lib/yadriggy/ast.rb', line 999

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