C to Pascal/Modula summary of questions

derek@knosof.uucp (Derek M Jones)
Fri, 25 Oct 91 21:12:38 BST

          From comp.compilers

Related articles
C to Pascal/Modula summary of questions derek@knosof.uucp (1991-10-25)
| List of all articles for this month |
Newsgroups: comp.compilers
From: derek@knosof.uucp (Derek M Jones)
Keywords: C, Pascal, Modula, translator
Organization: Compilers Central
Date: Fri, 25 Oct 91 21:12:38 BST

Various people have sent me questions on the topic of our translator.
Some with unusual address' that I have been unable to reply to. So here
is a summary.


>Why translate C to Pascal?


Well there are some people who believe Pascal to be the better language.
The original version was written for a Pascal only development group who
had purchased some C source and wanted to understand it. So the
translator was designed to produce readable, if not compilable output.
Version 2 (Turbo Pascal) was designed to produce compilable, but not
necessarily readable output. Version 3 does lots of flow analysis to
figure out all sorts of useful things, plus it does a better job of
unfolding C expressions.


>Other than via BBS where else can I get a copy?


Try Public Brand Software in Indianapolis 1-800-426-DISK who charge $5 per
disc (my catalog may be out of date). P.O Box 51315, Indianapolis, IN
46251.


>Why are you giving this software away? Isn't it any good?


A major problem in the translation business is finding customers. It is
good publicity (since it does a good job {well ok the output is not that
readable}). The translated output has been heavily tied to Turbo Pascal.
If you want to target another Pascal dialect it will be cheaper to pay us
to retarget the translator output than changing the existing output by
hand. Our technology has moved on since the Turbo release, but I will
leave that story for the sales pitch.


>What do you do about pointers?


This is a big question. I usually answer it by telling people about
translating to IL (a language used by the MALPAS formal verification
tool). This language does does not contain pointers. We did it all
symbolically. At this point the questioner goes very quiet.


>We are looking for a C -> Fortran77 converter. It doesn't need to be very
>clever, we only wish to convert fairly simple programs written in a C
>subset, but there are thousands of such programs, so a tool is indicated.
>Obviously we are happy to do some manual polishing of the converted source.


But what is a simple C program? My experience is that one person's simple
construct is another persons dark corner of the language. Manual
polishing is always necessary. The economics of the translator business
do not make it worth while producing the wonderful translators that people
would really like to buy.


>Can anyone supply pointers to suitable programs? Preferably FTP'able, but
>we are also interested in commercial programs.


We could use our C->Pascal tool as a basis for what you want. Call me
on (0252) 520667 if you want to be commercial (that's a UK number).


>[A similar question was posed last December and received no answers. I
>imagine it should be straightforward to start with one of the many C
>parsers lying around and have it generate Fortran, ...




The 'best' way to produce a simple translator is to write some awk
programs (or PERL). Parsers introduce all sorts of complexities that make
using then not worth while unless a large effort is going to be invested.
Our translator is over 57,000 lines long. It was not significantly better
than sed scripts/awk programs until it had reached nearly 70% of that
size. Now the effort has been invested we can do all sorts of wonderful
things, but it took a lot of work.


> ... at least for the easy pointer-free stuff. -John]


What easy pointer-free stuff? Well goto is easy, so is return. I guess
definitions of arithmetic types are also easy, unless their names clash
(don't forget all those name spaces and nested declarations).


derek jones
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.