Write a Brainfuck-to-Ruby compiler.
On 5/3/11 12:46 PM, Josep M. Bach wrote:
Hello there,
This might not be the right place to ask this (please tell me whether
it should be better to post this in the IRC or wherever else), but
here I go:
I'm going with my first try to interface a programming language with
the Rubinius VM. For starters, my choice is Brainfuck, since it's a
dead-simple language.
As far as I know, I only need a table of cells and a pointer, and
almost map the BF tokens (>, <, +, -...) to the VM instructions. I am
a bit lost, since I practically don't know where to start. I've seen
in other projects there is a Generator class sublassing
Rubinius::Generator, and each AST node implements a #bytecode method
that calls the instructions on the generator. How does it work
exactly? I don't know how to set an initial state (the table of cells
and the pointer pointing to cell 0).
How would you implement this? Any feedback is appreciated :)
Thanks!
--
--- !ruby/object:MailingList
name: rubinius-dev
view: http://groups.google.com/group/rubinius-dev?hl=en
post: [email protected]
unsubscribe: [email protected]
--
--- !ruby/object:MailingList
name: rubinius-dev
view: http://groups.google.com/group/rubinius-dev?hl=en
post: [email protected]
unsubscribe: [email protected]