Class: Kumi::Core::Analyzer::Passes::SemanticConstraintValidator
- Inherits:
-
VisitorPass
- Object
- PassBase
- VisitorPass
- Kumi::Core::Analyzer::Passes::SemanticConstraintValidator
- 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:
-
Cascade conditions are only trait references (DeclarationReference nodes)
-
Trait expressions evaluate to boolean values (CallExpression nodes)
-
Function names exist in the function registry
-
Expression types are valid for their context
Instance Method Summary collapse
Methods inherited from VisitorPass
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 |