From: Robert Feldt Date: 2004-02-28T19:08:39+09:00 Subject: Re: Ruby Compiler [was Introducing myself and my interest in ruby] Mark wrote: > Mark Hubbart wrote: > >> >> What are the chances of Cardinal having the ability to emit more than >> one type of code structure for the tree it parses? Could it possibly >> end up pluggable? >> >> > It is my intention to do exactly this. > > The plan is to write a class that outputs the correct code structure > and to pass an instance of that class into the compiler. > > This is necessary since at somepoint the intermediate compiler will be > enhanced so that it can accept an abstract syntax tree and generate > the parrot byte code from that. So at that point it will be very > useful to be able to switch from outputting intermediate compiler code > to just serialising the AST. > Concerning this and the discussion about what parser to use I'd say that what we really need is to decide on a common AST representation for Ruby. Then we can have different parser front-ends generating the correct type of AST and have different analysis and code generation back-ends. I'd say that in general though it's not the design of this or the parsing that is the hard part; these things are pretty standard in CS/compiler construction; the hard part is what kind of run-time support is needed (and of course how you implement it) for Ruby semantics. BTW, I have two thesis students working (they'll be starting in 3 weeks actually) on Ruby compilers, one for compiling to MSIL/CIL and one for compiling to llvm. Would be great if all these different Ruby compiler projects could eventually share code although I think it's too early for that at this point... On Slang (Smalltalk subset used in Squeak) and related Ruby ideas you might wanna check out http://www.ce.chalmers.se/~feldt/ruby/ideas/rubyvm/ and specifically "SRuby - A Ruby dialect for low-level programming", http://www.ce.chalmers.se/~feldt/ruby/ideas/rubyvm/sruby.pdf might be a bit dated now but anyway. Regards, Robert Feldt