THP is a statically typed, compiled programming language. Compiles to its own bytecode format, and runs on its own VM.
There is documentation and a WIP spec at https://thp-lang.org.
This program depends on the zig stdlib and thpvm, the virtual machine target.
To run from source:
- Install the Zig programming language.
- Run
zig build runto run the debug build - Run
zig build -Doptimize=ReleaseFastto build the final binary - The binary will be located at
zig-out/bin/thp - Profit
Run thp --help to see usage.
As of v0.0.5 the compiler is able to do:
- Basic u64 arithmetic
- Print strings
- Declare & use variables
var name = "John"
print("Hello, " + name + "!")
Run zig build run -- c /path/to/thp/source/code > out, where out is
the file to write the bytecode to. The compiler always writes to stdout.
See the thpvm package.
Run zig build run -- run /path/to/thp/source/code. It will compile & run the code in one command.
- When importing modules, use
m_<module-name>:const m_parser = @import("./parser.zig"); - Variables that hold a token have a
tok_prefix:const tok_number = ... - Variables that hold a type have a
t_prefix:const t_number = ... - Inside structs, the reference to self is always named
self, and a helper const is created:const Self = @This();