This is a REPL for the Zero Sugar compiler. It's a tongue in cheek and incomplete compiler whose goal it is to reduce the syntax surface of the JS language by rewriting certain constructs ("JSSugar") into atomic building blocks ("JS0"). See this TC39 presentation for details.
I made Zero Sugar more as a joke than anything else. I love writing this stuff but despite that I'm not sure I'm on board with the language forcing users into a compile step.
At the time of writing it supports a handful of transformations:
- Transform all loops (`for`, `for-of`, `for-in`, `do-while`) to regular `while` loops
- Transform `switch` statements to `if-else` chains
- Transform `finally` to `catch`
- Transform `continue` to `break`
- Normalize variable declarations define one variable and no patterns
This work is inspired by my Preval project, which tries to reduce the input source to simple building blocks to make optimizations easier by reducing transformation complexity.
This project was written in Rust using the Oxc parser (only) to parse the code. It is compiled to WebAssembly and can run in the browser and node.js.
I don't expect this project to be extended but I'm open to suggestions.