As part of working on Ruby on the Smalltalk VM, I am looking at ways of parsing Ruby in Ruby. My starting point is the fact that parse.y is by definition the most correct parsing of Ruby. So I thought, How could I turn parse.y into Ruby? Here is my idea:
- Turn parse.y into parse.c — Already done for me in the stock Ruby distribution
- Use GCC to turn parse.c into parse.rtl (where RTL is the intermediate representation of a program used by GCC) or parse.s (where S is some flavor of assembly)
- Find or write a small RTL or Assembly interpreter in Ruby.
And there you have it. I have reduced a nasty problem (turning YACC/C source) into a less nasty one (interpreting in Ruby a made-to-interpret language).
Now to figure out step #3.
No comments:
Post a Comment