A strongly-typed language that compiles into PHP
- Download the
cthulhu.phar
executable from the latest release chmod 755 cthulhu.phar
mv cthulhu.phar /usr/local/bin/cthulhu
- Clone this repository
- In the repository root folder, run
composer dump-autoload
- Access the CLI by running
php cli/cli.php
. Or make the program available system-wide by something likeln -s `pwd`/bin/cthulhu.php /usr/local/bin/cthulhu
A simple program looks like this:
use ::Io;
#[entry]
fn main() -> () {
Io::println("hello world");
}
And compiles to the following PHP:
<?php
namespace Hello {
function main() {
print("hello world\n");
}
}
namespace {
\Hello\main();
}
- Modules and types use PascalCase
- Function and variable names use camelCase
These capitalization rules are enforced by the language.
- Basic parsing
- Variable name resolution across module boundaries
- Generate and output PHP code from IR
- Pretty error reporting
- PHP AST rewriter library
- Basic function inlining optimization
- Basic dead-code elimination optimization
- Constant folding optimization
- Type name resolution
- Generic functions
- Pretty multi-line error snippets
- Module dependency linearized and cycle detection
- The Maybe type
- The List type
- Floating point numbers
- Pattern matching
- Recursion
- Tail call optimization
- Closures
- Extensible records
- Inference of record constraints