Class: Highway::Compiler::Analyze::Analyzer
- Inherits:
-
Object
- Object
- Highway::Compiler::Analyze::Analyzer
- Defined in:
- lib/highway/compiler/analyze/analyzer.rb
Overview
This class is responsible for semantic analysis of a parse tree. This is the second phase of the compiler.
Instance Method Summary collapse
-
#analyze(parse_tree:) ⇒ Highway::Compiler::Analyze::Tree::Root
Analyze the parse tree.
-
#initialize(registry:, interface:) ⇒ Analyzer
constructor
Initialize an instance.
Constructor Details
#initialize(registry:, interface:) ⇒ Analyzer
Initialize an instance.
23 24 25 26 |
# File 'lib/highway/compiler/analyze/analyzer.rb', line 23 def initialize(registry:, interface:) @registry = registry @interface = interface end |
Instance Method Details
#analyze(parse_tree:) ⇒ Highway::Compiler::Analyze::Tree::Root
Analyze the parse tree.
The semantic analyzer validates the parse tree in terms of content, performs segmentation of values and resolves steps against the registry.
The semantic analyzer produces a semantic tree which is then used by build phase to generate a manifest.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/highway/compiler/analyze/analyzer.rb', line 40 def analyze(parse_tree:) sema_tree = Analyze::Tree::Root.new() sema_tree.add_stage(index: 0, name: "bootstrap", policy: :normal, ) sema_tree.add_stage(index: 1, name: "test", policy: :normal) sema_tree.add_stage(index: 2, name: "deploy", policy: :normal) sema_tree.add_stage(index: 3, name: "report", policy: :always) sema_tree.default_preset = "default" validate_preset_names(parse_tree: parse_tree) validate_variable_names(parse_tree: parse_tree) validate_variable_values(parse_tree: parse_tree) validate_step_names(parse_tree: parse_tree) validate_step_parameter_values(parse_tree: parse_tree) resolve_variables(parse_tree: parse_tree, sema_tree: sema_tree) resolve_steps(parse_tree: parse_tree, sema_tree: sema_tree) validate_variable_references(sema_tree: sema_tree) sema_tree end |