Class: Jaina::Parser::AST Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jaina/parser/ast.rb

Overview

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

Since:

  • 0.1.0

Defined Under Namespace

Modules: Evaluator Classes: Context, Tree, TreeBuilder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program, ast_tree) ⇒ void

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:

Since:

  • 0.1.0



47
48
49
50
# File 'lib/jaina/parser/ast.rb', line 47

def initialize(program, ast_tree)
  @program  = program.dup.tap(&:freeze)
  @ast_tree = ast_tree
end

Instance Attribute Details

#ast_treeJaina::Pasrer::AST::Tree (readonly)

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.

Returns:

  • (Jaina::Pasrer::AST::Tree)

Since:

  • 0.1.0



30
31
32
# File 'lib/jaina/parser/ast.rb', line 30

def ast_tree
  @ast_tree
end

#programString (readonly)

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.

Returns:

  • (String)

Since:

  • 0.1.0



36
37
38
# File 'lib/jaina/parser/ast.rb', line 36

def program
  @program
end

Class Method Details

.build(program) ⇒ Jaina::Parser::AST

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:

  • program (String)

    Program string in prefix form

Returns:

Since:

  • 0.1.0



20
21
22
23
# File 'lib/jaina/parser/ast.rb', line 20

def build(program)
  ast_tree = Jaina::Parser::AST::TreeBuilder.build(program)
  new(program, ast_tree)
end

Instance Method Details

#evaluate(**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:

  • initial_context (Hash<Symbol,Any>)

Returns:

  • (Any)

Since:

  • 0.1.0



57
58
59
# File 'lib/jaina/parser/ast.rb', line 57

def evaluate(**initial_context)
  Jaina::Parser::AST::Evaluator.evaluate(self, **initial_context)
end