Class: IdentifierNode
- Inherits:
-
PrimitiveNode
- Object
- PrimitiveNode
- IdentifierNode
- Defined in:
- lib/nodes.rb
Overview
Class for identifiers (functions and variables).
Instance Attribute Summary
Attributes inherited from PrimitiveNode
Instance Method Summary collapse
Methods inherited from PrimitiveNode
Constructor Details
This class inherits a constructor from PrimitiveNode
Instance Method Details
#evaluate(scope) ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/nodes.rb', line 363 def evaluate(scope) # Checks if the identifier is a function. If true raise SyntaxError. if scope.is_function?(@value) raise SyntaxError, "Identifier #{@value} is assigned to a function. Please use correct syntax for function call." end # Checks if the identifier is a local variable. If false, add it to non-local list. id_value = scope.get_identifier(@value) unless scope.identifiers.has_key?(@value) scope.set_non_local_variable(@value) end return id_value end |