rs@uunet.UU.NET (Rich Salz) (07/28/87)
Submitted-by: Per Bergsten <mcvax!enea!chalmers!holtec!perb>
Posting-number: Volume 10, Issue 65
Archive-name: ptoc/Part01
[ This program translates monolithic Pascal programs into monolithic
C programs. To compile either the .c or the .p version, you will
first have to join all the ptc.c.[1-7] or ptc.p.[1-5] parts together
first. The manpage and ptc.doc will also be usefl. --r$ ]
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 1 (of 12)."
# Contents: MANIFEST README makefile ptc.c.7 ptc.man
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(594 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X File Name Archive # Description
X-----------------------------------------------------------
X MANIFEST 1 This shipping list
X README 1
X makefile 1
X ptc.c.1 3
X ptc.c.2 4
X ptc.c.3 2
X ptc.c.4 6
X ptc.c.5 7
X ptc.c.6 8
X ptc.c.7 1
X ptc.man 1
X ptc.p.1 12
X ptc.p.2 10
X ptc.p.3 9
X ptc.p.4 11
X ptoc.doc 5
END_OF_FILE
if test 594 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1473 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XSetting up the Pascal to C translator.
X
XThe translator is a single huge Pascal program. If you are working on a UNIX
Xsystem that has a Pascal compiler what you need to do is to unpack and
Xconcatenate the four parts forming the translator sourcecode, "ptc.p",
Xunpack the "makefile", say "make ptc" and take a break.
X
XIf you are on a non-UNIX system proceed with discretion.
X
XIf compilation fails due to the program size you may consider attacking the C
Xversion, "ptc.c", if this too is too large to compile you may as well give up.
XIf it fails to compile or run for other reasons you may try to contact me.
X
XWhen/if the ptc program is created you may try saying "make tests", this should
Xnot produce any output at all. If it does it means that ptc obtained from ptc.p
Xdiffered in behaviour from cptc obtained from ptc.c obtained from ptc.p. In that
Xcase your Pascal and/or C compilers depart seriously from the ones availible to
Xthe author, this may imply a bug in ptc.
X
XRead the section "Tuning" in the implementation notes and do what you believe
Xis appropriate for your installation; recompile and install binary and man-page
Xas necessary.
X
XSend vitriolic comments to /dev/null;
Xchecks, constructive critisism and bug-reports to the address below.
X
X
XSincerely,
X
X Per Bergsten
X
XEmail: perb%holtec.uucp@chalmers.csnet
X ... mcvax!enea!chalmers!holtec!perb
Xaka: bergsten@chalmers
X
XSmail: Holistic Technology AB
X Grona Gatan 59
X 414 54 Gothenburg
X Sweden
X
XFax: +46 31 247456
X
END_OF_FILE
if test 1473 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'makefile'\"
else
echo shar: Extracting \"'makefile'\" \(974 characters\)
sed "s/^X//" >'makefile' <<'END_OF_FILE'
X#
X# @(#)Makefile 1.5 Date 87/05/09
X#
XCFLAGS = -O
XPFLAGS = -O
XFILES = makefile ptc.p ptc.c ptc doc.ms doc.out ptc.man man.out
XPAGELEN = -rP70
XDEV = /dev/rst8
XBLK = 126
X
X.DEFAULT:
X $(GET) -p -s SCCS/s.$@ > $@
X
X# default version
XS = p
Xptc: ptc.$S
X $Sc -O -o ptc ptc.$S
X
X# translated version
Xcptc: cptc.c
X cc -O -o cptc cptc.c
X
Xcptc.c: ptc.p ptc
X ptc < ptc.p > cptc.c
X
Xtests: test0
X
X
X#
X# Perform a simple test translating the source with the compiled
X# translator and the compairing its own source against its
X# translation of its own source. They should be exactly equal.
X#
Xtest0: ptc cptc.c cptc FRC
X cptc < ptc.p > tmp.c
X cmp cptc.c tmp.c && rm tmp.c
X
X
XFRC:
X
X#
X# Documentation.
X#
Xdoc.out: doc.ms
X tbl doc.ms | nroff -T$(TERM) $(PAGELEN) -ms - > doc.out
X
Xman.out: ptc.man
X nroff -T$(TERM) $(PAGELEN) -man ptc.man > man.out
X
X
X#
X# Maintenance
X#
Xcleanup:
X rm -f cptc cptc.c tmp.c out
X
Xclean:: cleanup
X
X
Xclobber:: cleanup
X
X
Xtape: $(FILES)
X tar cvfb $(DEV) $(BLK) $(FILES)
END_OF_FILE
if test 974 -ne `wc -c <'makefile'`; then
echo shar: \"'makefile'\" unpacked with wrong size!
fi
# end of 'makefile'
fi
if test -f 'ptc.c.7' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ptc.c.7'\"
else
echo shar: Extracting \"'ptc.c.7'\" \(28856 characters\)
sed "s/^X//" >'ptc.c.7' <<'END_OF_FILE'
X void
Xdefmach(lo, hi, str)
X integer lo, hi;
X machdefstr str;
X{
X register toknidx i;
X toknbuf w;
X
X { register int _j, _i = 1 - 1;
X for (_j = 0; _j < 16; )
X w.A[_i++] = str.A[_j++];
X }
X if (w.A[machdeflen - 1] != space)
X error(ebadmach);
X {
X toknidx B74 = machdeflen - 1,
X B75 = 1;
X
X if (B74 >= B75)
X for (i = B74; ; i--) {
X if (w.A[i - 1] != space) {
X w.A[i + 1 - 1] = null;
X goto L999;
X }
X if (i == B75) break;
X }
X }
X error(ebadmach);
XL999:
X if (nmachdefs >= maxmachdefs)
X error(emanymachs);
X nmachdefs = nmachdefs + 1;
X {
X register struct S193 *W76 = &machdefs.A[nmachdefs - 1];
X
X W76->lolim = lo;
X W76->hilim = hi;
X W76->typstr = savestr(&w);
X }
X}
X
X void
Xinitstrstore()
X{
X register strbcnt i;
X
X {
X strbcnt B77 = 1,
X B78 = maxblkcnt;
X
X if (B77 <= B78)
X for (i = B77; ; i++) {
X strstor.A[i] = (strblk *)NIL;
X if (i == B78) break;
X }
X }
X strstor.A[0] = (strblk *)malloc((unsigned)(sizeof(*strstor.A[0])));
X strstor.A[0]->A[0] = null;
X strfree = 1;
X strleft = maxstrblk;
X}
X
X
X void
Xinitialize()
X{
X register hashtyp s;
X register pretyps t;
X register predefs d;
X
X lineno = 1;
X colno = 0;
X initstrstore();
X setlst = (struct S61 *)NIL;
X setcnt = 0;
X (void)strncpy(hexdig.A, "0123456789ABCDEF", sizeof(hexdig.A));
X symtab = (struct S60 *)NIL;
X statlvl = 0;
X maxlevel = -1;
X enterscope((declptr)NIL);
X varno = 0;
X usenilp = false;
X usesets = false;
X useunion = false;
X usediff = false;
X usemksub = false;
X useintr = false;
X usesge = false;
X usesle = false;
X usesne = false;
X useseq = false;
X usememb = false;
X useins = false;
X usescpy = false;
X usefopn = false;
X usescan = false;
X usegetl = false;
X usecase = false;
X usejmps = false;
X usebool = false;
X usecomp = false;
X usemax = false;
X {
X hashtyp B79 = 0,
X B80 = hashmax;
X
X if (B79 <= B80)
X for (s = B79; ; s++) {
X idtab.A[s] = (struct S59 *)NIL;
X if (s == B80) break;
X }
X }
X {
X predefs B81 = dabs,
X B82 = dztring;
X
X if ((int)(B81) <= (int)(B82))
X for (d = B81; ; d = (predefs)((int)(d)+1)) {
X deftab.A[(int)(d)] = (struct S61 *)NIL;
X defnams.A[(int)(d)] = (struct S62 *)NIL;
X if (d == B82) break;
X }
X }
X defkey(sand, *((keyword *)"and "));
X defkey(sarray, *((keyword *)"array "));
X defkey(sbegin, *((keyword *)"begin "));
X defkey(scase, *((keyword *)"case "));
X defkey(sconst, *((keyword *)"const "));
X defkey(sdiv, *((keyword *)"div "));
X defkey(sdo, *((keyword *)"do "));
X defkey(sdownto, *((keyword *)"downto "));
X defkey(selse, *((keyword *)"else "));
X defkey(send, *((keyword *)"end "));
X defkey(sextern, *((keyword *)externsym));
X defkey(sfile, *((keyword *)"file "));
X defkey(sfor, *((keyword *)"for "));
X defkey(sforward, *((keyword *)"forward "));
X defkey(sfunc, *((keyword *)"function "));
X defkey(sgoto, *((keyword *)"goto "));
X defkey(sif, *((keyword *)"if "));
X defkey(sinn, *((keyword *)"in "));
X defkey(slabel, *((keyword *)"label "));
X defkey(smod, *((keyword *)"mod "));
X defkey(snil, *((keyword *)"nil "));
X defkey(snot, *((keyword *)"not "));
X defkey(sof, *((keyword *)"of "));
X defkey(sor, *((keyword *)"or "));
X defkey(sother, *((keyword *)othersym));
X defkey(spacked, *((keyword *)"packed "));
X defkey(sproc, *((keyword *)"procedure "));
X defkey(spgm, *((keyword *)"program "));
X defkey(srecord, *((keyword *)"record "));
X defkey(srepeat, *((keyword *)"repeat "));
X defkey(sset, *((keyword *)"set "));
X defkey(sthen, *((keyword *)"then "));
X defkey(sto, *((keyword *)"to "));
X defkey(stype, *((keyword *)"type "));
X defkey(suntil, *((keyword *)"until "));
X defkey(svar, *((keyword *)"var "));
X defkey(swhile, *((keyword *)"while "));
X defkey(swith, *((keyword *)"with "));
X defkey(seof, *((keyword *)dummysym));
X cprio.A[(int)(nformat) - (int)(nassign)] = 0;
X cprio.A[(int)(nrange) - (int)(nassign)] = 0;
X cprio.A[(int)(nin) - (int)(nassign)] = 0;
X cprio.A[(int)(nset) - (int)(nassign)] = 0;
X cprio.A[(int)(nassign) - (int)(nassign)] = 0;
X cprio.A[(int)(nor) - (int)(nassign)] = 1;
X cprio.A[(int)(nand) - (int)(nassign)] = 2;
X cprio.A[(int)(neq) - (int)(nassign)] = 3;
X cprio.A[(int)(nne) - (int)(nassign)] = 3;
X cprio.A[(int)(nlt) - (int)(nassign)] = 3;
X cprio.A[(int)(nle) - (int)(nassign)] = 3;
X cprio.A[(int)(ngt) - (int)(nassign)] = 3;
X cprio.A[(int)(nge) - (int)(nassign)] = 3;
X cprio.A[(int)(nplus) - (int)(nassign)] = 4;
X cprio.A[(int)(nminus) - (int)(nassign)] = 4;
X cprio.A[(int)(nmul) - (int)(nassign)] = 5;
X cprio.A[(int)(ndiv) - (int)(nassign)] = 5;
X cprio.A[(int)(nmod) - (int)(nassign)] = 5;
X cprio.A[(int)(nquot) - (int)(nassign)] = 5;
X cprio.A[(int)(nnot) - (int)(nassign)] = 6;
X cprio.A[(int)(numinus) - (int)(nassign)] = 6;
X cprio.A[(int)(nuplus) - (int)(nassign)] = 7;
X cprio.A[(int)(nindex) - (int)(nassign)] = 7;
X cprio.A[(int)(nselect) - (int)(nassign)] = 7;
X cprio.A[(int)(nderef) - (int)(nassign)] = 7;
X cprio.A[(int)(ncall) - (int)(nassign)] = 7;
X cprio.A[(int)(nid) - (int)(nassign)] = 7;
X cprio.A[(int)(nchar) - (int)(nassign)] = 7;
X cprio.A[(int)(ninteger) - (int)(nassign)] = 7;
X cprio.A[(int)(nreal) - (int)(nassign)] = 7;
X cprio.A[(int)(nstring) - (int)(nassign)] = 7;
X cprio.A[(int)(nnil) - (int)(nassign)] = 7;
X pprio.A[(int)(nassign) - (int)(nassign)] = 0;
X pprio.A[(int)(nformat) - (int)(nassign)] = 0;
X pprio.A[(int)(nrange) - (int)(nassign)] = 1;
X pprio.A[(int)(nin) - (int)(nassign)] = 1;
X pprio.A[(int)(neq) - (int)(nassign)] = 1;
X pprio.A[(int)(nne) - (int)(nassign)] = 1;
X pprio.A[(int)(nlt) - (int)(nassign)] = 1;
X pprio.A[(int)(nle) - (int)(nassign)] = 1;
X pprio.A[(int)(ngt) - (int)(nassign)] = 1;
X pprio.A[(int)(nge) - (int)(nassign)] = 1;
X pprio.A[(int)(nor) - (int)(nassign)] = 2;
X pprio.A[(int)(nplus) - (int)(nassign)] = 2;
X pprio.A[(int)(nminus) - (int)(nassign)] = 2;
X pprio.A[(int)(nand) - (int)(nassign)] = 3;
X pprio.A[(int)(nmul) - (int)(nassign)] = 3;
X pprio.A[(int)(ndiv) - (int)(nassign)] = 3;
X pprio.A[(int)(nmod) - (int)(nassign)] = 3;
X pprio.A[(int)(nquot) - (int)(nassign)] = 3;
X pprio.A[(int)(nnot) - (int)(nassign)] = 4;
X pprio.A[(int)(numinus) - (int)(nassign)] = 4;
X pprio.A[(int)(nuplus) - (int)(nassign)] = 5;
X pprio.A[(int)(nset) - (int)(nassign)] = 6;
X pprio.A[(int)(nindex) - (int)(nassign)] = 6;
X pprio.A[(int)(nselect) - (int)(nassign)] = 6;
X pprio.A[(int)(nderef) - (int)(nassign)] = 6;
X pprio.A[(int)(ncall) - (int)(nassign)] = 6;
X pprio.A[(int)(nid) - (int)(nassign)] = 6;
X pprio.A[(int)(nchar) - (int)(nassign)] = 6;
X pprio.A[(int)(ninteger) - (int)(nassign)] = 6;
X pprio.A[(int)(nreal) - (int)(nassign)] = 6;
X pprio.A[(int)(nstring) - (int)(nassign)] = 6;
X pprio.A[(int)(nnil) - (int)(nassign)] = 6;
X defname(cabort, *((keyword *)"abort "));
X defname(cbreak, *((keyword *)"break "));
X defname(ccontinue, *((keyword *)"continue "));
X defname(cdefine, *((keyword *)"define "));
X defname(cdefault, *((keyword *)"default "));
X defname(cdouble, *((keyword *)"double "));
X defname(cedata, *((keyword *)"edata "));
X defname(cenum, *((keyword *)"enum "));
X defname(cetext, *((keyword *)"etext "));
X defname(cextern, *((keyword *)"extern "));
X defname(cfclose, *((keyword *)"fclose "));
X defname(cfflush, *((keyword *)"fflush "));
X defname(cfgetc, *((keyword *)"fgetc "));
X defname(cfloat, *((keyword *)"float "));
X defname(cfloor, *((keyword *)"floor "));
X defname(cfprintf, *((keyword *)"fprintf "));
X defname(cfputc, *((keyword *)"fputc "));
X defname(cfread, *((keyword *)"fread "));
X defname(cfscanf, *((keyword *)"fscanf "));
X defname(cfwrite, *((keyword *)"fwrite "));
X defname(cgetc, *((keyword *)"getc "));
X defname(cgetpid, *((keyword *)"getpid "));
X defname(cint, *((keyword *)"int "));
X defname(cinclude, *((keyword *)"include "));
X defname(clong, *((keyword *)"long "));
X defname(clog, *((keyword *)"log "));
X defname(cmain, *((keyword *)"main "));
X defname(cmalloc, *((keyword *)"malloc "));
X defname(cprintf, *((keyword *)"printf "));
X defname(cpower, *((keyword *)"pow "));
X defname(cputc, *((keyword *)"putc "));
X defname(cread, *((keyword *)"read "));
X defname(creturn, *((keyword *)"return "));
X defname(cregister, *((keyword *)"register "));
X defname(crewind, *((keyword *)"rewind "));
X defname(cscanf, *((keyword *)"scanf "));
X defname(csetbits, *((keyword *)"setbits "));
X defname(csetword, *((keyword *)"setword "));
X defname(csetptr, *((keyword *)"setptr "));
X defname(cshort, *((keyword *)"short "));
X defname(csigned, *((keyword *)"signed "));
X defname(csizeof, *((keyword *)"sizeof "));
X defname(csprintf, *((keyword *)"sprintf "));
X defname(cstatic, *((keyword *)"static "));
X defname(cstdin, *((keyword *)"stdin "));
X defname(cstdout, *((keyword *)"stdout "));
X defname(cstderr, *((keyword *)"stderr "));
X defname(cstrncmp, *((keyword *)"strncmp "));
X defname(cstrncpy, *((keyword *)"strncpy "));
X defname(cstruct, *((keyword *)"struct "));
X defname(cswitch, *((keyword *)"switch "));
X defname(ctypedef, *((keyword *)"typedef "));
X defname(cundef, *((keyword *)"undef "));
X defname(cungetc, *((keyword *)"ungetc "));
X defname(cunion, *((keyword *)"union "));
X defname(cunlink, *((keyword *)"unlink "));
X defname(cunsigned, *((keyword *)"unsigned "));
X defname(cwrite, *((keyword *)"write "));
X defid(nfunc, dabs, *((keyword *)"abs "));
X defid(nfunc, darctan, *((keyword *)"arctan "));
X defid(nvar, dargc, *((keyword *)"argc "));
X defid(nproc, dargv, *((keyword *)"argv "));
X defid(nscalar, dboolean, *((keyword *)"boolean "));
X defid(ntype, dchar, *((keyword *)"char "));
X defid(nfunc, dchr, *((keyword *)"chr "));
X defid(nproc, dclose, *((keyword *)"close "));
X defid(nfunc, dcos, *((keyword *)"cos "));
X defid(nproc, ddispose, *((keyword *)"dispose "));
X defid(nid, dfalse, *((keyword *)"false "));
X defid(nfunc, deof, *((keyword *)"eof "));
X defid(nfunc, deoln, *((keyword *)"eoln "));
X defid(nproc, dexit, *((keyword *)"exit "));
X defid(nfunc, dexp, *((keyword *)"exp "));
X defid(nproc, dflush, *((keyword *)"flush "));
X defid(nproc, dget, *((keyword *)"get "));
X defid(nproc, dhalt, *((keyword *)"halt "));
X defid(nvar, dinput, *((keyword *)"input "));
X defid(ntype, dinteger, *((keyword *)"integer "));
X defid(nfunc, dln, *((keyword *)"ln "));
X defid(nconst, dmaxint, *((keyword *)"maxint "));
X defid(nproc, dmessage, *((keyword *)"message "));
X defid(nproc, dnew, *((keyword *)"new "));
X defid(nfunc, dodd, *((keyword *)"odd "));
X defid(nfunc, dord, *((keyword *)"ord "));
X defid(nvar, doutput, *((keyword *)"output "));
X defid(nproc, dpack, *((keyword *)"pack "));
X defid(nproc, dpage, *((keyword *)"page "));
X defid(nfunc, dpred, *((keyword *)"pred "));
X defid(nproc, dput, *((keyword *)"put "));
X defid(nproc, dread, *((keyword *)"read "));
X defid(nproc, dreadln, *((keyword *)"readln "));
X defid(ntype, dreal, *((keyword *)"real "));
X defid(nproc, dreset, *((keyword *)"reset "));
X defid(nproc, drewrite, *((keyword *)"rewrite "));
X defid(nfunc, dround, *((keyword *)"round "));
X defid(nfunc, dsin, *((keyword *)"sin "));
X defid(nfunc, dsqr, *((keyword *)"sqr "));
X defid(nfunc, dsqrt, *((keyword *)"sqrt "));
X defid(nfunc, dsucc, *((keyword *)"succ "));
X defid(ntype, dtext, *((keyword *)"text "));
X defid(nid, dtrue, *((keyword *)"true "));
X defid(nfunc, dtrunc, *((keyword *)"trunc "));
X defid(nfunc, dtan, *((keyword *)"tan "));
X defid(nproc, dunpack, *((keyword *)"unpack "));
X defid(nproc, dwrite, *((keyword *)"write "));
X defid(nproc, dwriteln, *((keyword *)"writeln "));
X defid(nfield, dzinit, *((keyword *)"$nit "));
X defid(ntype, dztring, *((keyword *)"$ztring "));
X deftab.A[(int)(dboolean)]->U.V14.tbind->U.V17.tscalid = deftab.A[(int)(dfalse)];
X deftab.A[(int)(dfalse)]->tnext = deftab.A[(int)(dtrue)];
X currsym.st = sinteger;
X currsym.U.V3.vint = maxint;
X deftab.A[(int)(dmaxint)]->U.V14.tbind = mklit();
X deftab.A[(int)(dargc)]->U.V14.tbind = deftab.A[(int)(dinteger)]->U.V14.tbind;
X deftab.A[(int)(dinput)]->U.V14.tbind = deftab.A[(int)(dtext)]->U.V14.tbind;
X deftab.A[(int)(doutput)]->U.V14.tbind = deftab.A[(int)(dtext)]->U.V14.tbind;
X {
X pretyps B83 = tnone,
X B84 = terror;
X
X if ((int)(B83) <= (int)(B84))
X for (t = B83; ; t = (pretyps)((int)(t)+1)) {
X switch (t) {
X case tboolean:
X typnods.A[(int)(t)] = deftab.A[(int)(dboolean)];
X break ;
X case tchar:
X typnods.A[(int)(t)] = deftab.A[(int)(dchar)]->U.V14.tbind;
X break ;
X case tinteger:
X typnods.A[(int)(t)] = deftab.A[(int)(dinteger)]->U.V14.tbind;
X break ;
X case treal:
X typnods.A[(int)(t)] = deftab.A[(int)(dreal)]->U.V14.tbind;
X break ;
X case ttext:
X typnods.A[(int)(t)] = deftab.A[(int)(dtext)]->U.V14.tbind;
X break ;
X case tstring:
X typnods.A[(int)(t)] = deftab.A[(int)(dztring)]->U.V14.tbind;
X break ;
X case tnil: case tset: case tpoly: case tnone:
X typnods.A[(int)(t)] = mknode(npredef);
X break ;
X case terror:
X break ;
X default:
X Caseerror(Line);
X }
X if (Member((unsigned)(t), Conset[163]))
X typnods.A[(int)(t)]->U.V12.tobtyp = t;
X if (t == B84) break;
X }
X }
X fixinit(defnams.A[(int)(dzinit)]->U.V6.lid->istr);
X deftab.A[(int)(dzinit)]->U.V14.tbind = deftab.A[(int)(dinteger)]->U.V14.tbind;
X {
X predefs B85 = dabs,
X B86 = dztring;
X
X if ((int)(B85) <= (int)(B86))
X for (d = B85; ; d = (predefs)((int)(d)+1)) {
X linkup((treeptr)NIL, deftab.A[(int)(d)]);
X if (d == B86) break;
X }
X }
X deftab.A[(int)(dchr)]->U.V13.tfuntyp = typnods.A[(int)(tchar)];
X deftab.A[(int)(deof)]->U.V13.tfuntyp = typnods.A[(int)(tboolean)];
X deftab.A[(int)(deoln)]->U.V13.tfuntyp = typnods.A[(int)(tboolean)];
X deftab.A[(int)(dodd)]->U.V13.tfuntyp = typnods.A[(int)(tboolean)];
X deftab.A[(int)(dord)]->U.V13.tfuntyp = typnods.A[(int)(tinteger)];
X deftab.A[(int)(dround)]->U.V13.tfuntyp = typnods.A[(int)(tinteger)];
X deftab.A[(int)(dtrunc)]->U.V13.tfuntyp = typnods.A[(int)(tinteger)];
X deftab.A[(int)(darctan)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dcos)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dsin)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dtan)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dsqrt)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dexp)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dln)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
X deftab.A[(int)(dsqr)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
X deftab.A[(int)(dabs)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
X deftab.A[(int)(dpred)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
X deftab.A[(int)(dsucc)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
X deftab.A[(int)(dargv)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(ddispose)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dexit)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dget)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dhalt)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dnew)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dpack)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dput)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dread)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dreadln)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dreset)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(drewrite)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dwrite)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dwriteln)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dmessage)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X deftab.A[(int)(dunpack)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
X nmachdefs = 0;
X defmach(0, 255, *((machdefstr *)"unsigned char "));
X defmach(-128, 127, *((machdefstr *)"char "));
X defmach(0, 65535, *((machdefstr *)"unsigned short "));
X defmach(-32768, 32767, *((machdefstr *)"short "));
X defmach(-2147483647, 2147483647, *((machdefstr *)"long "));
X}
X
Xextern void exit();
X
X void
Xerror(m)
X errors m;
X{
X prtmsg(m);
X exit(1);
X longjmp(J[0].jb, 9999);
X}
X
X void
Xfatal(m)
X errors m;
X{
X prtmsg(m);
X abort();
X}
X
X/*
X** Start of program code
X*/
Xmain()
X{
X if (setjmp(J[0].jb))
X goto L9999;
X initialize();
X if (echo)
X (void)fprintf(output.fp, "# ifdef PASCAL\n"), Putl(output, 1);
X parse();
X if (echo)
X (void)fprintf(output.fp, "# else\n"), Putl(output, 1);
X lineno = 0;
X lastline = 0;
X transform();
X emit();
X if (echo)
X (void)fprintf(output.fp, "# endif\n"), Putl(output, 1);
XL9999:
X ;
X exit(0);
X}
X/*
X** End of program code
X*/
Xstatic setword Q0[] = {
X 1,
X 0x03FD
X};
Xstatic setword Q1[] = {
X 1,
X 0x004C
X};
Xstatic setword Q2[] = {
X 1,
X 0x0000
X};
Xstatic setword Q3[] = {
X 2,
X 0x000E, 0x5210
X};
Xstatic setword Q4[] = {
X 2,
X 0x000E, 0x1210
X};
Xstatic setword Q5[] = {
X 1,
X 0x0C00
X};
Xstatic setword Q6[] = {
X 1,
X 0x000C
X};
Xstatic setword Q7[] = {
X 2,
X 0x000E, 0x0210
X};
Xstatic setword Q8[] = {
X 3,
X 0x0000, 0x0000, 0x0060
X};
Xstatic setword Q9[] = {
X 4,
X 0x0002, 0x0000, 0x0064, 0x0800
X};
Xstatic setword Q10[] = {
X 1,
X 0x0C00
X};
Xstatic setword Q11[] = {
X 1,
X 0x000C
X};
Xstatic setword Q12[] = {
X 4,
X 0x0000, 0x0000, 0x4FF0, 0x0008
X};
Xstatic setword Q13[] = {
X 3,
X 0x0000, 0x0000, 0x0780
X};
Xstatic setword Q14[] = {
X 3,
X 0x0000, 0x0000, 0x0780
X};
Xstatic setword Q15[] = {
X 5,
X 0x0000, 0x0001, 0x0000, 0x0000, 0x0001
X};
Xstatic setword Q16[] = {
X 3,
X 0x0000, 0x0000, 0x07E0
X};
Xstatic setword Q17[] = {
X 3,
X 0x0000, 0x0000, 0xB000
X};
Xstatic setword Q18[] = {
X 4,
X 0x0000, 0x0008, 0x0000, 0x0040
X};
Xstatic setword Q19[] = {
X 3,
X 0x0000, 0x0000, 0xB560
X};
Xstatic setword Q20[] = {
X 4,
X 0x0000, 0x0000, 0x4FF0, 0x0008
X};
Xstatic setword Q21[] = {
X 1,
X 0x0C00
X};
Xstatic setword Q22[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1700
X};
Xstatic setword Q23[] = {
X 2,
X 0x0000, 0x0003
X};
Xstatic setword Q24[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1700
X};
Xstatic setword Q25[] = {
X 3,
X 0x0000, 0x0040, 0x4000
X};
Xstatic setword Q26[] = {
X 1,
X 0x000E
X};
Xstatic setword Q27[] = {
X 1,
X 0x000E
X};
Xstatic setword Q28[] = {
X 1,
X 0x000C
X};
Xstatic setword Q29[] = {
X 1,
X 0x000E
X};
Xstatic setword Q30[] = {
X 1,
X 0x000E
X};
Xstatic setword Q31[] = {
X 2,
X 0x8000, 0x0045
X};
Xstatic setword Q32[] = {
X 1,
X 0x000E
X};
Xstatic setword Q33[] = {
X 1,
X 0x000E
X};
Xstatic setword Q34[] = {
X 3,
X 0x0000, 0x0000, 0x0040
X};
Xstatic setword Q35[] = {
X 3,
X 0x4010, 0x0C00, 0x000A
X};
Xstatic setword Q36[] = {
X 5,
X 0x0300, 0x0000, 0x0004, 0x2000, 0x0001
X};
Xstatic setword Q37[] = {
X 4,
X 0x0300, 0x0000, 0x0004, 0x2000
X};
Xstatic setword Q38[] = {
X 3,
X 0x0000, 0x0000, 0x0080
X};
Xstatic setword Q39[] = {
X 4,
X 0x0040, 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q40[] = {
X 1,
X 0x0040
X};
Xstatic setword Q41[] = {
X 3,
X 0x0080, 0x0000, 0x0001
X};
Xstatic setword Q42[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x4000
X};
Xstatic setword Q43[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q44[] = {
X 4,
X 0x0000, 0x0000, 0x0004, 0x2000
X};
Xstatic setword Q45[] = {
X 1,
X 0x0040
X};
Xstatic setword Q46[] = {
X 2,
X 0x0000, 0x8000
X};
Xstatic setword Q47[] = {
X 4,
X 0x0300, 0x0000, 0x0004, 0x2000
X};
Xstatic setword Q48[] = {
X 4,
X 0x930C, 0x2001, 0x0834, 0x2000
X};
Xstatic setword Q49[] = {
X 4,
X 0x930C, 0x2001, 0x0834, 0x3000
X};
Xstatic setword Q50[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1800
X};
Xstatic setword Q51[] = {
X 2,
X 0x0200, 0x0100
X};
Xstatic setword Q52[] = {
X 3,
X 0x0200, 0x0100, 0x3C80
X};
Xstatic setword Q53[] = {
X 2,
X 0x0000, 0x0040
X};
Xstatic setword Q54[] = {
X 4,
X 0x0000, 0x0000, 0x4FF0, 0x0008
X};
Xstatic setword Q55[] = {
X 4,
X 0x03E1, 0x80CA, 0xF005, 0xBFFE
X};
Xstatic setword Q56[] = {
X 4,
X 0x0000, 0x0030, 0x3F80, 0x001A
X};
Xstatic setword Q57[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0478
X};
Xstatic setword Q58[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0478
X};
Xstatic setword Q59[] = {
X 1,
X 0x0C0C
X};
Xstatic setword Q60[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q61[] = {
X 5,
X 0x0000, 0x0000, 0x0000, 0x000B, 0x0001
X};
Xstatic setword Q62[] = {
X 5,
X 0x03E1, 0x80CA, 0xF005, 0xFFFF, 0x0001
X};
Xstatic setword Q63[] = {
X 4,
X 0x930C, 0x2001, 0x0834, 0x2000
X};
Xstatic setword Q64[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1000
X};
Xstatic setword Q65[] = {
X 4,
X 0x930C, 0x2001, 0x08B4, 0x2000
X};
Xstatic setword Q66[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2004
X};
Xstatic setword Q67[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q68[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1000
X};
Xstatic setword Q69[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1002
X};
Xstatic setword Q70[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2004
X};
Xstatic setword Q71[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2006
X};
Xstatic setword Q72[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2004
X};
Xstatic setword Q73[] = {
X 3,
X 0x0002, 0x0000, 0x0800
X};
Xstatic setword Q74[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q75[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1000
X};
Xstatic setword Q76[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q77[] = {
X 3,
X 0x4000, 0x0400, 0x0808
X};
Xstatic setword Q78[] = {
X 3,
X 0x0002, 0x0000, 0x0800
X};
Xstatic setword Q79[] = {
X 2,
X 0x0000, 0x0040
X};
Xstatic setword Q80[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2010
X};
Xstatic setword Q81[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q82[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2010
X};
Xstatic setword Q83[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q84[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0008
X};
Xstatic setword Q85[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1000
X};
Xstatic setword Q86[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q87[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x8000
X};
Xstatic setword Q88[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q89[] = {
X 3,
X 0x4004, 0x0400, 0x0040
X};
Xstatic setword Q90[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2000
X};
Xstatic setword Q91[] = {
X 1,
X 0x2400
X};
Xstatic setword Q92[] = {
X 3,
X 0x4014, 0x0404, 0x000A
X};
Xstatic setword Q93[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2000
X};
Xstatic setword Q94[] = {
X 3,
X 0x6414, 0x0404, 0x000A
X};
Xstatic setword Q95[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2000
X};
Xstatic setword Q96[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q97[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q98[] = {
X 3,
X 0x4004, 0x0400, 0x0840
X};
Xstatic setword Q99[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1800
X};
Xstatic setword Q100[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q101[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1800
X};
Xstatic setword Q102[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q103[] = {
X 3,
X 0x4004, 0x0400, 0x0848
X};
Xstatic setword Q104[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0020
X};
Xstatic setword Q105[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q106[] = {
X 2,
X 0x0000, 0x0040
X};
Xstatic setword Q107[] = {
X 2,
X 0x0000, 0x0040
X};
Xstatic setword Q108[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0010
X};
Xstatic setword Q109[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0008
X};
Xstatic setword Q110[] = {
X 4,
X 0x0200, 0x0000, 0x0000, 0x2004
X};
Xstatic setword Q111[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q112[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0004
X};
Xstatic setword Q113[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q114[] = {
X 3,
X 0x0000, 0x0000, 0x3C80
X};
Xstatic setword Q115[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x8000
X};
Xstatic setword Q116[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x8000
X};
Xstatic setword Q117[] = {
X 4,
X 0x0200, 0x0000, 0x0000, 0x2814
X};
Xstatic setword Q118[] = {
X 2,
X 0x0802, 0x5000
X};
Xstatic setword Q119[] = {
X 4,
X 0x0802, 0x5200, 0x3C80, 0x0003
X};
Xstatic setword Q120[] = {
X 4,
X 0x0200, 0x0000, 0x0000, 0x2004
X};
Xstatic setword Q121[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0002
X};
Xstatic setword Q122[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1800
X};
Xstatic setword Q123[] = {
X 3,
X 0x0000, 0x0000, 0x3C80
X};
Xstatic setword Q124[] = {
X 2,
X 0x0000, 0x0040
X};
Xstatic setword Q125[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q126[] = {
X 4,
X 0x0000, 0x0040, 0x0000, 0x1000
X};
Xstatic setword Q127[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q128[] = {
X 3,
X 0x0008, 0x0000, 0x0800
X};
Xstatic setword Q129[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1000
X};
Xstatic setword Q130[] = {
X 3,
X 0x0008, 0x0000, 0x0800
X};
Xstatic setword Q131[] = {
X 3,
X 0x0000, 0x0000, 0x0880
X};
Xstatic setword Q132[] = {
X 3,
X 0x0000, 0x0000, 0x0980
X};
Xstatic setword Q133[] = {
X 3,
X 0x0000, 0x0000, 0x3000
X};
Xstatic setword Q134[] = {
X 3,
X 0x4004, 0x0400, 0x084A
X};
Xstatic setword Q135[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2000
X};
Xstatic setword Q136[] = {
X 3,
X 0x0000, 0x0000, 0x3F80
X};
Xstatic setword Q137[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0020
X};
Xstatic setword Q138[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q139[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1824
X};
Xstatic setword Q140[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q141[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x1824
X};
Xstatic setword Q142[] = {
X 3,
X 0x4014, 0x0400, 0x000A
X};
Xstatic setword Q143[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2800
X};
Xstatic setword Q144[] = {
X 3,
X 0x0000, 0x0000, 0x0080
X};
Xstatic setword Q145[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2000
X};
Xstatic setword Q146[] = {
X 5,
X 0x0000, 0x0000, 0x0000, 0x0000, 0x0001
X};
Xstatic setword Q147[] = {
X 3,
X 0x4014, 0x0404, 0x000A
X};
Xstatic setword Q148[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2000
X};
Xstatic setword Q149[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q150[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x2002
X};
Xstatic setword Q151[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q152[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0804
X};
Xstatic setword Q153[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q154[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0804
X};
Xstatic setword Q155[] = {
X 3,
X 0x0000, 0x0000, 0x0800
X};
Xstatic setword Q156[] = {
X 4,
X 0x0000, 0x0000, 0x0000, 0x0804
X};
Xstatic setword Q157[] = {
X 3,
X 0x0004, 0x0000, 0x0040
X};
Xstatic setword Q158[] = {
X 1,
X 0x0018
X};
Xstatic setword Q159[] = {
X 1,
X 0x00C0
X};
Xstatic setword Q160[] = {
X 1,
X 0x001A
X};
Xstatic setword Q161[] = {
X 1,
X 0x001E
X};
Xstatic setword Q162[] = {
X 1,
X 0x001F
X};
Xstatic setword Q163[] = {
X 1,
X 0x1FE7
X};
Xstatic setword *Conset[] = {
X Q163, Q162, Q161,
X Q160, Q159, Q158, Q157, Q156, Q155,
X Q154, Q153, Q152, Q151, Q150, Q149,
X Q148, Q147, Q146, Q145, Q144, Q143,
X Q142, Q141, Q140, Q139, Q138, Q137,
X Q136, Q135, Q134, Q133, Q132, Q131,
X Q130, Q129, Q128, Q127, Q126, Q125,
X Q124, Q123, Q122, Q121, Q120, Q119,
X Q118, Q117, Q116, Q115, Q114, Q113,
X Q112, Q111, Q110, Q109, Q108, Q107,
X Q106, Q105, Q104, Q103, Q102, Q101,
X Q100, Q99, Q98, Q97, Q96, Q95,
X Q94, Q93, Q92, Q91, Q90, Q89,
X Q88, Q87, Q86, Q85, Q84, Q83,
X Q82, Q81, Q80, Q79, Q78, Q77,
X Q76, Q75, Q74, Q73, Q72, Q71,
X Q70, Q69, Q68, Q67, Q66, Q65,
X Q64, Q63, Q62, Q61, Q60, Q59,
X Q58, Q57, Q56, Q55, Q54, Q53,
X Q52, Q51, Q50, Q49, Q48, Q47,
X Q46, Q45, Q44, Q43, Q42, Q41,
X Q40, Q39, Q38, Q37, Q36, Q35,
X Q34, Q33, Q32, Q31, Q30, Q29,
X Q28, Q27, Q26, Q25, Q24, Q23,
X Q22, Q21, Q20, Q19, Q18, Q17,
X Q16, Q15, Q14, Q13, Q12, Q11,
X Q10, Q9, Q8, Q7, Q6, Q5,
X Q4, Q3, Q2, Q1, Q0
X};
X
Xstatic setptr
XUnion(p1, p2)
X register setptr p1, p2;
X{
X register int i, j, k;
X register setptr sp = Newset(),
X p3 = sp;
X
X j = *p1;
X *p3 = j;
X if (j > *p2)
X j = *p2;
X else
X *p3 = *p2;
X k = *p1 - *p2;
X p1++, p2++, p3++;
X for (i = 0; i < j; i++)
X *p3++ = (*p1++ | *p2++);
X while (k > 0) {
X *p3++ = *p1++;
X k--;
X }
X while (k < 0) {
X *p3++ = *p2++;
X k++;
X }
X return (Saveset(sp));
X}
X
Xstatic boolean
XMember(m, sp)
X register unsigned int m;
X register setptr sp;
X{
X register unsigned int i = m / (setbits+1) + 1;
X
X if ((i <= *sp) && (sp[i] & (1 << (m % (setbits+1)))))
X return (true);
X return (false);
X}
X
Xstatic setptr
XInsmem(m, sp)
X register unsigned int m;
X register setptr sp;
X{
X register int i,
X j = m / (setbits+1) + 1;
X
X if (*sp < j)
X for (i = *sp + 1, *sp = j; i <= *sp; i++)
X sp[i] = 0;
X sp[j] |= (1 << (m % (setbits+1)));
X return (sp);
X}
X
X# ifndef SETSPACE
X# define SETSPACE 256
X# endif
Xstatic setptr
XCurrset(n,sp)
X int n;
X setptr sp;
X{
X static setword Space[SETSPACE];
X static setptr Top = Space;
X
X switch (n) {
X case 0:
X Top = Space;
X return (0);
X case 1:
X if (&Space[SETSPACE] - Top <= 15) {
X (void)fprintf(stderr, "Set-space exhausted\n");
X exit(1);
X }
X *Top = 0;
X return (Top);
X case 2:
X if (Top <= &sp[*sp])
X Top = &sp[*sp + 1];
X return (sp);
X }
X /* NOTREACHED */
X}
X
Xstatic void
XSetncpy(S1, S2, N)
X register setptr S1, S2;
X register unsigned int N;
X{
X register unsigned int m;
X
X N /= sizeof(setword);
X *S1++ = --N;
X m = *S2++;
X while (m != 0 && N != 0) {
X *S1++ = *S2++;
X --N;
X --m;
X }
X while (N-- != 0)
X *S1++ = 0;
X}
X
Xstatic void
XCaseerror(n)
X int n;
X{
X (void)fprintf(stderr, "Missing case limb: line %d\n", n);
X exit(1);
X}
X
END_OF_FILE
if test 28856 -ne `wc -c <'ptc.c.7'`; then
echo shar: \"'ptc.c.7'\" unpacked with wrong size!
fi
# end of 'ptc.c.7'
fi
if test -f 'ptc.man' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ptc.man'\"
else
echo shar: Extracting \"'ptc.man'\" \(2583 characters\)
sed "s/^X//" >'ptc.man' <<'END_OF_FILE'
XFrom enea!holtec!perb Sat May 9 17:47:50 1987
XReceived: by mirror.TMC.COM; Sat, 9 May 87 17:47:37 edt
XReceived: from enea.UUCP by seismo.CSS.GOV (5.54/1.14) with UUCP
X id AA12891; Sat, 9 May 87 16:51:27 EDT
XReceived: by enea.se (5.51/1.33)
X id AA18863; Sat, 9 May 87 22:36:30 +0200 (MET)
XReceived: by chalmers.UUCP id AA22220; Sat, 9 May 87 22:08:11 -0200
XReceived: by holtec.uucp (2.0/SMI-2.0)
X id AA12513; Sat, 9 May 87 21:24:27 -0200
XDate: Sat, 9 May 87 21:24:27 -0200
XFrom: enea!holtec!perb (Per Bergsten)
XMessage-Id: <8705091924.AA12513@holtec.uucp>
XTo: mirror!sources
XStatus: R
X
XSubject: ptc.man
X.\" @(#)ptc.man 1.3 Date 87/05/09
X.if \nP .pl \nP
X.TH PTC 1
X.SH NAME
Xptc \- Pascal to C translator
X.SH SYNOPSIS
X.B ptc
X< pascal\ source > c\ source
X.SH DESCRIPTION
X.I Ptc
Xreads a correct Pascal program and prints a C program with
Xthe same behaviour.
XIt is intended as a tool for transporting finished applications to
Xenvironments that lack Pascal compilers,
Xit is
X.I not
Xintended for program development.
X.PP
XThe input should comply with the ISO level 0 Pascal definition.
XTwo common Pascal extensions are also recognized: the keyword
X.B otherwise
Xmay be used for default entries in case-statements,
Xthe keyword
X.B external
Xmay be used in place of the forward directive to signify that
Xa procedure or function is defined in a library.
XFurthermore,
Xthe translator does not require a complete Pascal program,
Xa consistent subset of declarations can be translated.
XThus a primitive module concept is supported.
X.SH "SEE ALSO"
XPtc implementation notes.
X.SH CAVEATS
XThe quality of an object program is of course highly dependent on the
XC compiler that processes the translated code.
XArithmetic operations are sometimes implemented in a way that is incompatible
Xwith the Pascal definition.
XFor example, the translator assumes that:
X.sp
X.nf
X a := b mod c
X.fi
X.sp
Xcan be accurately translated into
X.sp
X.nf
X a = b % c
X.fi
X.sp
Xbut that may not be true if c is negative.
XA check on the characteristics of integer and float arithmetic is
Xstrongly recommended.
X.PP
XSome Pascal constructs are impossible to express in C.
XThe translator will not object to:
X.sp
X.nf
X type ptr = ^ ptr;
X.fi
X.sp
Xbut a C-compiler may balk at the resulting:
X.sp
X.nf
X typedef ptr * ptr;
X.fi
X.sp
X.SH BUGS
XThe program can't translate comments from Pascal to C.
X.sp
XThe translator does not do complete typechecking so
Xa Pascal program that isn't formally correct may cause malfunction.
X.sp
XPassing a procedure as parameter to an enclosing recursive procedure
Xmay produce erroneous code (see the implementation notes).
X
END_OF_FILE
if test 2583 -ne `wc -c <'ptc.man'`; then
echo shar: \"'ptc.man'\" unpacked with wrong size!
fi
# end of 'ptc.man'
fi
echo shar: End of archive 1 \(of 12\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 12 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Rich $alz "Anger is an energy"
Cronus Project, BBN Labs rsalz@bbn.com
Moderator, comp.sources.unix sources@uunet.uu.net