Jack is a toy, java-like, object oriented language as presented in Nand2Tetris. This project is a 2 stage compiler written for the Jack language. The compiler generates code for a stack-based virtual machine, then translates it to Hack assembly which can be executed on the Nand2Tetris CPU emulator.
A Hack assembler is also included for completeness but is not strictly necessary since the cpu emulator understands both assembly code and machine code.
To compile a directory containing *.jack classes
jack myProgram/To compile a jack source file
jack myProgram/Main.jackTo dump the token list produced by the parser
jack -v -t MainT.xml myProgram/Main.jackTo dump the AST produced by the parser
jack -v -a Main.xml myProgram/Main.jackTo compile a directory containing *.vm files
jack -o examples/FibonacciElementTo compile a single *.vm file
jack -o examples/BasicLoop/BasicLoop.vmTo specify the output filename
jack -o -f fib.asm examples/FibonacciElementTo dump debug info to STDOUT
jack -o -v -f fib.asm examples/FibonacciElementTODO
To build the jack compiler from source
mix escript.buildIf available in Hex, the package can be installed
by adding jack to your list of dependencies in mix.exs:
def deps do
[
{:jack, "~> 0.1.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/jack.