[net.general] Results of Pascal To C Converter Wanted Request

vax2:dag (01/28/83)

Lots of people responded to my request for a Pascal to C converter. Since
this much interest was generated, I thought I would post the responses. It
looks like there is two existing compilers that do this, both of them Pascal
compilers that target a C compiler. These are the Whitesmiths and HCR packages.
Contacts for both of these are included below. It looks like there is demand 
for this sort of thing (is C becoming more universal than it appears?). I want
it to get around some of the shortcommings of the Berkeley Pascal compiler.
This gets somewhat unreliable for large Pascal collections. So, here is my
collection of both the people that asked for a copy of the info and some
really good advice from some nice people. Thank you all for your interest.

--David Gunderson
  John Fluke Mfg. Co., Inc.
  decvax!microsof!fluke!dag


>From sb1!burl!rcj  Thu Jan 20 05:51:25 1983
To: floyd!harpo!decvax!microsof!fluke!dag
Subject: Pascal to C conversion

Thanks for the note, if you get anything else plez send and I
will (of course) do likewise.

The MAD Programmer -- Cornet 291-3814
alias: Curtis Jackson	...!floyd!burl!rcj
			...!sb1!burl!rcj
			...!mhuxv!burl!rcj



>From microsof!decvax!eagle!karn  Thu Jan 20 07:36:53 1983
Date: Wed Jan 19 14:27 EST 1983
Dave,
I would also be very interested in such a conversion aid (from Pascal
to C). Please let me know what you find out.

Phil




>From microsof!decvax!ucbvax!fair  Thu Jan 20 07:47:48 1983
Date: 19 Jan 83 20:11:26 PST (Wed)
From: ucbvax!fair (Erik E. Fair)
Subject: Pascal to C
Received: by UCBVAX.BERKELEY.ARPA (3.300 [1/17/83])
	id AA08808; 19 Jan 83 20:11:26 PST (Wed)
To: decvax!microsof!fluke!vax2:dag


Can you send me a copy of whatever you get ?

		Erik E. Fair
		ucbvax!fair



>From microsof!decvax!genradbolton!marc  Thu Jan 20 07:26:22 1983
Date: Wed Jan 19 10:41:36 1983
To: decvax!microsof!fluke!vax2:dag
Subject: pascal to c script

if someone has a convenient program from this conversion could you
send me a copy, please.  I have many programs in pascal that i would like
to convert over and be done with pascal.  If i hear of any i will respond
back to you.
 thanks in advance,
 marc (smith)
 decvax!genradbolton!marc




>From microsof!decvax!ucbvax!helge  Thu Jan 20 07:29:01 1983
Date: 19 Jan 83 09:47:14 PST (Wed)
From: ucbvax!helge (Helge Skrivervik)
Subject: Pascal to C converter
Received: by UCBVAX.BERKELEY.ARPA (3.300 [1/17/83])
	id AA10135; 19 Jan 83 09:47:14 PST (Wed)
To: decvax!microsof!fluke!vax2:dag

Whitesmiths (NJ) has such a beast, in fact their pascal compiler
*is* a preprocessor that converts the pascal program into C.
I tried it a year ago (under VMS) and it worked fine.

helge



>From microsof!decvax!genradbolton!grkermit!tan  Thu Jan 20 07:22:49 1983
Date: Wed Jan 19 09:04:32 1983
To: genradbo!decvax!microsof!fluke!vax2:dag
Subject: pascal -> c

The easy way is to use the whitesmith tools "ptc" which they
sell for just $200 (I believe you have to have their c compiler)
	I understand it does not convert "records" into structures very
cleanly, but this is their "pascal".

	I'd be interested in knowing how you do it (ie w/'awk'),
or anything else you find out about Whitesmith's ptc
	
	decvax!genradbolton!grkermit!tan 





>From microsof!decvax!duke!bcw  Thu Jan 20 07:36:49 1983
Date: Wed Jan 19 18:52:35 1983
To: decvax!microsof!fluke!vax2:dag
Subject: Re: vax2.424: PASCAL to C conversion aid wanted

From:	Bruce C. Wright @ Duke University
Re:	Pascal to C conversion

