Commit Graph

3 Commits

Author SHA1 Message Date
d77bf48fe9 Add name-scanning pass to compiler
Compile::discover_locals now takes a Vec<SpExpr> instead of a single
SpExpr. It is also called before the compiler starts building the list
of instructions so that all names in the scope are available at
compile-time.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-02-16 15:19:14 -08:00
b4ae936832 Add comment processing, add a comment to factorial.sy to test it out
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-02-11 18:31:12 -08:00
1f642b9739 Change if function stack ordering, add some basic math ops to Int, add factorial example
* `if` function stack ordering is changed to use condition, if-false,
  if-true (bottom to top). This is so we can pass a value on top of the
  stack directly to a new `if` in a condition, so we don't have to store
  a new value in a new variable.
* Add __splat__ and __minus__ functions to Int
* Add * and - builtins, which call the __splat__ and __minus__ functions
  of the top stack item, respectively.
* Add factorial example because now factorials are possible with this
  skeleton implementation, albeit a little hacky with the recursion.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-02-11 11:10:14 -08:00