Experimental, compiled, strongly-typed, functional, system programming language that inherits memory regions ideas, focused on dev experience, extensibility and reliability.
Mainly inspired by Rust's type system, Verona's and Pony's memory managment systems, Python's simplicity, Koka's effect system, and Zig's comptime.
This is the roadmap for implementing a minimal working framework that will serve as the base for the proposed innovative features. Basically, this is the way to create a "Rustic C" compiler.
- Lexer & tokens stream
- AST definition
- AST parser
- HIR/OptHIR/THIR definitions
- AST to OptHIR translator
- OptHIR to THIR translator (type inference)
- MIR definition
- THIR to MIR lowering
- MIR to LLVM-IR lowering
- LLVM-IR to object file compilation
- object files linking
For cli help reference:
cargo run --helpFor example, following command will parse test.sm file, analyse, stop on HIR stage and emit the result in a text format:
cargo run emit test.sm --stage hir --format text HIR Codegen (LLVM)
________________ _____________________________________
| | | |
code -> tokens -> AST -> | OptHIR -> THIR | -> MIR -> | LLVM-IR -> ASM -----> artifacts ----|--> linker -> Exe
| | | |_____________|__| | | | (.o/.a/.bc/.wasm) |
| |----> CST | | |_____________|_______________________|
| | | | |
| | | | |
Visible Visible Visible Visible Visible
in IDE in IDE in IDE in IDE in IDE
AST Abstract Syntax Tree
CST Concrete Syntax Tree
IR Intermediate Representation
HIR High-level IR
OptHIR Optionally typed HIR
THIR Typed HIR
MIR Middle-level IR
Codegen Code Generation
LLVM A external compiler backend
ASM Assembler
Exe Executable file
CLI Command Line Interface
ast/- Abstract Syntax Tree + Parsercli/- Command Line Interface wrappercodegen/- LLVM-IR + translator from MIR to LLVM-IR + artifacts generation utilitiesdiagnostic/- Utilities to track errors during compilation process likeSpan, code snippets, and errors containerexamples/- Plasm language exampleshir/- High-level IR, OptHIR, THIR + translator from AST + types annotatormir/- Middle-level IR + translator from HIRorchestrator/- Compilation flow management utilities (Parallel compilation, linkers controller, configuration reader)tokenizer/- Tokens description + lexer + from bytes to tokens stream
Internal dependencies:
orchestrator diagnostic -> tokenizer -> ast -> hir -> mir -> codegen
^ | | | ^ | ^ | | |
| | | | | | | | | |
| |_|____________|________|_|____| | | |
| | | | | | |
|______________|____________|__________|______|_____|________|