Awesome
wasm-rocks
Rockstar is a computer programming language designed for creating programs that are also hair metal power ballads.
This is a work-in-progress transpilation for the Rockstar language to WebAssembly. You can compile to WebAssembly's text format and then compile to the binary encoding, which is also executed in the browser.
Get started
yarn install
yarn build
This will create a build
folder, where you can open index.html
in your favorite browser.
How does it work?
The idea is to do a AST-to-AST transformation. The sequence is:
- Parse Rockstar source, which procudes a Rockstar AST
- Transform Rockstar AST to WebAssembly AST
- Emit WebAssembly AST in WebAssembly Text Format (wat) or Binary Format (wasm)
Known limitations
- Rockstar parsing errors could be difficult to understand, because of the composition of many fine-grained parsers
- Rockstar parsing does not support arrays
- Rockstar parsing does not support list arithmetics
- Rockstar strings can only be used in say statements, i.e. outputting something. If you try to do some operations with strings, you might not get what you expect. This is because WebAssembly does not support string operations so far.
- WebAssembly operations are done with 32-bit signed integers only. While floats exist in WebAssembly and Rockstar, I have decided to omit them for easier transformation.
References
- typed-parser A parser library for TypeScript, inspired by elm/parser and Parsec(Haskell)
- Rockstar The Rockstar Language Specification
- Build your own WebAssembly Compiler by Colin Eberhardt
Questions & contribution
You can follow me on Twitter @boyanio and ask me any questions you might have. You can directly open issues here on GitHub or sent a Pull-Requests :-)