Module: Jaina::Parser::AST::Evaluator Private

Defined in:
lib/jaina/parser/ast/evaluator.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Class Method Summary collapse

Class Method Details

.evaluate(ast, **initial_context) ⇒ Any

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Any)

Since:

  • 0.1.0



13
14
15
16
17
18
19
20
# File 'lib/jaina/parser/ast/evaluator.rb', line 13

def evaluate(ast, **initial_context)
  # NOTE: build shared context for a program
  context = Jaina::Parser::AST::Context.new(**initial_context)

  # NOTE: evaluate the root expression of AST
  # NOTE: root is an entity of type [Jaina::Parser::Expression::Operator::Abstract]
  ast.root.evaluate(context)
end