Class: ORB::Temple::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/temple/compiler.rb

Overview

The Compiler is used in the ORB::Engine to compile an input document string into a Temple expression that gets passed on to the next step in the pipeline.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Compiler

The Compiler is initialized by the Engine pipeline with the options passed to the Engine



9
10
11
12
# File 'lib/orb/temple/compiler.rb', line 9

def initialize(options = {})
  @options = options
  @identity = Identity.new
end

Instance Method Details

#call(ast) ⇒ Object

Then the pipeline executes the #call method with an ORB::AST::*Node input



15
16
17
18
19
20
21
22
23
# File 'lib/orb/temple/compiler.rb', line 15

def call(ast)
  return runtime_error(ast) if ast.is_a?(ORB::Error)

  transform(ast)
rescue CompilerError => e
  raise e
rescue ORB::Error => e
  runtime_error(e)
end