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:

Hachi Memory Leak Test

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:

Hachi Go Args