|
|
|
|
|
|
2
|
|
2
|
|
|
3
|
A basic compiler based off of @thejameskyle's super-tiny-compiler, compiles a simple LISP-esque syntax into runnable JS.
|
3
|
A basic compiler based off of @thejameskyle's super-tiny-compiler, compiles a simple LISP-esque syntax into runnable JS.
|
|
4
|
|
4
|
|
|
5
|
-Currently supports a few built-ins, `add`, `subtract`, `assign`, `def` and `log`. Hopefully these are self-explanatory, or at least
|
|
|
|
6
|
-they should be from `example.mc`. A `;` denotes that the rest of the line (until the compiler sees `\n`) as a comment and
|
|
|
|
|
|
5
|
+Currently supports quite a few builtins, which you can mostly see in the examples for now, documentation is in the works if you're interested. Hopefully most of these are self-explanatory from `example.mc` and `fizzbuzz.mc`. A `;` denotes that the rest of the line (until the compiler sees `\n`) as a comment and
|
|
7
|
means that it will not be compiled.
|
6
|
means that it will not be compiled.
|
|
8
|
|
7
|
|
|
9
|
-In addition to the regular include(coming soon), there is also a preprocessing directive called `` `source <filename> `` which can be used
|
|
|
|
10
|
-to just directly insert the contents of `<filename>` into the file. Instead of wasting the compilers energy checking for circular
|
|
|
|
11
|
-sources, you have two options, to not be so stupid or wait for the call stack to overflow.
|
|
|
|
|
|
8
|
+In addition to the regular include, there is a preprocessing directive called `` `source <filename> `` which can be used
|
|
|
|
9
|
+to just directly insert the contents of `<filename>` into the file. Instead of wasting the compilers energy checking for circular sources, you have two options, to not be so stupid or wait for the call stack to overflow.
|
|
12
|
|
10
|
|
|
13
|
The compiler runs like `node compiler.js file.mc` where `file.mc` is the file you wish to compile, and this will produce a
|
11
|
The compiler runs like `node compiler.js file.mc` where `file.mc` is the file you wish to compile, and this will produce a
|
|
14
|
-`file.mc.js` which requires the `lib` to be present in the same directory when running for now at least.
|
|
|
|
|
|
12
|
+`file.mc.js` which requires the `libjs` directory to be present in the same directory when running for now at least.
|
|
15
|
|
13
|
|
|
16
|
-Functions and variables are in different scopes, so variables can have the same names as functions - even builtins,
|
|
|
|
17
|
-thus making `(assign assign 5)` a totally okay thing to do.
|
|
|
|
|
|
14
|
+Functions and variables are in different scopes, so variables can have the same names as functions - even builtins -
|
|
|
|
15
|
+thus making `(assign assign 5)` a totally okay thing to do. However note that builtins and defined functions are in the same scope no matter what and attempting to define a function with the same name as a builtin will not work properly.
|
|
18
|
|
16
|
|
|
19
|
Note that this compiler is not only totally useless, but also horrendously inefficient. Either way it's a fun exercise :)
|
17
|
Note that this compiler is not only totally useless, but also horrendously inefficient. Either way it's a fun exercise :)
|