https://github.com/sonota88/ruccola
A self-hosting toy compiler written in Ruby
https://github.com/sonota88/ruccola
compiler programming-language ruby
Last synced: 11 months ago
JSON representation
A self-hosting toy compiler written in Ruby
- Host: GitHub
- URL: https://github.com/sonota88/ruccola
- Owner: sonota88
- License: mit
- Created: 2021-03-06T01:39:51.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-05T23:22:49.000Z (about 2 years ago)
- Last Synced: 2025-04-15T16:15:25.681Z (11 months ago)
- Topics: compiler, programming-language, ruby
- Language: Ruby
- Homepage:
- Size: 878 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```