Class: Kumi::Core::Analyzer::Passes::SemanticConstraintValidator

Inherits:
VisitorPass show all
Defined in:
lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb

Overview

RESPONSIBILITY: Validate DSL semantic constraints at the AST level DEPENDENCIES: :definitions PRODUCES: None (validation only) INTERFACE: new(schema, state).run(errors)

This pass enforces semantic constraints that must hold regardless of which parser was used to construct the AST. It validates:

  1. Cascade conditions are only trait references (DeclarationReference nodes)

  2. Trait expressions evaluate to boolean values (CallExpression nodes)

  3. Function names exist in the function registry

  4. Expression types are valid for their context

Instance Method Summary collapse

Methods inherited from VisitorPass

#visit

Methods inherited from PassBase

#debug, #debug_enabled?, #initialize

Methods included from ErrorReporting

#inferred_location, #raise_localized_error, #raise_syntax_error, #raise_type_error, #report_enhanced_error, #report_error, #report_semantic_error, #report_syntax_error, #report_type_error

Constructor Details

This class inherits a constructor from Kumi::Core::Analyzer::Passes::PassBase

Instance Method Details

#run(errors) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb', line 19

def run(errors)
  @registry = state[:registry]
  # Visit value and trait declarations
  each_decl do |decl|
    visit(decl) { |node| validate_semantic_constraints(node, decl, errors) }
  end

  # Visit input declarations
  schema.inputs.each do |input_decl|
    visit(input_decl) { |node| validate_semantic_constraints(node, input_decl, errors) }
  end
  state
end