/* Copyright (c) 1979 Regents of the University of California */
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.2 November 1978
* This version of pi has been in use at Berkeley since May 1977
* and is very stable, except for the syntactic error recovery which
* has just been written. Please report any problems with the error
* recovery to the second author at the address given in the file
* READ_ME. The second author takes full responsibility for any bugs
* in the syntactic error recovery.
char piusage
[] = "pi [ -blnpstuw ] [ -i file ... ] name.p";
char pixusage
[] = "pix [ -blnpstuw ] [ -i file ... ] name.p [ arg ... ]";
char *ppcname
= "ppc.p1";
char *ppcdname
= "ppcd.p1";
char *pTreeName
= "pi.pTree";
* Be careful changing errfile and howfile.
* There are the "magic" constants 9 and 15 immediately below.
char *errfile
= "/usr/lib/pi1.2strings";
char *howfile
= "/usr/lib/how_pi\0";
* these are made real variables
* if you are compiling on a smaller machine
double MAXINT
= 2147483647.;
double MININT
= -2147483648.;
* Process options, then call yymain
* to do all the real work.
errfile
+= 9, howfile
+= 9;
if (argv
[0][0] == '-' && argv
[0][1] == 'o') {
execl("/bin/cat", "cat", howfile
, 0);
opt('p') = opt('t') = opt('b') = 1;
while (c
= *cp
++) switch (c
) {
if (dotted(argv
[1], 'p'))
pflstc
++, argc
--, argv
++;
Perror( "Usage", usageis
);
efil
= open ( errfile
, 0 );
perror(errfile
), pexit(NOSTART
);
if (!dotted(filename
, 'p')) {
Perror(filename
, "Name must end in '.p'");
if ( ( ibuf
= fopen ( filename
, "r" ) ) == NULL
)
perror(filename
), pexit(NOSTART
);
if ( ( ppcstream
= fopen( ppcname
, "w" ) ) == NULL
) {
if ( ( ppcdstream
= fopen( ppcdname
, "w" ) ) == NULL
) {
putprintf( "# compilation of %s" , filename
);
if ( ! pCreate( pTreeName
, MAXpPAGES
) ) {
if ((signal(2, 1) & 01) == 0)
char ugh
[] = "Fatal error in pi\n";
* Exit from the Pascal system.
* We throw in an ungraceful termination
* message if c > 1 indicating a severe
* error such as running out of memory
* or an internal inconsistency.
if (opt('l') && c
!= DIED
&& c
!= NOSTART
)
write(2, ugh
, sizeof ugh
);
* this to gather statistics on programs being compiled
* taken 20 june 79 ... peter
* execl("/usr/lib/gather", "gather", cp, filename, 0);
* Get an error message from the error message file
lseek(efil
, (long) seekpt
, 0);
if (read(efil
, buf
, 256) <= 0)
perror(errfile
), pexit(DIED
);
if (anyheaders
&& opt('n'))
printf("Berkeley Pascal PI -- Version 1.2 (%s)\n\n%s %s\n\n",
version
, myctime(&tvec
), filename
);