A simple programming language with ML-inspired syntax and an MLIR/LLVM backend.
- ML-inspired syntax: Haskell-style definitions, type annotations, first-class functions
- Type inference: Hindley-Milner style type inference with polymorphism
- MLIR backend: Custom Polang dialect lowered through MLIR to LLVM IR
- Interactive REPL: JIT compilation with state persistence
- Comprehensive testing: Unit tests, lit tests, sanitizers, and coverage
The project uses Docker for a consistent build environment:
# Start the development container
docker/docker_run.sh
# Configure and build (inside container)
cmake -S. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_PREFIX_PATH="/usr/lib/llvm-20"
cmake --build build -j$(nproc)Or from outside the container:
docker exec polang cmake -S. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_PREFIX_PATH="/usr/lib/llvm-20"
docker exec polang cmake --build build -j$(nproc)Interactive REPL:
./build/bin/PolangReplExample session:
$ ./build/bin/PolangRepl
Polang REPL (type 'exit' or Ctrl+D to quit)
> 1 + 2
3 : i64
> x = 5
> x * 2
10 : i64
> double(n) = n * 2
> double(21)
42 : i64
> if x > 3 then true else false
true : bool
> exit
Compile to LLVM IR:
echo "x = 42" | ./build/bin/PolangCompilerRun a source file:
./build/bin/PolangRepl example/fibonacci.po# Run all tests
ctest --test-dir build --output-on-failure
# Run example programs
for f in example/*.po; do echo "=== $(basename $f) ==="; ./build/bin/PolangRepl "$f"; done| Document | Description |
|---|---|
| Syntax | Language syntax reference |
| TypeSystem | Type system and inference |
| Architecture | Project structure, components, MLIR lowering |
| Building | Build instructions, dependencies |
| Development | Code style and tooling |
| Testing | Test infrastructure and CI/CD |
polang/
├── parser/ # Lexer, parser, type checker
├── compiler/ # LLVM IR compiler
├── repl/ # Interactive REPL with JIT
├── mlir/ # Polang MLIR dialect and lowering
├── tests/ # Unit tests and lit tests
├── example/ # Example programs
├── doc/ # Documentation
├── scripts/ # Development scripts
└── docker/ # Docker build environment
- CMake 3.20+
- LLVM 20+ with MLIR
- Bison and Flex
- GCC or Clang
See LICENSE for details.