A (very, very) basic compiler written in ruby. It compiles code written in a toy language to javascript.
It should probably be called a "transpiler" 🤭
compiler.rb # The compiler
example # The toy language
README.md # Well... Read it!!!
You need both a ruby
and node
interpreter for this to work 🙃
ruby compiler.rb | node
# 3 -> what you should get/see :-)
Feel free to change the literal arguments to f
on Line #5.
Example:
TEST = 'console.log(f(4, 22));'
This work is based on the excellent A Compiler From Scratch screencast by Gary Bernhardt.