Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sonota88/ruccola

A self-hosting toy compiler
https://github.com/sonota88/ruccola

compiler programming-language ruby

Last synced: 1 day ago
JSON representation

A self-hosting toy compiler

Awesome Lists containing this project

README

        

This is my hobby project to learn compiler implementation.

素朴な自作言語Ruccolaのコンパイラをセルフホストした
https://qiita.com/sonota88/items/1e683276541cf1b87b76

See also: [selfhost/README.md](selfhost/README.md)

# Example

[examples/fibonacci.rcl](examples/fibonacci.rcl)

```ruby
#include ../selfhost/lib/std.rcl

def fib(n)
case
when (n < 0)
_panic();
when (n < 3)
return n;
else
return fib(__sub(n, 2)) + fib(__sub(n, 1));
end
end

def main()
var n = 0;

while (n < 21)
print_i(n);
putchar(C_SPC());
print_i(fib(n));
putchar(C_LF());

n = n + 1;
end
end
```