FOO to C translator

Gregory Smith greg at utcsri.UUCP
Tue Jan 27 04:22:19 AEST 1987


In article <****> everybody at everywhere (Eve Rybody) writes:
>HELP!  Does anyone know of a software product that will convert FOO
>language code into "C"?  A friend of mine had told me that he knew of a
>product that would do this, but he did not know the name of the product,
>the company or anything else.  If anyone out here knows anything about it,
>PLEASE send mail to me at....

FOO to C translators fall into two broad classes:

(1) Translators which, when given a valid FOO program, produce a valid
C program which does the same thing, but is not maintainable. All comments
will be deleted from the original, variable names may be reinvented, gotos
may be generated copiously. Weird tables may be created from nowhere. The
C code may not be formatted in any useful way.

These convertors are useful if you have a C compiler and don't expect to
able to find a FOO compiler for your machine. You will still have to
maintain your code in FOO and just use the translator as part of the
compilation. You never have to look at the intermediate C code (which is
just as well).

(2) Translators which, given a valid FOO program, produce a valid and
maintainable C program which contains the original programmers comments.
The output is properly indented, and instead of emulating FOO control
statements with if's and goto's, the translator chooses the appropriate
do, while, for, or switch statement. Variables names are preserved as much
as possible. Parts of the code may be restructured to take advantage of
the strengths of C.

You need a type (2) translator if you have 50K lines of FOO code that
you are sick of maintaining in FOO, and you want to use C.
Unfortunately, type (2) translators generally walk, talk and must be
paid money. I think it is very unrealistic to ask for a type (2)
translator program if FOO is LISP, BASIC, COBOL or even FORTRAN. I have
seen a program do a half decent type (2) from Pascal to C, but they are
pretty close to start with.

What I am trying to say is:
	- When you ask for a 'FOO to C' translator, say what you want it for,
	  so that it is clear whether you need a type (1) or (2) translator.
	- If you want a type (2) translator, don't be surprised if you
	  don't get one.

If you need a type (2) translation, and decide to use a human translator,
it may be very useful to get a type (1) translator program so that the
system can be up and running, and get the human to translate from FOO to
real C in chunks. This allows incremental debugging with the whole system
operational.

However, it is sometimes better to restructure the implementation of a
system when rewriting to C, rather than perform a line-for-line or even
routine-for-routine hand translation from FOO to C.

-- 
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
Have vAX, will hack...



More information about the Comp.lang.c mailing list