This is a compiler for the ArnoldC language, which is based on the one-liners of Arnold Schwarzenegger. It was developed during some innovation weeks at XING for the purpose of learning Haskell. The original implementation is in Scala and can be found here.
The original version compiles to JVM bytecode while this one converts to JavaScript.
Improvements over the original implementation:
- Scoped blocks.
if-else
andwhile
blocks in the original implementation were not scoped. You could declare a variable within a block and it'd become usable in the whole method after that. - Semantic validation happens before code generation. The original implementation relied on the bytecode library it was using to check for errors and the error reporting is not very nice.
- Nice errors. When an error occurs, the line where the error was found is printed and the actual error is underlined.
TODO:
Read
code generation. Implementation varies depending on the target platform (Node, browser...) so it was left out for the time being.- Replace usage of
String
forText
orByteString
. - Better validation for non-void functions. Currently the last statement of a non-void function has to be a 'return' but an
if-else
with return statements in both blocks should be valid too. - Less unit tests, more integration tests. The unit tests have been time-consuming and they hinder future refactoring efforts. Can check how Idris is developed for reference.
IT'S SHOWTIME
TALK TO THE HAND "hello world"
YOU HAVE BEEN TERMINATED
- Install the Haskell platform: https://www.haskell.org/platform/mac.html
- Clone this repo and run
$ stack build
- This will build a binary
arnoldH
file in the default.stack-work
folder. If you want to install it globally you can runstack install
instead. - In the binary folder (you'll need Node.js)
$ ./arnoldH HelloWorld.arnoldc
$ node HelloWorld.arnoldc.js
hello world