Class: Highway::Compiler::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/highway/compiler/suite.rb

Overview

This class is responsible for executing all compiler stages, including syntactic analysis, semantic analysis and manifest generation.

Instance Method Summary collapse

Constructor Details

#initialize(registry:, interface:) ⇒ Suite

Initialize an instance.

Parameters:



23
24
25
26
# File 'lib/highway/compiler/suite.rb', line 23

def initialize(registry:, interface:)
  @registry = registry
  @interface = interface
end

Instance Method Details

#compile(path:, preset:) ⇒ Highway::Compiler::Build::Output::Manifest

Run the compiler suite.

Parameters:

  • path (String)

    Path to the configuration file.

  • preset (String)

    Preset to compile.

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/highway/compiler/suite.rb', line 34

def compile(path:, preset:)

  @interface.header_success("Compiling the configuration file...")

  parser = Parse::Parser.new(interface: @interface)
  parse_tree = parser.parse(path: path)

  analyzer = Analyze::Analyzer.new(registry: @registry, interface: @interface)
  sema_tree = analyzer.analyze(parse_tree: parse_tree)

  builder = Build::Builder.new(interface: @interface)
  manifest = builder.build(sema_tree: sema_tree, preset: preset)

  @interface.success("Successfully compiled the configuration file.")

  manifest

end