I don't have this thing, but a couple of comments on the general subject.
I've played around with programs to convert from one language to another,
and may know about a few traps.  One of the possible problems is trying
to translate to a language which doesn't have *quite* the same semantics
as the source language - it is always possible to do it but you may lose
an awful lot in efficiency and/or readability.  I have a program which
tries to do a conversion between Fortran and PL/I and actually manages to
do a fairly good job for the type of thing you are talking about (something
to get the silly, simple editing done but not the finer points).  There are
problems though when it tries to deal with some of the things like Fortran
LOGICAL data types:  do they translate to PL/I BIT (boolean) variables, or
to characters, since many Fortran programs use the data type for that purpose
rather than its original purpose?  And even if the program could try to
figure out which the source program used, there are always problems with
variables used in both ways ... also a favorite of Fortran programmers (yuck).
If you are interested in the program (in PL/I) or in discussing the general
topic, I'd be happy to talk about it at greater length, but I'm not aware
of anything which does exactly what you want.  I might add though that it
only took a few hours to hack together my Fortran --> PL/I converter ...
if you have to work too hard to find one you might as well have gone ahead
and written it.

Good luck -

			Bruce C. Wright @ Duke University




>From microsof!decvax!tektronix!tekmdp!crimson!donh  Thu Jan 20 23:10:38 1983
Date: Thu Jan 20 10:13:52 1983
To: !tekmdp!tektronix!decvax!microsof!fluke!dag
Subject: convert
Date: Wed Jan 19 14:30:29 1983

Whitesmiths has a Pascal to C converter they give out
as their pascal support on their version of Unix.  It
converts VERY plain vanilla Pascal to wretchedly mnemoniced
C.  Few people I have talked to are over-fond of it.  The
three big complaints I hear are 1)  It doesn't work for
x, where x is a large, interesting or useful program.  2)
'I can not read the code!'  It produces names like x1, x2
and y1 in place of the names you so carefully picked; it
also reorders the modules for you.  3)  It introduces
subtle bugs.  I am not yet convinced of this.

