[net.lang] PL/1 -> C translation

garry@lasspvax.UUCP (Garry Wiegand) (01/12/86)

I have seen many requests for translaters going by recently, but I
think my variation is novel:

                Anyone out there doing **PL/1** to C??

I had to do a medium size conversion by hand last year. It took months
to get all the bugs out. Nowe have to do a LARGE one (shudder).

If I can't find such a translating program, there's a good chance we'll
build it ourselves. (It becomes an interesting exercise when you include
translations for nested procedures, label variables, non-local GOTOs,
conditional handlers, etc etc. YES, those can all be done in C. With
hair pulling. NO, I am NOT going to parse PL/1 macros.)

I'm directing followups to net.lang...

garry wiegand
garry@lasspvax.tn.cornell.edu

ark@alice.UucP (Andrew Koenig) (01/14/86)

> I have seen many requests for translaters going by recently, but I
> think my variation is novel:
>
>                Anyone out there doing **PL/1** to C??
> 
> I had to do a medium size conversion by hand last year. It took months
> to get all the bugs out. Nowe have to do a LARGE one (shudder).
>
> If I can't find such a translating program, there's a good chance we'll
> build it ourselves. (It becomes an interesting exercise when you include
> translations for nested procedures, label variables, non-local GOTOs,
> conditional handlers, etc etc. YES, those can all be done in C. With
> hair pulling. NO, I am NOT going to parse PL/1 macros.)
>
> I'm directing followups to net.lang...

Parsing PL/I macros is by far the easiest part of translating the
language.

I think that doing a full-fledged PL/I to C conversion is almost impossible.
Not completely impossible, just almost impossible -- about as hard as
translating PL/I into machine language.

Consider, for instance, translating something as simple as

	a = b;

garry@batcomputer.TN.CORNELL.EDU (Garry Wiegand) (04/02/86)

In a recent article segedy@gsg.UUCP (Catherine Segedy) wrote:
>... I am trying to find information about PL/1 compilers under Unix and 
>PL/1 to C translators.  Can anyone help me ? ...


You just joggled my "to-do" list! I posted the translator question a couple
months ago - here's a summary of the replies (much thanks to all!): 


** Mike Pique (mp@unc.csnet, UNC Comp Sci Dept, Chapel Hill, NC 27514 
   (919) 966-5053) said:

A team of 4 undergraduates here few years ago built 'pltoc', 
a PL/I-to-C translation *AID* (repeat aid, not *translator*!)
It does the grunge work (converting array refs from () to [], changing order
of keywords in declarations and unwinding attribute factoring, [e.g., 
 DECLARE (  (  ( A EXTERNAL), (B AUTOMATIC) ) BINARY) FLOAT); ], selecting
C types most closely corresponding to PL/I types), you do the intellectual
stuff (deciding how to simulate/implement ON-conditions, ALLOCATE/FREE,
GET/PUT/READ/WRITE, and much more).  It's 1300 lines of YACC, 400 lines of LEX,
800 lines of C, and 20 lines of SHELL.  Runs on VAX 4BSD, probably too large
for PDP-11 but we haven't tried.  Was built spring 1981 by a student team here
and is more a research tool than a production program, but it does help:
I've pushed thousands of lines of PL/I through it.
If you want a 'tar' tape or more info, write or phone.


** Laura Creighton (ihnp4!l5!laura) said:

Converting PL/1 to C is very hard by hand.  I converted a whole lot of
sp/k (a U of T subset of PL/1) into C a long time ago.  I couldn't do
it by hand -- it was faster to write a translator!  I don't think that I
still have the translator, but even if I did it won't be much use to you
since it generated v6 style C, and doesn't handle most of the hard part
of PL/1.


** And lastly, Craig Jackson ({ihnp4!linus,seismo!harvard}!axiom!mhis!dricej, 
   {dual,hplabs,ptsfa,lll-crg}!well!cej) said:

About a PL/I to  C translator:  Lexeme Corp., of Pittsburgh, PA, does
translations like that.  They don't actually like to sell their translator;
the would prefere to contract to translate a given program.  They want
moderate bucks for this ($1-$4 per line). I don't have their address
here, but they're associated with Unilogic, the Scribe folks. 


***********
In my own case, we decided this was a glorious opportunity - not to be 
wasted - to do a full rewrite. So in the end we did not actually do any 
mechanized translation (the DECLARE's are the hard part!) 

Hope this helps someone -

garry wiegand  (garry%cadif-oak@cu-arpa.cornell.cs.edu)