Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiling to ParrotVM

0 views
Skip to first unread message

K Stol

unread,
Dec 17, 2002, 7:07:55 AM12/17/02
to perl6-i...@perl.org
Hi there,

After doing some reading about Parrot, I got very interested. I'd like to write some kind of compiler for my Bacherlor's in Computer Science. I'm thinking of a compiler for Tcl which produces Parrot Assembly code, but the source language (which will be compiled) is not definite yet.

I have basic knowledge on compiler construction, but I think I can make a good start. The implementation language I'll use will most probably be C.

Does anybody have a good suggestion or tips to help me get further? Or is anybody interested in this as well?

Thnx

Klaas-Jan

David Robins

unread,
Dec 17, 2002, 9:12:45 AM12/17/02
to K Stol, perl6-i...@perl.org
On Tue, 17 Dec 2002, K Stol wrote:
> After doing some reading about Parrot, I got very interested. I'd like to
> write some kind of compiler for my Bacherlor's in Computer Science. I'm
> thinking of a compiler for Tcl which produces Parrot Assembly code, but
> the source language (which will be compiled) is not definite yet.

> I have basic knowledge on compiler construction, but I think I can make a
> good start. The implementation language I'll use will most probably be C.

The rest of parrot is in C, so that's a good choice, especially if you want
your code added to /languages in the parrot tree.

> Does anybody have a good suggestion or tips to help me get further? Or is
> anybody interested in this as well?

Get the Tcl source. Keep current with Parrot source
(http://dev.perl.org/cvs/) and of course being on this list is a good step.
You can probably start with Tcl's own lexer/parser and AST (assuming it
builds one), and traverse the AST to write out pasm/imcc code. I'm doing
some work with Ruby -> Parrot ("Cardinal"), or was until I got sidetracked
by the ops' destination values being unpredictable, and then sidetracked
again into working on a PHP to Perl translator.

Parrot's a bit of a moving target, though, so be prepared to have to make
changes as the language/platform evolves. You're fortunate in that Tcl's
fairly simple.

Dave
Isa. 40:31

Gopal V

unread,
Dec 17, 2002, 9:54:18 AM12/17/02
to perl6-i...@perl.org
If memory serves me right, K Stol wrote:
> I'm thinking of a compiler for Tcl which produces Parrot Assembly code,
> but the source language (which will be compiled) is not definite yet.

Instead of generating Parrot assembly, you might find it easier to
generate imcc code which is a simplified form . This takes care of the
register allocation involved in Parrot assembly generation and spill
over of registers. Writing your own register allocator is not advisable
(unless you want to tear your hair out in bits & peices).

> I have basic knowledge on compiler construction, but I think I can make
> a good start. The implementation language I'll use will most probably be C.

If you're going to use C , please take a look at TreeCC which is a
compiler tool for simplifying Syntax Tree traversal . It was developed
for the DotGNU compiler collection and being used to build the C# & C
compilers now. (http://www.southern-storm.com.au/treecc.html)

flex+bison+treecc has been demonstrated with multiple codegens (IL,Parrot)
at http://symonds.net/~gopalv82/code/expr_compiler.tgz

Hope it helps,
Gopal
--
The difference between insanity and genius is measured by success

Tanton Gibbs

unread,
Dec 17, 2002, 12:46:04 PM12/17/02
to perl6-i...@perl.org
I also have a C++ compiler under development that uses flex + btyacc +
TreeCC that I can send on request. I must say that TreeCC is an extremely
nice system and one I highly recommend.

Dan Sugalski

unread,
Dec 19, 2002, 1:23:41 PM12/19/02
to David Robins, K Stol, perl6-i...@perl.org
At 9:12 AM -0500 12/17/02, David Robins wrote:
>On Tue, 17 Dec 2002, K Stol wrote:
>> After doing some reading about Parrot, I got very interested. I'd like to
>> write some kind of compiler for my Bacherlor's in Computer Science. I'm
>> thinking of a compiler for Tcl which produces Parrot Assembly code, but
>> the source language (which will be compiled) is not definite yet.
>
>> I have basic knowledge on compiler construction, but I think I can make a
>> good start. The implementation language I'll use will most probably be C.
>
>The rest of parrot is in C, so that's a good choice, especially if you want
>your code added to /languages in the parrot tree.

If he gets a Tcl compiler, I'll take it in any language he wants to
write it in, up to and including Prolog. (Though I admit that, at
some point, we should split the languages out of the base parrot
tree. Not for a while though)

> > Does anybody have a good suggestion or tips to help me get further? Or is
> > anybody interested in this as well?
>
>Get the Tcl source. Keep current with Parrot source
>(http://dev.perl.org/cvs/) and of course being on this list is a good step.
>You can probably start with Tcl's own lexer/parser and AST (assuming it
>builds one), and traverse the AST to write out pasm/imcc code. I'm doing
>some work with Ruby -> Parrot ("Cardinal"), or was until I got sidetracked
>by the ops' destination values being unpredictable, and then sidetracked
>again into working on a PHP to Perl translator.

Damn, we need to nail down which ops overwrite their destination and
which ones store into their destination. I'll start getting that
properly defined.

>Parrot's a bit of a moving target, though, so be prepared to have to make
>changes as the language/platform evolves. You're fortunate in that Tcl's
>fairly simple.

I should point out that it's not moving *that* much. The core op set
hasn't changed in quite a while, though the newer ops do go through a
round or two of fiddling before they settle down.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Will Coleda

unread,
Dec 20, 2002, 11:22:55 AM12/20/02
to K Stol, Dan Sugalski, David Robins, perl6-i...@perl.org
I still have the single pass (that is, no eval) tcl to pasm
parser/compiler that I wrote in perl5. I had only defined a few commands
(append, exit, puts, and set, with a broken incr (were missing a PMC
method at the time, and a partial if), but the parsing algorithm is
already done.

I had meant to follow jako and have it generate imcc instead (which
would allow me to easily do a lot of the stuff I was doing manually),
and in fact have the parsing in imcc or pasm (for eval), but haven't
gotten that far yet. Pesky life.

Regards.

--
Will "Coke" Coleda

Will Coleda

unread,
Dec 20, 2002, 11:34:57 AM12/20/02
to wi...@coleda.com, K Stol, Dan Sugalski, David Robins, perl6-i...@perl.org
Sorry to reply to myself, but I realized this is the second time I've
mentioned this and never actually let anyone see the code. ^_^

http://www.coleda.com/users/coke/tcl_parrot.zip

Be gentle - it was written back in... 0.0.2 days, I think, and I haven't
kept up. =-)

0 new messages