Reimplementation of the compiler used by Creator to have better performance, more helpful error messages, and a more correct output.
The only requirement is the rust toolchain, which can be installed through rustup.
The compiler can be built from source using cargo build --release, which will
place the binary in ./target/release/creator-compiler. The --release flag can
be omitted to generate debug binaries. Additionally, cargo run --release -- [<ARGS>]
can be used as a shortcut to build and run the binary. Running the application
without arguments provides a short description of the application and subcommands,
and using creator-compiler help <command> provides a description and usage
instructions for each command.
The compiler currently supports 3 modes of execution:
- Print architecture specification schema to
stdout:creator-compiler schema - Validate architecture specification file:
creator-compiler validate <architecture.json> - Compile assembly input and print the result to
stdout:creator-compiler compile <architecture.json> <assembly.s>- The
-v/--verboseflag can be used to also print the parsed AST
- The
JS bindings are supported through wasm. In order to build them, the code must first
be compiled into a wasm package with wasm-pack.
This can be done using wasm-pack build --target [web|nodejs], where the target
depends on if the code is being compiled for NodeJS or a browser. The flag --dev
can be added to generate a debug module with a shorter compile time by omitting optimizations.
Alternatively, the provided build script (./build.sh) can be used to build both targets.
After the package has been built, it can be loaded by requiring the generated .js
file as a module. The js_example/ directory contains a working example of how to
use the generated package, both for the web and Node.js:
index.html: entry point for the web example. Can't be directly opened in a browser due to CORS limitations. Python can be used to start a development server withpython3 -m http.server 8080which allows loading the page atlocalhost:8080/js_example.web.js: main module for the web example, shows how to load the package in the webnode.js: main module for the Node.js example, shows how to load the package in Node.jscompiler.mjs: module responsible for interaction with the package, shows how to use the provided API