Module: Void

Defined in:
lib/void.rb

Class Method Summary collapse

Class Method Details

.compile(code = "") ⇒ Object



12
13
14
15
16
17
# File 'lib/void.rb', line 12

def compile(code = "")
  # Instantiate required language components
  @syntax = Parser.parse code

  pp @syntax
end

.render(file, context = {}) ⇒ Object

Analyze the input code and check for matching tokens. In case no match was found, throw an exception. In special cases, modify the token hash.

Parameters:

  • file (String)

    The file that needs to be analyzed

  • context (Hash | String) (defaults to: {})

    Processing environment data



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/void.rb', line 25

def render(file, context = {})
  @file = file

  # Accept both ruby hashes and JSON files as database environments
  case context
  when Hash
    @context = context
  when String
    @context = JSON.parse(File.read context)
  end

  # Run all the processors
  compile PreProcessor.process @file 
end