Class: Riml::Compiler::RimlCommandNodeVisitor

Inherits:
CallNodeVisitor show all
Defined in:
lib/compiler.rb

Instance Method Summary collapse

Methods inherited from CallNodeVisitor

#compile_arguments

Methods inherited from Visitor

#initialize, #visit

Constructor Details

This class inherits a constructor from Riml::Compiler::Visitor

Instance Method Details

#compile(node) ⇒ Object



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/compiler.rb', line 597

def compile(node)
  if node.name == 'riml_source'
    node.name = 'source'
    node.each_existing_file! do |basename, full_path|
      current_compiler(node).compile_queue << full_path
    end
  elsif node.name == 'riml_include'
    # riml_include has to be top-level
    unless node.parent == root_node(node)
      error_msg = %Q(riml_include error, has to be called at top-level)
      raise IncludeNotTopLevel, error_msg
    end
    node.each_existing_file! do |basename, full_path|
      riml_src = File.read(full_path)
      node.compiled_output << current_compiler(node).compile_include(riml_src, basename)
    end
    return node.compiled_output
  end
  node.compiled_output << node.name
  compile_arguments(node)
  node.compiled_output.gsub!(/['"]/, '')
  node.compiled_output.sub!('.riml', '.vim')
  node.compiled_output
end