Parrot Languages -- Prolog?

Ovid on 2005-05-14T20:27:06

Today I played around a bit with the Parrot languages. Regrettably, the documentation on them seems a bit, er, lacking. It would be nice to find a more straightforward guide to converting simple languages. The Scheme example seemed the most straightforward and even that has documentation errors and is incomplete. I've read through Sugalski's Building a Parrot Compiler, but regrettably, I can't use Perl 5 to boostrap this because in Prolog, the code and the data are pretty much the same thing and the code needs to be able to parse Prolog and possibly modify itself at runtime. Thus, I think my parser needs to be in Parrot.

After a bit of research, I think I've determined my main obstacle for porting AI::Prolog to Parrot. Specifically, I can't just do a straight code transformation. A machine must be written in Parrot and higher level "logic opcodes" must be available for a Prolog interface to call. That, of course, is exactly how the Warren Abstract Machine does things. I need a six-month sabbatical. Damn.

In other news, sitting on my hard-drive now is a version of AI::Prolog with anonymous variables working. Previously, you had to make up variable names for every variable, even if you didn't need it. That's no longer a requirement. However, it did show the parser limitations again. I have to make things aware of their context and a recursive descent parser that inches through, one character at a time doesn't do that too well. However, it does appear to work despite being a hack. Internally these are regular variables but they assign unique names for you. However, this still means the engine tries to unify them. What I really need is an anonymous variable class which doesn't unify with anything. That would be much cleaner and faster.

And what I just realized is that not only am I sitting here talking about writing a compiler for a language, I now know how to go about it, albeit clumsily. Wow. I feel a bit weird about that though I'm not quite sure why.