Method: Emfrp::Interpreter#initialize

Defined in:
lib/emfrp/interpreter/interpreter.rb

#initialize(include_dirs, output_io, main_path) ⇒ Interpreter

Returns a new instance of Interpreter.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/emfrp/interpreter/interpreter.rb', line 18

def initialize(include_dirs, output_io, main_path)
  @file_loader = FileLoader.new(include_dirs)
  @main_path = main_path
  @output_io = output_io
  @readline_nums = (1..1000).to_a
  @command_manager = CommandManager.make(self)
  @top = Parser.parse_input(main_path, @file_loader, Parser.module_or_material_file)
  @infix_parser = Parser.from_infixes_to_parser(@top[:infixes])
  @top = Parser.infix_convert(@top, @infix_parser)
  PreConvert.convert(@top)
  Typing.typing(@top)
rescue Parser::ParsingError => err
  err.print_error(@output_io)
  raise InterpreterError.new(err.code)
rescue CompileError => err
  err.print_error(@output_io, @file_loader)
  raise InterpreterError.new(err.code)
end