Use Hachi
Make sure clang++ and make are installed.
git clone https://gitlab.com/hachi-lang/hachi
cd hachi
make
There is now an install script accessible. To install, just run:
curl -fsSL https://hdev.run/install | bash
Thatโs it. Itโs suggested that your Hachi executable be placed in your PATH somewhere. Additionally, set HACHI_LIB to the lib
directory. There are plans in the future to manage this more efficiently by way of running install scripts. When importing modules, Hachi will look in the HACHI_LIB first, and if the module doesnโt exist there then imports become relative paths.
$ hachi -h
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โขโกดโฃโ โ โ โ โ โฃโฃคโ โ โ โ
โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โกธโ โ โฃโ โ โ โฃดโกโ โกโ โ โ
โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โขโกโ โ โฃธโกฟโฃฟโกโขฟโฃโ โกโ โ โ
โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โฃธโฃโฃผโฃพโฃปโ โ โ โ โ โ โ
โ โ โ
โ โ โขโ โขโ โ โ โ โ โ โ โ โ โ โ โ โ โขฐโฃฟโฃปโ ทโ โ โ จโฃฏโ โ โ ธโ โกโ โ โ
โ โฃฐโ โขโกโ โ โ โ โ โ โ โ โ โ โ โ โ โฃฟโฃฟโกโ โ โ โขโกโ โ โ โข โฃพโฃทโ โ
โ โกโข โฃฟโฃงโ โ โ โ โ โ โ โ โ โ โ โ โขฐโฃฟโฃฟโฃทโ โ โ โ โ โขโฃคโฃโฃโกฝโ โ โ
โ โขกโ จโฃโฃพโฃถโฃโฃโขโฃโฃโฃคโฃคโฃคโฃคโฃคโฃถโฃฟโฃฟโฃฟโฃฏโฃทโกโ โ โ จโ โ จโขดโ โ โ โ โ
โ โ โ ขโฃโฃปโกพโขฟโฃฟโขฟโฃโฃฟโฃปโฃฝโฃปโฃฝโขฏโฃโฃทโฃโฃพโฃณโฃงโ โ โ โ โ โ โขธโ โ โ โ โ
โ โ โ โ โ โขฉโฃฟโขฏโฃฟโฃโฃฏโกทโฃฟโฃฝโขพโฃโกฟโฃพโกฝโฃพโฃปโกโกโ โ โ โ โ โขโ โ โ โ โ
โ โ โ โ โ โฃพโฃโฃฏโฃทโฃปโฃฝโฃฟโฃณโฃฏโขฟโฃโฃฟโฃณโกฟโฃฏโฃทโ โ โ โ โ โ โกฐโ โ โ โ โ โ
โ โ โ โ โ โฃฟโฃฏโฃโฃพโกฝโกปโ คโ โฃโ โ โ โ โฃฟโฃณโกฟโ โกโ โกโฃโขโกโ โ โ โ โ โ
โ โ โ โ โก โ ฟโ ทโ โฃโ โกโ โ โข โ โ โ โฃฆโ โ โ โข โ ฅโกโ โ
โขธโ โ โ โ โ โ โ
โ โ โ โกโ โขโกดโ โ โฃโ โขโกโ โ โ โ โ ธโกโ โ โกธโ โกโ โ โกโ โ โ โ โ โ โ
โ โ โ โกโ โกโ โ โ โ โกโ โฃโกโ โ โ โ โกโ โ โกโ โขนโ โ โฃงโ โ โ โ โ โ โ
โ โ โขฐโ โขโ ฑโขโ โ โ โ โขโฃโฃโกงโ โ โ โขนโ โ โขโ โ โขโ โ ธโ คโขโ โ โ โ โ
โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โฃโ โขโขโกโ โ โ คโ คโ ญโ โ โ โ โ
โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ
โ ๐๐ WELCOME TO HACHI! ๐๐ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฅ Hachi v0.2.2 โ Code like a legend! ๐ฅ
๐ Author: Mike Curnow
๐ Usage : hachi [โ options] [๐ source.hachi] [โ options]
โจ OPTIONS โจ
-v, --version Show Hachi version and exit
-h, --help Show this help screen
-d, --debug Enter debug mode before execution
-i, --init ๐ง Bootstrap a new Hachi project here
-cpp <file> โ๏ธ Emit transpiled C++ to <file>
-b, --build <file> โ๏ธ Compile Hachi into a binary
-buildml <file> ๐ Leak-detector build (memory insights)
-go โถ๏ธ Build & run on the fly
-cf <flags> ๐ ๏ธ Pass custom flags to your C++ compiler
-target <triple> ๐ฏ Cross-compile target (arch triple)
[cpp] -cc <flags> ๐ฆ Hachi-driven C++ build commands
-c <code> ๐ Run inline Hachi snippet & exit
๐ก Pro Tip: Mix & match flags to suit your workflow. Stay Legendary! ๐ก
After installing Hachi, you probably gonna want to run this puppy. So to start off, you can simply run hachi -h
to see all commands you can run. Here weโll cover general commands to use.
Compile
-build
This builds the executable from a defined Hachi file.
Syntax:
hachi <filename>.8 -build <program-name>
Example:
# Build "skate"
hachi sk.8 -build skate
# Run "skate"
./skate
-buildml
This builds the executable from a defined hachi file and checks for memory leaks.
This is intended mainly to use on hachi code which makes use of the outerCPP
and innerCPP
commands since any raw C++ code you may choose to embed can introduce unsafe contexts which are outside the coverage of hachiโs own memory safety mechanisms. Essentially C++ code used in either of the aforementioned commands is not included in hachiโs auto-free mechanism as itโs an unsafe advanced mechanism, and the -buildml
flag allows the you to see where you may have introduced unsafe code that you may choose to correct.
NOTE:
Hachiโs own print
statements can be flagged under this mechanism if youโre printing literals. Best practice is just to use the shout
function.
Another memory safety item to disclose here is that hachi dynamically assigns memory to objects. Currently running with -buildml
flag will still flag areas where memory is being dynamically allocated. Hence itโs recommended use is only for when youโre code includes raw C++ code.
Syntax:
hachi <filename>.8 -buildml <filename>
Example:
hachi sk.8 -buildml skate
Screenshot:
Cross-Compilation
Hachi now supports cross-compilation between various architectures by specifying a target triple after the -target
flag.
Syntax:
hachi <filename>.8 -build <program-name> -target <target-triple>
Example:
hachi sk.8 -build skate -target aarch64-unknown-linux-gnu
More Commands
-cpp
Translates Hachi file to a C++ file.
Syntax:
hachi <filename>.8 -cpp <filename>.cpp
Example:
hachi sk.8 -cpp skate.cpp
Linux tested, other OSโs will be soon.
-d/-debug
Runs Hachi command with a visual debug output including AST and AT.
Syntax:
hachi <filename>.hachi -d <other-commands>
Example:
hachi print.hachi -d
โญโโโโโโโโโโโโโโฎ
โโโโโโโฅ print.hachi โโโโโโโ
โ โฐโโโโโโโโโโโโโโฏ โ
โ 1 one: 1 โ
โ 2 print: one.String โ
โ 3 # Test comment โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โญโโโโโโโโโโโโโโโโโโโโโโโฎ
โ abstract syntax tree โ
โฐโโโโโโโโโโโโโโโโโโโโโโโฏ
โโโดโโโโโโโโโโโโโโโโโโโโ
โ โโโโโฎ โ
โ โญโโโดโโโฎ โ
โ โ one โโฎ โ
โ โฐโโโโโโฏโ โ
โ โญโโดโโฎ โ
โ โ 1 โ โ
โ โฐโโโโฏ โ
โ โโโโโโฎ โ
โ โญโโโโดโโโโฎ โ
โ โ print โโโโโโฎ โ
โ โฐโโโโโโโโฏ โ โ
โ โญโโโโดโโโโโฎ โ
โ โญโค String โ โ
โ โโฐโโโโโโโโโฏ โ
โ โญโโโดโโโฎ โ
โ โ one โ โ
โ โฐโโโโโโฏ โ
โโโโโโโโโโโโโโโโโโโโโโโ
โญโโโโโโโโโโโโโโฎ
โ action tree โ
โฐโโโโโโโโโโโโโโฏ
โโโดโโโโโโโโโโโโโโโโโโโโโโโ
โ โโโโโโโฎ โ
โ โญโโโโโดโโโโโฎ โ
โ โ set one โโโฎ โ
โ โฐโโโโโโโโโโฏInt โ
โ โญโโดโโฎ โ
โ โ 1 โ โ
โ โฐโโโโฏ โ
โ โโโโโโฎ โ
โ โญโโโโดโโโโฎ โ
โ โ print โโโโโโโโโฎ โ
โ โฐโโโโโโโโฏ String โ
โ โญโโโโดโโโโโฎ โ
โ โญโโค String โ โ
โ Intโฐโโโโโโโโโฏ โ
โ โญโโโโโดโโโโโฎ โ
โ โ get one โ โ
โ โฐโโโโโโโโโโฏ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
...
-cf
Compile Flags. Allows you to specify C++ compiler flags in your build.
Syntax:
hachi <filename>.8 -cf <flags> -build <program-name>
Example:
hachi coolProgram.8 -cf "-std=c++17 -ldl" -build coolProgram
-cc
Compile C/C++ files as build tool. Allows you to specify C/C++ files and compiler flags in your build.
Syntax:
hachi <filename>.cpp -cc "<compiler-flags> <program-name"
Example:
hachi yoloSwag.cpp -cc "-std=c++17 -ldl -o yoloSwag"
-c
Inline code execution support for Hachi code, similar to pythonโs -c command. You can run one-liner code straight from the hachi
command.
Syntax:
hachi -c <code>
Example:
hachi -c ">@ \"fmt/fmt\" shout: \"Hachi is awesome!\""
Run
Hachi files can be ran instead of compiled, similar to how Goโs go run
command works. In short, it compiles the Hachi file and executes it.
-g/-go
This is a one-liner Hachi command compiles and executes the program. When used with arguments, be sure to offset args by 3 in your code.
Syntax:
hachi <filename>.8 -go <arguments>
Example:
hachi cliArgs.8 -go These Are Arguments
Screenshot: