CLU on Parrot

kag on 2003-07-22T08:10:37

For reasons that can best be described as "obsessive compulsive", I've decided to port CLU to Parrot.

What is CLU?

  • An early sorta-OO language. It appeared in the late 70s, and was used as a teaching langauge in the early and mid 80s. It has "clusters", which are a set of operations that can be performed on an opaque data abstraction. (Like a class, but no inheritance, and slightly awkward syntax.)
  • A language with some interesting features. Parameterized types; parameterized procedures; iterators; parameterized iterators; exceptions.
  • It's a language I learned to program in once, so therefore it can never be allowed to die.
Why port to Parrot?
  • Clusters and exceptions will test bits of Parrot not heavily stressed yet.
  • While CLU iterators don't have to be implemented with coroutines, they can be. So that gets tested too.
  • It's strongly-typed, and Parrot should have at least one B&D language.
  • I wanna.
  • I never bothered taking the compiler course, so this is my chance to use the Dragon book in anger.
  • I get to play with Parse::RecDescent and Parrot.
Things I have:
  • A Perl6 grammar that looks like it might parse CLU. Useless until Perl6::Rules gets released.
  • A Parse::RecDescent grammar that parses the bits of CLU I've fed into it so far.
  • The outline of the parsetree cleanup code.
  • Vague ideas of how I'm going to do code emission. (I'm going to target IMCC.)
Things I need:
  • A set of parsing tests.
  • Finish the AST cleanup code.
  • Write the code generation.
    • Do I understand the current state of the calling conventions?
    • How is linking supposed to happen?
    • How out-of-date is Perl 6 Essentials already?
  • Implement the builtin types and the standard library (or at least enough of streams to print).
  • Tests, tests, tests


If you ask nicely

broquaint on 2003-07-22T15:50:08

A Perl6 grammar that looks like it might parse CLU. Useless until Perl6::Rules gets released.


Matthijs van Duin has written an alpha version of a perl6 grammar -> perl5 regexp translator and if you ask nicely I'm sure he'll be happy to share. Good luck with CLU!

Re:If you ask nicely

kag on 2003-07-22T18:43:50

Running my alpha rules on an alpha translator. Heh.

I'll stick with Parse::RecDescent for the parser for now. It mostly works, ignoring the bugs I haven't found yet. There's one spot where I mangled the grammar to remove left recursion, but I don't think it changed the semantics.

Another option

educated_foo on 2003-07-22T18:07:13

If you're feeling more ambitious, there's a start at a P6Regex to Parrot compiler in the languages/perl6 subdirectory of the Parrot distribution. It's definitely incomplete, but see the README for what is implemented, and the t/ and example/ directories for some of what can be done. There is also a (perhaps clearer) regex-to-parrot compiler in languages/regex, which could be extended to handle perl6 regexes.

HTH,
/s