Skip to content

Commit 44d26e2

Browse files
authored
feat: DSL semantic checking analysis (#24)
## Problem We want to reject DSL programs that are semantically incorrect. This PR analyzes the parsed AST and rejects if an error is detected. ## Summary of changes - Parser bug fixes - Implemented `SemanticAnalyzer` to perform comprehensive static analysis on DSL programs - Added validation for properties: - Ensures property types are valid (basic types, maps, arrays, tuples) - Rejects function types and operators in properties - Added validation for operators: - Prevents duplicate operator names - Validates field types for both scalar and logical operators - Ensures logical operators have all required derived properties - Verifies derived properties match declared logical properties - Added scope-based identifier validation: - Maintains a stack of scopes for variable declarations - Prevents duplicate identifiers in the same scope - Validates variable references exist in accessible scopes - Added recursive expression validation: - Validates all sub-expressions in compound expressions - Handles various expression types (variables, function calls, conditionals, etc.) - Manages scope for closures and pattern matching - Added comprehensive test suite: - Tests for valid DSL programs - Tests for various error conditions (duplicate names, invalid types, etc.) - Tests for scope handling and identifier validation The semantic analyzer provides early error detection for DSL programs, helping users identify issues before runtime.
1 parent baa09fc commit 44d26e2

File tree

15 files changed

+917
-46
lines changed

15 files changed

+917
-46
lines changed

optd-core/src/dsl/analyzer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod semantic;

0 commit comments

Comments
 (0)