|
1 |
| -# Interpreter |
| 1 | +# Analyzer Module |
2 | 2 |
|
3 |
| -The Interpreter takes in the AST and |
| 3 | +## Overview |
| 4 | +The analyzer module performs static analysis and type checking on the HelixQL AST, ensuring queries are grammatically and semantically correct before code generation. |
| 5 | + |
| 6 | +## Structure |
| 7 | + |
| 8 | +### Core Components |
| 9 | +- **`mod.rs`** - Main analyzer entry point, orchestrates validation passes |
| 10 | +- **`types.rs`** - Type system definitions and type inference structures |
| 11 | +- **`diagnostic.rs`** - Diagnostic messages and error reporting |
| 12 | +- **`error_codes.rs`** - Error code definitions and messages |
| 13 | +- **`errors.rs`** - Error handling utilities |
| 14 | +- **`fix.rs`** - Auto-fix suggestions for common errors |
| 15 | +- **`pretty.rs`** - Pretty printing utilities for diagnostics |
| 16 | +- **`utils.rs`** - Helper functions for analysis |
| 17 | + |
| 18 | +### Validation Methods (in `methods/`) |
| 19 | +- **`schema_methods.rs`** - Schema validation and field lookup building |
| 20 | +- **`query_validation.rs`** - Query structure and parameter validation |
| 21 | +- **`migration_validation.rs`** - Schema migration consistency checks |
| 22 | +- **`statement_validation.rs`** - Statement-level validation |
| 23 | +- **`traversal_validation.rs`** - Graph traversal operation validation |
| 24 | +- **`graph_step_validation.rs`** - Individual graph step validation |
| 25 | +- **`object_validation.rs`** - Object literal and remapping validation |
| 26 | +- **`infer_expr_type.rs`** - Expression type inference |
| 27 | +- **`exclude_validation.rs`** - Field exclusion validation |
| 28 | + |
| 29 | +## Analysis Flow |
| 30 | + |
| 31 | +1. **Input**: Parsed AST from the parser module |
| 32 | +2. **Schema Validation**: Verifies schema definitions are valid |
| 33 | +3. **Migration Validation**: Ensures migrations are consistent across versions |
| 34 | +4. **Query Validation**: Type-checks queries against schemas |
| 35 | +5. **Output**: Diagnostics (errors/warnings) and validated AST for code generation |
| 36 | + |
| 37 | + |
| 38 | +## Error Handling |
| 39 | +- Error codes provide consistent, searchable error identification |
| 40 | +- Diagnostics include source location for precise error reporting |
| 41 | +- Fix suggestions help users resolve common issues |
0 commit comments