A basic compiler based off of thejameskyle's super-tiny-compiler

Matt Coles d247c3dd0b Update example.mc лет назад: 9
.gitignore a1ab34b0e4 Add some example code лет назад: 9
README.md 0f8bd9ffe5 Add support for comments and a bit more documentation лет назад: 9
compiler.js 0f8bd9ffe5 Add support for comments and a bit more documentation лет назад: 9
example.mc d247c3dd0b Update example.mc лет назад: 9
stdlib.js dec28251e2 Add some runtime error checking лет назад: 9

README.md

babys-first-compiler

A basic compiler based off of @thejameskyle's super-tiny-compiler, compiles a simple LISP-esque syntax into runnable JS.

Currently supports a few built-ins, add, subtract, assign and log. Hopefully these are self-explanatory, or at least they should be from example.mc. A # denotes that the rest of the line (until the compiler sees \n) as a comment and means that it will not be compiled.

The compiler runs like node compiler.js file.mc where file.mc is the file you wish to compile, and this will produce an output.js which requires stdlib.js to be in the same directory when running for now at least.

Functions and variables are in different scopes, so variables can have the same names as functions - even builtins, thus making (assign assign 5) a totally okay thing to do.

Note that this compiler is not only totally useless, but also horrendously inefficient. Either way it's a fun exercise :)