Dispite all this bad press, I think it might be a tolerable
aid, depending on the familiarity of the convertee with
the original program.  What often throws people who try
it off is the recursive back-pointers the converter (called ptc)
introduces in the place of local variables referred to
by heirarchically (sp?) lower subroutines.  This is a
manifestation of a nasty mis-match between Pascal and C
with respect to scoped variables contained in recursively
accessed sub-modules.  (if this is greek to you, ask & I'll send example)
I have been thinking about this for several months and have grown
convinced that what ptc does cannot be much improved on.

In other words, I think it might work, if you are very
patient with it.  The main uglifier is inherent in the
problem, not a peculiarity of ptc.

                         Don Harvey
                         Tektronix  (503) 629-1732




>From sb1!burl!rcj  Wed Jan 19 09:26:00 1983
To: mhuxv!mhuxm!mhuxh!mhuxa!mhuxt!eagle!harpo!duke!decvax!microsof!fluke!dag
Subject: Pascal to C converter

If you get anything, could you drop me a line via electronic mail?

Thanks in advance,

The MAD Programmer -- Cornet 291-3814
alias: Curtis Jackson	...!floyd!burl!rcj
			...!sb1!burl!rcj
			...!mhuxv!burl!rcj



>From microsof!decvax!utzoo!utcsrgv!utcsstat!groggy  Fri Jan 21 23:13:46 1983
Date: Fri Jan 21 17:09:48 1983
To: utcsrgv!utzoo!decvax!microsof!fluke!vax2:dag
I too, am interested in your PASCAL to C conversion program. If somebody
send s you a n automated way to do it, or pointers to places wyerehere such
information is available, colduld you forward that information to me?

Thanks.

Groggy {Mike Grossman}
{...decvax!utzoo!utcsstat!groggy}






>From microsof!decvax!utzoo!hcr!allen  Fri Jan 21 23:13:41 1983
Date: Fri Jan 21 14:25:27 1983
RE: Pascal to C translator

HCR/Pascal is a Pascal compiler based on a Pascal to C translator.
It is available for $1000 to $1500 for a binary licence on the PDP11,
VAX, or Perkin-Elmer machines running UNIX. It has also been ported
to UNIX systems based on the 68000, Z8000, 8086 and 16032 chips, and
is available on an OEM basis on any of them. For more information,
contact HCR's sales department at (416)922-1937, or at UNICOM.





>From microsof!decvax!tektronix!tekmdp!bronze!mikez  Fri Jan 21 23:10:10 1983
Date: Thu Jan 20 12:29:37 1983
To: tekmdp!tektronix!decvax!microsof!fluke!vax2.dag
Date: 20 Jan 1983 at 1011-PST (Thursday)
Subject: Re: PASCAL to C conversion aid wanted
In-Reply-To: Your news article vax2.424 of Tue Jan 18 09:46:29 1983

Whitesmiths' sells one fairly cheap.  We have an early freebie version
that seems to work, but we haven't really tested it much.  Whitesmiths'
supports Pascal by converting it to C and then using their C compilers.



>From microsof!decvax!duke!harpo!floyd!cmcl2!lanl-a!unm-ivax!mckeon  Sat Jan 22 06:35:29 1983
Date: Fri Jan 21 07:11:29 1983
To: lanl-a!cmcl2!floyd!harpo!duke!decvax!microsof!fluke!vax2:dag
Subject: pascal to C conversion


David:

If you could summarize for the net, or for a mailing list,
I'm also interested in pascal/c ( and c/pascal ) conversion. 
I was tooling up to write such a thing in lex/yacc last fall, 
but got sidetracked on some other things.

it sounds like the sort of thing someone must have done somewhere.

thanks, 
Denis McKeon,

        ucbvax!lbl-csam!        \
or      harpo!floyd!cmcl2!       lanl-a!unm-ivax!mckeon
or      pur-ee!purdue!          /










>From microsof!decvax!utzoo!utcsrgv!dave  Tue Jan 25 06:34:43 1983
Date: Mon Jan 24 17:29:49 1983
To: utzoo!decvax!microsof!fluke!vax2:dag
Subject: pascal to C

HCR has such a product. You might have to pay to get it from them.
They have a version of Pascal which is simply preprocessed into C.
Try Human Computing Resources Corp., Toronto, 416-922-1937, or mail
....hcr!mike, he might know.





>From microsof!decvax!utzoo!watmath!ajcanas  Tue Jan 25 06:35:07 1983
Date: Mon Jan 24 09:38:58 1983
To: utzoo^decvax^microsoft^fluke^vax2:dag
Subject: pascal to c

The Whitesmith's Pascal compiler is really a Pascal to C translator.
I've been using it with good results. Its nice because it allows
separate compilation of Pascal procedures.
                                   Alberto J. Canas
                                   watmath!ajcanas





>From microsof!decvax!utzoo!watmath!watarts!bernie  Tue Jan 25 06:35:11 1983
Date: Mon Jan 24 09:15:49 1983
Well, the problem you'll run into is that Pascal allows a nested-block struc-
ture to programs.  I never use that aspect of the language myself, and indeed
try not to use Pascal if there's any good alternative (e.g. C).  If you have
a Pascal program where "interior" blocks do not have variables with the same
names as those in outer blocks, and there are no "procedures within procedures",
the translation should be a simple one.  I don't have an awk script to do it,
but it's something Qed could probably handle without too much trouble.
(mostly it's things like BEGIN => {, and so on, though the fact that it's
hard to distinguish between variables and functions (since function calls
are not explicitly identified by () after them unless there are arguments) may
be a serious obstacle to automated translation.  Unless you're willing to
write a translator that actually maintains a symbol table (to distinguish
functions in expressions from variables), it's almost easier to do the trans-
lation by hand.
                                    --Bernie Roehl
                                    ...decvax!utzoo!watmath!watarts!bernie





>From vax3:microsof!decvax!ucbvax!CAD:tektronix!zehntel!sytek!gi!arizona!kpno!stevens Sat Jan 22 09:39:58 1983
Subject: re: Pascal to C translator
Newsgroups: net.general

Whitesmiths implement their Pascal compiler by translating it into C,
then passing it through their C compiler.  Their price list shows the
pascal-to-c program as $200 (binary) and I think should run under V7
(probably not 4.1bsd though).