Class: Yadriggy::Reserved

Inherits:
Name show all
Defined in:
lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb

Overview

Reserved words such as self, nil, true, and false.

Instance Attribute Summary

Attributes inherited from Name

#column, #line_no, #name

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Name

#to_sym

Methods inherited from ASTnode

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

Constructor Details

#initialize(sexp) ⇒ Reserved

Returns a new instance of Reserved.



146
147
148
# File 'lib/yadriggy/ast.rb', line 146

def initialize(sexp)
  super(sexp)
end

Class Method Details

.tagObject



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

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



153
154
155
# File 'lib/yadriggy/ast.rb', line 153

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

#const_valueObject



178
# File 'lib/yadriggy/ast_value.rb', line 178

def const_value() value end

#valueObject

Gets self, true, or false. Otherwise, Undef.



166
167
168
169
170
171
172
173
174
175
176
# File 'lib/yadriggy/ast_value.rb', line 166

def value()
  if @name == 'self'
    get_receiver_object || Undef
  elsif @name == 'true'
    true
  elsif @name == 'false'
    false
  else
    Undef
  end
end