[comp.lang.pascal] Real Pascal to C translator offered.

bergsten@chalmers.UUCP (04/07/87)

I have recently seen a number of requests for Pascl to C translators;
I have also seen a few such programs mailed through the network, most of
them doing only a very limited translation.

I have in my possession a "real" translator which I believe is capable of
translating ISO Pascal level 0 into decent C.
I am willing to share this program in the hope of bringing an end to the
flow of requests (and maybe to help one or two collegues out there).

However, as the program attempts to handle all of Pascal it is very large,
i.e. 8000+ lines or 180K+ byte of code.

==> I am reluctant to ship this huge amount of code unless there is a
    clamorous demand (see below).

-----------------------------------------------------------------------------

Remarks:
	The translator was written using standard Pascal.
	It has successfully translated itself, TeX and tangle into C.
	The translator itself, ptc, consists of more than 8000 lines of
	moderately complex Pascal code.
	TeX (after tangling) consists of more than 20000 lines of very dense
	but fairly simple Pascal code.

	When studying the resulting program quality I found that compiling the
	translator with Berkeley pc yilded approximately 220Kbyte of machine
	code on a Vax (running BSD 4.2), whereas translating it to C and then
	compiling it yilded approximately 180Kbyte of code.
	This 20% reduction is particularly surprising since the generated C-
	code was more than 20% larger than the original Pascal code.
	Similar results were observed when translating TeX.

	The output from the translator is properly indented C-code with
	original identifiers preserved where possible.

	The translator has one serious fault. It is (as yet) unable to
	translate comments in Pascal code, it is therefore not practical
	to throw away the Pascal source and maintain the resulting C-code.
	A consequence of this is that it is necessary to distribute both
	Pascal and C source for the translator which implies that I must ship
	off some 400Kbyte of source code + documentation to prospective users.

	The translator works in three passes: parse, translate, emit.
	The entire input is read at once and converted to a parse-tree which
	is modified and then printed. This method of implementation forces the
	host system to provide substantial amounts of memory.
	Translating the translator requires 1-2 Mbyte of virtual memory.

--------------------------------------------------------------------------
Mail your comments to:

	Per Bergsten


Email:	UUCP:	....mcvax!enea!chalmers!holtec!perb
	csnet:	perb%holtec.UUCP%chalmers.UUCP@chalmers.csnet

Smail:	Holtec AB
	Grona Gatan 59
	414 54 Gothenburg
	Sweden