The TechScript compiler is a highly optimized multi-stage pipeline written entirely in Rust.
graph LR
A[Source Code] --> B[Lexer]
B --> C[Parser]
C --> D[AST]
D --> E[Semantic Analyzer]
E --> F[IR Generation]
F --> G[Optimizer]
G --> H[Bytecode/LLVM Generator]
Converts the raw source character stream into a sequence of structured Token items. It relies on the fast logos crate to scan tokens with minimal allocations.
Takes the token stream and builds an Abstract Syntax Tree (AST). It uses a custom Pratt Parser for expression parsing, ensuring clear operator precedence handling without deep recursion stacks.
Stores the parsed representation. It maintains node IDs and spans matching the source code for error reporting.
Performs scope checks, type resolution, definition tracking, and correctness checks (e.g. validating that constants are not reassigned). It resolves identifiers to their definition locations.
Simplifies the AST into an intermediate representation suitable for optimizations (e.g. dead code elimination, constant folding).
Performs control-flow graph optimizations on the IR.
Generates compiled bytecode files (.txc) containing instructions for the Virtual Machine, or compiles directly to machine code using LLVM.