Dec 182017
Pascal to C converter.
File PTC.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Pascal to C converter.
File Name File Size Zip Size Zip Type
PTC.DOC 2392 993 deflated
PTC.EXE 118728 38943 deflated
PTOC.DOC 57541 13963 deflated

Download File PTC.ZIP Here

Contents of the PTC.DOC file


ptc - Pascal to C translator

ptc < pascal source > c source

_P_t_c reads a correct Pascal program and prints a C program
with the same behaviour. It is intended as a tool for tran-
sporting finished applications to environments that lack
Pascal compilers, it is _n_o_t intended for program develop-

The input should comply with the ISO level 0 Pascal defini-
tion. Two common Pascal extensions are also recognized: the
keyword otherwise may be used for default entries in case-
statements, the keyword external may be used in place of the
forward directive to signify that a procedure or function is
defined in a library. Furthermore, the translator does not
require a complete Pascal program, a consistent subset of
declarations can be translated. Thus a primitive module
concept is supported.

Ptc implementation notes.

The quality of an object program is of course highly depen-
dent on the C compiler that processes the translated code.
Arithmetic operations are sometimes implemented in a way
that is incompatible with the Pascal definition. For exam-
ple, the translator assumes that:

a := b mod c

can be accurately translated into

a = b % c

but that may not be true if c is negative. A check on the
characteristics of integer and float arithmetic is strongly

Some Pascal constructs are impossible to express in C. The
translator will not object to:

type ptr = ^ ptr;

but a C-compiler may balk at the resulting:

typedef ptr * ptr;



The program can't translate comments from Pascal to C.

The translator does not do complete typechecking so a Pascal
program that isn't formally correct may cause malfunction.

Passing a procedure as parameter to an enclosing recursive
procedure may produce erroneous code (see the implementation


 December 18, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>