22_23_Pascal_News_Sep81 22 23 Pascal News Sep81

22_23_Pascal_News_Sep81 22_23_Pascal_News_Sep81

User Manual: 22_23_Pascal_News_Sep81

Open the PDF directly: View PDF PDF.
Page Count: 90

Download22_23_Pascal_News_Sep81 22 23 Pascal News Sep81
Open PDF In BrowserView PDF
Pascal Users Group

NUMBER 22 & 23

Pascal News
COMMUNICATIONS ABOUT THE PROGRAMMING LANGUAGE

PASCAL BY PASCALERS

.,

SEPTEMBER, 1981

Two for one ...

..-

--

..

»

-

•

-

.....

Or one for two?

POLICY:

PASCAL NEWS

(15-Sep-80)

* Pascal News is the official but informal publication of the User's Group.
* Pascal News contains all we (the editors) know about Pascal; we use it as
the vehicle to answer all inquiries because our physical energy and
resources for answering individual requests are finite.
As PUG grows, we
unfortunately succumb to the reality of:
Having to insist that people who need to know "about Pascal" join PUG
and read Pascal News - that is why we spend time to produce it!

1.

2. Refusing to return phone calls or answer letters full of questions - we
will pass the questions on to the readership of Pascal News.
Please
understand what the collective effect of individual inquiries has at the
"concentrators" (our phones and mailboxes). We are trying honestly to say:
"We cannot promise more that we can do."

* Pascal News is produced 3 or 4 times during a year; usually in March, June,
Septemb~and

December.

* ALL THE NEWS THAT'S fIT, WE PRINT.

Please send material (brevity is a
virtue) for Pascal News single-spaced and camera-ready (use dark ribbon and
18.5 cm lines!)
--

~

u
.-

-o
a.

* Remember:

ALL LETTERS TO US WILL BE PRINTED UNLESS THEY CONTAIN A REQUEST
TO THE CONTRARY.

* Pascal News is divided into flexible sections:
POLICY - explains the way we do things (ALL-PURPOSE COUPON, etc.)
EDITOR'S CONTRIBUTION - passes along the opinion and point of view of the
editor together with changes in the mechanics of PUG operation, etc.
HERE AND THERE WITH PASCAL - presents news from people, conference
announcements and reports, new books and articles (including reviews),
notices of Pascal in the news, history, membership rosters, etc.
APPLICATIONS - presents and documents source programs written in Pascal
for various algorithms, and software tools for a Pascal environment; news
of significant applications programs.
Also cr itiques regarding
program/algorithm certification, performance, standards conformance,
style, output convenience, a~p general design.
ARTICLES - contains formal, submitted contributions (such as Pascal
philosophy, use of Pascal as a teaching tool, use of Pascal at different
computer installations, how to promote Pascal, etc.).
OPEN FORUM FOR MEMBERS - contains short, informal correspondence among
members which is of interest to the readership of Pascal News.
IMPLEMENTATION NOTES - reports news of Pascal implementations: contacts
for maintainers, implementors, distributors, and documentors of various
implementations as well as where to send bug reports. Qualitative and
quantitative descriptions and comparisons of various implementations are
publicized. Sections contain information about Portable Pascals, Pascal
Variants, Feature-Implementation Notes,
and Machine-Dependent
Implementations.

- - - - - - ALL-PURPOSE COUPON - - - - - Pascal UserslGroup
P.O. Box 4406
'Allentown, Pa. 18104-4406

(lS-Dec-8l)

USA

**Note**
We will not accept purchase orders.
Make checks payable to: "Pascal Users Group",drawn on a U.s. bank in
U.s. dollars.
Note the discounts below, for multi-year subscription and renewal.
The U. S. Postal Service does not forward Pascal News.
USA
[

]

Enter me as a new member for:

[

]

Renew my subscription for:

[

]

UK

Europe

Aust.

~

[ ]

1 year

$10.

#6.

DM20.

A$8.

[ ]

2 years

$18.

#10.

DM45.

A$15.

[ ]

3 years

$25.

#15.

DM50.

A$20.

:

Send Back Issue(s)

[]

My new

address/phone is listed below

[]

Enclosed please find a contribution, idea, article or opinion which is
submitted for publication in the Pascal News.

[]

Comments:

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

ENCLOSED PLEASE FIND:
CHECK no.
NAME
ADDRESS

PHONE

i----------·..;."""";-\,_____________

COMPUTER_~------......

DATE

'.,,

JOINING

~ASCAL

USERS GROUP?

- Membership is open to anyone:
Particularly the Pascal user, teacher,
maintainer, implementor, distributor, or just plain fan.
- Please enclose the proper prepayment (check payable to "pascal User's
Group"); we will not. bill you.
- Please do not senaus purchase orders; we cannot endure the paper work!
- When you join PUG any time within a year: January 1 to December 31, you will
receive all issues of Pascal News for that year.
- We produce Pascal News as a---means toward the end of promoting P.ascal and
communicating news or events surrounding Pascal to persons interested in
Pascal. We are simply interested in the news ourselves and prefer to share
it through Pascal News. We desire to minimize paperwork, because we have
other work to do. ---- American Region (North and South America)

Join through PUG (USA) •

- European Region (Europe, North Africa, Western Asia): Join through PUG (EUR)
Pascal
Users
Gr~up,
c/o
Grado
Computer
Systems
&
Software,
Weissenburgerstrasse 25, D-8000, Munchen 80, Germany~
- United Kingdom Region : )01n through PUG (UK) : Pascal Users Group,
Shetlandtel, Walls, Shetland, ZE2 9PF, United Kingdom.

c/o

- Australasian Region (~ustralia, East Asia - incl.India & Japan):
PUG(AUS).
pascal Users Group, c/o Arthur Sale, Department of Information SC ience,
Universi ty of Tasmania, Box 252C GPO, Hobart, Tasmania 7001, Australia ..
International telephone: 61-02-202374

RENEWING?
- Please renew early (before November) and please write us a line or two to
tell us what you are doing with pascal, and tell us what you think of PUG and
pascal~.
Renewing for more than one year saves us time.
ORDERiNG BACK ISSUES OR EXTRA ISSUES?
- Our unusual policy of automatically sending all issues of Pascal ~ to
anyone who joins wi thin a year means that we el iminate many requests for
backissues ahead of time, and we don't have to reprint important information
in every issue--especially about Pascal implementations!
- Issues 1 •• 8 (January, 1974- May 1977) are

~

of print ..

- Issues 9 •• 12, 13 •• 16, &. 17 ... 20 are available from PUG (USA) all for
$15.00 a set, and from PUG(AUS) all for $A15.00 a set.
- Extra single copies of new issues (current academic year) are:
PUG(USA);
and $A5.00 each - PUG(AUS).

$5.00 each -

SENDING MATERIAL FOR PUBLICATION?
- Your experiences with Pascal (teaching and otherwise), ideas, letters,
opinions, notices, news, articles, conference announcements, reports,
implementation information, applications, etc. are welcome.
Please send
material single-spaced and in camera-ready (use a dark ribbon and lines 18.5
em .. wide) form.
All letters will be printed unless they contain a request to the contrary.

Pascal News #22 & 23

rou PONS

t)

POI. r CY,

:I

FDTTORS CONTRTBUTION

3

HFRF ANn THFRE WJTH

3

SUhlm~rY

for'

4

Index

SePtember' 1981

1

r NDE}', FTC.

of

PasD~1
1('IPJp.hlf'nt~tjons

t;. 'ia r s hal 1

PN 1!=i .. f 9

APPLICATJONS

4

The FM1 Compjler (node)

A. Tanenbaum

38

Optjons -- Control Statement
Opt.jon Settins

s.

39

Treeprint -- Prints Trees
on a Character Printer

Freed & Carosso

44

Co,press & Reoall -- Text
nompression Hsins Huffman codes

T. 510ne

"The Perform~ncp. of' three CPIM
Toran.:; J at.or~"1

,Johnson i:-.
Sidebottom

so

ARTIClES

"A Geosrapher Teache$ Pascal -RefJeDtjon~

58

Leonard

on

~he

OPEN FORUM FOR I"!EMBERS

88

IMPLEMENTATION NOTES

81

ONE PURPOSE COUPON, POLICY

J.

Pitzl

Experienoe"

"An Extension That Solves Four
Pr'ob) ems"

61

~ased

.1. Vallner

APPLICATION FOR LICENSE TO USE VALIDATION SUITE FOR PASCAL
Name and address of reqestor:
(Company name if requestor is a company):
Phone Number:
Name and address to which information should
be addressed (write "as above" if the same)

Signature of requestor:
Date:
In making this application, which should be signed by a responsible person in the case of a company, the requestor agrees that:
a) The Validation Suite is recognized as being the copyrighted, proprietary property
of R. A. Freak and A. H. J. Sale, and
b) The requestor will not distribute or otherwise make available machine-readable
copies of the Validation Suite, modified or unmodified, to any third party
without written permission of the copyright holders.
In return, the copyright holders grant full permission to use the programs and documentation contained in the
Validation Suite forthe purpose of compiler validation, acceptance tests, benchmarking, preparation of comparative reports and similar purposes, and to make available the listings of the results of compilation and execution of the programs to third parties in the course of the above activities. In such documents, reference
shall be made to the original copyright notice and its source.
I

Distribution Charge: $50.00
Make checks payable to ANP AIRI in US dollars drawn on a US bank.
Remittance must accompany application.
Source Code Delivery Medium Specification;
) 800 bpi, 9-track, NRZI, odd parity, 600' magnetic tape
) 1600 bpi, 9-track, PE, odd parity, 600' magnetic tape

Mail Request to:
ANPAIRI
P.O. Box 598
Easton, Pa. 18042
USA
Attn: R. J. Cichelli

) ANSI-STANDARD
a) Select Character Code Set:
( ) ASCII
( ) EBCDIC
b) Each logical record is an 80 character card image. Select block size in logical records per block.
( ) 40
I

(

)

( ) 20

( ) 10

Special DEC System Alternates:
) RSX-IAS PIP Format (requires ANSI MAGtape RSX SYSGEN)
( ) DOS-RSTS FLX Format

Office Use Only
Signed
Date
Richard J. Cichelli
On behalf. of A.H.J. Sale and R,A.Freak

Editor's Contribution
GOOFED

!;)Gt~

I"·'

res as all ~ou loyal PenSylVanlan! h~ue noticed
In th~ last
Issue of PH we Manased to Mess UP the ZIP cooeoF ~llentdwn PAr
and of course the USPS ha$ ~ome down on us 11~e a tono~ brlC~S'
Please not.e t.hRt t.he ZIP js 18014 IHft 1817'). It ha;; been
oorrect.ed In the new APe.

THE NEW APC
--Speaklns of the new APC. we have ~lmplificd it -ome More. an~
added current prlces for the UK and Furopp. and h3ue Mod.fled the
reverse sIde of the coupon to reflect the neu foreisn edItors.
and their current addres5es •

.I.t:.tt:: LATEST EUROPEAN 2.QhUTION
Speaking of the Furop~an editor5. we have two new ones! nne for
the UK, and on. For the Continent. Nlck Hu~hes wI11 be handling
all buslness tor Flori.taln" and Hellmut. ',Jc!ie'r WIll he In chs'rse 0':
the European Reslon. Pl&ase ,ee the APe for their addresses.

ON CALLING
Please restrlct your,elf to wrI~ten Dorre5Ponoence when dealing
WIth PUG. This is 5trintly ~ sGhnlArlv funDtlon~ None of the
e d i t. 0 r ~ ',i n c J It din:9 trl v F. ~ I Pi ',1 e t!" PAuL (it 1 hill.' e 3 f er.:t 1 .j 0 b t hll 't
F' a }' s

t.

he1 r

b] 1 I

57

~nd

they owe

t)H~ 1 'r'

0

i' fiG e I h 0 u 'r stO

t. h e 1. r

eMPloyer. All PUG wor~ I; donated on theIr own tiMe. So FJe3~e
,,,rIte to t:heiilFi'proP'f'iiilt,e re~uoni'l.l editor. ft le:l'.les iii doci.ifnentBT'"
traIl tha.T. can be t'ollo(4ed rind I";::tndled ~<: Fast as Me cari. Honest.'

COMBINED .ISSUE
This is of course a oombined Issue. We ~re d~~n9 ~his to catch UP
and to beat the postal ~ystem i'tnd theirht~h ra~es. Tf this
upsets an:·'one we are ;orr>'. t·Jc~ are doi.ngour hest.

ON _BE_I_NG _TH_E_ .:E:,: D;.,: ;I. .:. T=O.. ,.R
An)'one wlho is Interested in beinst,hene"" edItor aF PN should
write to me at the frliunaddress (APe).

STANDARDS
Good news frOM the stand~rd fro.nt!' 7!S5. t u.::t1J JlPpro'Jed bi' the,
International COMMittee •. Mor.'·ne!-

'"'"

225

O•• rwlim;

226

0 •• t8m1;

228
229
l!30
231
232

233
235
236
237
238
23'9
240

{pointer typesl
IIP=
Alltruoture:
11>=
"identi fier :
Ip=
'labl;
bp.
'blockini'o:
np=

{set types}
sOS'S

set of symbol;
set of idol ass :
set Of strootfo"";
set of struotflag;
set of identflag;

242
243
24lj

{array types I
alpha .packed array[ idrangeJ afchar;
fntype'paoked a.... ay[ fnrange] of char;

246

254
255
256

{record typesl
-errec=record
erno:lnt-eger;
mess: alph:a;
me$i ~lnteger;
chno:lntecger;
lino:integer ;
linr :integer;
orig:integer :
fnam:fntype;
end;

258
259
260

position'record
ad :integer;
Iv :integer;

241
248
249
250
251
252

253

261

Uirder SEGMENTS

262
263

Dendir

264

end;

266
267
268
269

270
271
272
273
274

215
276

277
278
279
280

·sg :sgrange

end;

283
2M
285
286

nameinfo=record

288
289
290

nlin-k:np;
fname:ip;
case occur :where of
blck:();
reo: 0;
wrec.:(wa:attr)
end;

292
293
294
295
296
297
298

blockinfo=reoord
nextbp:bp;
lc:integer;
ilbno:integer:
rorwcount :integer;
lchain :lp;
end;

300
301
302

st.rueture~record

281

""nameinfo;

setofids.
f'ormset.
sflagset.
iflagset=

281

303
{error numbed
!identifier parameter if required}
{numeric parameter if required}
{column number}
{lin en umber}
{relative to start. of (included) file}
{idem, but. before preproces!ling)
{source· file neme}

3011

305
306

307
308
309
310
311
312

313
{the addr info of certain variable}
{for locals i t is the byte offsetl
{the level of the beast)
{only relevant for globals (lv"O) }

315
316

317

{all info of the current procedurel
{pointer to blockinfo Of surrounding proc}
{data" location "ounter (from begin of proc)
{number of last local label}
{number of not yet spe"lfied forward procs}
{first label: header of chain}

s.1ze.:integer;
sflag:sflagset;
case form:structform of
scalar : (scalno:integer;
fconst:ip
subrange: (min .max :integer;
rangetype :sp;
subrno:lnteger

);

324
325
326
327

328
329
332
333
334

335
336

{number of range descriptor}
{names of constants}
{lower and upper bound}
{type of bounds}
{number of subr descriptor}

);

pointer : (eHype :sp);
power
: (elset :sp);
files
: (flltype :sp);
arrays ,csrray:
(aeltype:sp:
inx type :sp ~
arpos :posl tion
records:( fstfld :ip;
tagsp:sp

322
323

{size of structure in bytes}
{flag bits}

);

319

331
{type of expressionl
{true for packed elementsl
{access method}
{sg. Iv and ad}
in ad}

{name space opened by with statement}

318
320
321

{records of type attr are used to remember qualities of
expression parts to delay the loading of them.
Reasons to delay the loading of one word constants:
- bound checking
- set building.
Reasons to delay the loading of direct accessible objects:
- efficient handling of read/wri'te
- efficient handling of the with statement.
attr=record
asp:sp;
packbit :boolean;
ak :attrkind;
pos :po sition;
{If ak=cst then the val ue is stored

314

{one for each separate name space J
{one deeper}
{first name:· root of treel

{type ofpolnted object}
{type of set elementsl
{type of file elements}
{type of array elements}
{type of array index}
{position of array descriptor}

-<.D
00

{points to first fieldl
{points to tag if present}

);

variant ': (varval :integer;
nxtvar':sp;
subtsp:sp

{tag value for this variantl
{next equilevel Variant}
{points to tag for sub-case }

);

tag

:(fstvar:sp;
tfldsp:sp

{first variant of case}
{type of tagl

)

...,
'"m
>

identifier. record
idtype:sp;
narile:alpha;
llink.rl1nk:ip;
next :ip;
iflag:iflagset;

{type of identifier!
{name of identified
{see enterid,search1d}
{used to make several chains)
{several flag bitsl

337
338
339
3~O
3~1

342
343
344
345

346
347
348
349
350
351
352
353
35q
355
356
357
358
359
360

361

case klasa ide lass of
types
0;
(value:integer);
{for integers the value is
konst
COInputed and stored in this field.
For strings and reals an assembler constant is
defined labeled '.1', '.2' •...
This '.' number is then stored in value.
For reals value may be negated to indicate that
the opposite of the assembleroonstant is needed.
val'S
:(vpos:position);
{position of' var}
field
: (totfset :integer);
{offset to begin of record}
carrbnd :0:
lid type pOints to carray)'
proe,func:
(oase pfkind :kindofpf of
{identifioation}
standard :(key:standpf):
formal ,actual,forwrd ,E!-xtrn:
(pfpos:position:
{l'i gives declaration level.
sg gives instruction segment of this proc and
ad 1s relevant for formal pf's and for
functions (no oonfliot!!).
for funotions: ad is the result address.
for formal pf' s: ad is the address of the
descriptor }
(unique pi number)
pfRo :integer:
{head of par ameter list 1
parhead lip;
{le
when heading scanned)
headle: integer

362
363
36q
365

end;

367

labl~record

393

394
395
396
397
398
399
liOO

401
Q02

403
404
405

406
407

408
409
410
411

412
Q13
41Q

415
416
417
418

)

419

368

nextlp:lp;

420
421
422
423
424

369

seen:boolean;

310
311

labval : integer;
labname:integer;
labdlb:integer

372

373
374

376
377
378

379
380
381

382
383
384
385

386
387
388
389
390
391
392

{ohain of labels}

425
{label number given by the progr.ammer}
!label number given by the compiler}
{zero means only locally used,
otherwise dlbno of label information}

430

end;

{--------------------------------------------------------}
v.... {the most frequent used externals are declared first}
sy:symbol:

a:attr;
[returned by insyml
;,h:ohar;
chsy:chartype;
val :integer;
1x :integer;
eol :boolean;
zerostr ing :boolean;
Id:alpha;
[some counters}
lino: integer;
dlbno: integer;
lom8x!lnteger:

level:i'nteger;

426
427
428
429

!last symbol}
{type,access method,posil;ion,value of expr}
!last character}
{type of ch, used by insym}
tit last symbol is an constant
{string length}
{true if current oh replaces a newline}
{true for strings in tI tI}
{if last symbol is an identif1er}
{line number on
{number of last
{keeps track of
{current statio

code file (1 •• n)
global nUlllber}
maximl.lD of Ie)
level}

431

432
433
434
435

436
437
438
439

440
441
442
443
444

445

446
447
448

ptrsize :integer;
realsize :integer;
fhsize:integer;
(file header size)
argc:integer:
{index in argvl
lastpfno:integer;
{unique pf number counter}
copt:integer;
Ie-type strings allowed i f on}
dopt ; integer ;
!longs allowed if on}
iopt:integer;
{number of bits in sets with base integer}
sopt :integer;
{standard option}
{pointers pointing to standard types}
realptr ,intptr ,textptr ,emptyset,boolptr :sp;
charptr ,nilptr ,stringptr ,longptr :sp;
{flags}
giveline :boolean;
{give source line number at next statement}
including:boolean;
{no LIN's for included code}
eofexpected :boolean: {quit without error i f true (nextch)
main !boolean;
{complete programme or a module}
intypedec :boolean;
{true if nested in typedefinition}
fltused :boolean;
{true if floating point instructions are used}
seconddot :boolean;
{ind~cates the second dot of t •• ' }
{pointers}
fwptr:ip;
{head of chain of forward reference pointers}
progp:ip;
{program identifier}
curr proc : ip;
{current proc/func Ip (see case statement) }
top:np;
{pointer to the most recent name space}
lastnp:np;
{pointer to nameinfo of last searched ident
{records)
b:blookinfo;
{all info to be stacked at pfdeolaration}
e :-errec;
{all info required for error messages}
fa :attr;
{attr for current file name}
{arrays}
source:fntype;
{name of pascal scurce file}
strbu1':array[1. .smax] of char;
iop:array[boolean] of ip;
[false :standard input, true :standard output}
rw:array[rwrange] of alpha;
{reserved words}
frw:array[O .. idmax] of integer;
{indices in rw}
rsy:array[rwrange] of symbol;
{symbol for reserved words}
cs :array[ char] of chartype;
{chartype of a character}
csy:array[rparentch •• equal] of symbol;
{symbol for single character symbols}
lmn:array[libmnem) of packed array[1 •• 4} of char;
{mnemonics of pascal library routines}
opt :array[ 1 a' .. t z.'] of integer;
forceopt:array['a' •• 'z'} of boolean:
{26 different options}
undefip:array[idclass] of ip;
{used in searehid)
argv:array[O •• maxargc] of
record name:alpha; aa:integer end;
{save here the external heading names}
(riles)

."

»

'"'"......

em1 :Clle of byte;

{the El41 codel

lili9
li50
li51
li52

{the compilation errors}
{===================================================================}

45li
li55
li56
li57
li58
'159
li60
li61

pr:oce.1ure gen2bytes(b:byte; i :integer);
VBr b1,b2:byte;
begin
if 1(0 then
i f i0 do
beginj:=j+1; n[j]:=chr(i ..od 10 + ord('O'»; i:=i div 10 end;
end;
genO(b); genident(spynam,n)
end;

515
516

procedure genend;
begin write(eml,sp_eend) end;

518
519
520
521

procedure genlin:

523

procedure _genreg(ad ,sz,nr :iriteger);
begin
if sz<=wordsize then
begin gen1(ps_mes,mesreg); genest(ad); genest(nr); genend end
end;

511

524

525
526

527

begin giveline:=false;
if opt[ 'l']<>off then if main then gen1(op_lin,e.orig)

end;

=" ===== ==•••• =•• =••••• ==••• =•••••• =••••••••••••• == =•• ====•• }

529

{= == == ===

531
532
533

procedure puterr (err :integer);
{a~ you--wl11 notice, all error numbers-are preceded by
ease their renumbering in case of new errornumbers.

53li
535

'+'

and 'Ot to

r

536
537

begin e.erno :=err; write(errors,e);
if err)O then begin gen1 (ps_mes,meserror); genend end
end;

......

539

proc~ure

......

<.a

484
485

procedure gen1(b:byte; i :integer);
begin genO(b); gencst(i) end;

487
li88

procedure gend (b :b.yte; d: integer);
begin genO(b); gendlb(d) end;

490
li91
492
493
li94
495
496

procedure genident(nametype:byte; YBr a:alpha);
VBr i,J :integer;
.
begin i:=idmax;
while (a[i]=' ') and (i>1) do i:=i-l;
write(em1,nametype,i);
.
Cor j:=l toi do write(eml,ord(a[j]»
end;

498
499
500
501
502

procedure gensp{m:libmnem);
var i :integer;
begin genO(op cal) ;write(eml,spynam,lI);
Cor 1:~'1 to-4 do write(eml,ord(lmn[mHil»
end;

556

504

proceduregenpnam( b:byte; fip :ip);

560

540

5li2
543

545
546
548

549
551
552

554
555
557

558
559

error (err: integer) ;
begin e.mess_:=spaces; e.mesi:::;. -1; puterr(err) end;

procedure errid(err:integer; var id:alpha);
begin e.m_~ss:=id; e.mesi:= -1; put.err(err) end;
procedure errint(err:i-nteger; i :i.nteger);
begin e ~mesi: =i; e .mess:=spaces; puterr(err) end;
prQCJedure asperr(err:integer);
begin if a.asp<>nil then begin err()r(err); a.asp:=nil end end;
procedure test standard ;
begin i f sopt<>off then error(-(+01»

end;

procedure enterid(fip: ip);
{enter id pointed.at by fip into the name-table,
which o-n each declaration level is organised as
an i.mbal~nced -binary tree}
yar nam:alpha; J!p,l1p1:ip; lleft,again:boolean;
begin nam:=fip"_.name; again:=fal.se;
lip: .top· • fn ame;

00

561
562
563
564
565
566
567
568
569
570
571
572
573
574
575

if lip=nil then top' .fname:=fip else
begin
repeat lip 1: =lip;
if lip' .name>nam then
begin lip:=l1p' .llink; lleft :=true end
else
begin i f lip' .name=nam then again:=true; {name conflict)
lip :=lip' .rlink; lleft: =false;
end;
until l1p=nil;
if Heft then lip1' .llink:=fip else lip1' .rlink:=fip
end:;
fip' .1link:=nll; fip' .rlink:=n11;
if again tben err id (+02, nam) ;
end;

577
578
579
580
581
582

procedure initpos( var ~ p:posi tion);
begin p.lv:=level; p.ad:=O;
lifdef SEGMENTS
p.sg:=O
lendif
end;

584
585
586
587
588
589
590

procedure inita(fsp:sp; fad:integer);
begin wi tb a do begin
asp:=fsp; packbit:=false; ak:=fixed; pos.ad:=fad; pos.lv:=level;
IUdef SEGMENTS
pos.sg:=O;
'endif
end_ end;

592
593
594
595
596
597
598
599
600
601
602
603
604

function newip(kl:idclass; n:alpba; idt:sp; nxt:ip):ip;
var p:ip; f:iflagset;
begin f:=[l;
case kl of
types,carrbnd~
{similar structure)
new(p,types);
konst:
beginnew(p,konst);~ p' .value:=O end;
vars:
begin new(p,vars);

r :=[used ,assigned];

initpos(p ..... vpos) end;

606
607
608
609
610
611

field:
begin new(p,field); p' .foffset:=O end;
proc,func: {same structurel
begin new(p,proc ,actual); p' .pfkind: =actual;
initpos( p' .pfpos); p' .pfno: =0; p' .parhead: =n11; p' .headlc: =0
end
end;
p' .name:=n; p' .klass:=kl; p' .idtype:=idt; p' .next;=nxt;
p' .1link:=n11; p' .rlink:=nll; p' .iflag:=f; newip:=p
end;

613
614
615
616

function newsp(sf:structform; sz:integer):sp;
var p:sp; sflag:sflagset;
begin sflag:=[l;
case_sf of

605

617
618
619
620
621
622
623
624
625
626
627
628
.629
630
631
632
633
634
635
636
637
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672

scalar:
begin new(p,scalar); p .... scalno:=O; p'" .fcanst:=nil end;
subrange:
new( p,subrange);
pointer:
begin new(p,pointer); p·.eltype:=n11 end;

power:
new( P ,power) ;
files:
begin new(p,files); sflag:=[withfilel end;
arrays,earray: {same structurel
new(p,arrays);
records:
new(p,records) ;
variant:
new(p,variant):
tag:
new(p,tag);
~d;
...
P .form:=sf; p .size:=sz; p'" .sflag:=sflag; newsp:=p;
end;

procedure init 1;
var c :char;
begin
!initialize the first name space)
new(top,blck); top·.occur:=blck; top·.nl1nk:=n11; top·.fname:=nll;
level :=0;
{reserved words}
rw[ Ol:='if
';
rw[ 1]: =' do
1;
rw[ 2l:='of
';
rw[ 3l:='to
';
rw[ 4 J: =' in
I;
rw[ 5l:='or
';
,.
rw[ 6]:='end
';
rw[ 7l: = ' for
'•
rw[ 8l:='nil
,.
rw[ 9]: ='var
';
rw[10):='div
I;
rw[ 11]: = 'mod
,.
rw[12]:='set
';
rw[13l: ='and
';
rw[ 14l: = 'not
rw[15l:='then
,.
rw[ 16l: ='else
';
rw[17l:='with
';
rw[ 1 B]: =' case
I;
rw[19l:='type
,.
rw[20]: =' goto
t;
rw[21]:='file
I;
rw[22l:='begin
';
rw[23l:='until
';
rw[2ijl:='while
,.
rw[25]:='array
,.
rw[26]:='const
I.
rw[27l:='label
';
rw[28J:='r€>peat I;
rw[29l: = 'record ,.
rw[30l:='downto ';
rw[""; _::='packed
,
rw[32l:='program '~;
rw(33]: ='function';

r'."i.

....
....
CD
00

]:::' procedur ';

{corresponding symbols)
rsy[ Ol:=ifsy;
rsy[ 1]:=dosy;
rsy[ 2l: =oj"sy;
rsy[ 3l:=tosy;
rsy[ ijl:=insy;
rsy[ 5l:=orsy;
rsy[ 6l:=endsy;
rsy[ 7l:=forsy;
rsy[ 8l: =nilcst;
rsy[ 9l:=varsy;
rsy[10l:=divsy;
rsy[11l: =modsy;
rsy[12l: =setsy;
rsy[13l: =andsy;
rsy[14l:=notsy;
rsy[ 15l: =thensy;
rsy[ 16l: =elsesy;
rsy[17l: =withsy;
rsy[ 18l: =casesy;
rsy[ 19l: =typesy;
rsy[20l: =gotosy;
rsy[21l: =filesy;
rsy[22l: =beginsy;
rsy[23l: =untilsy;
rsy[2ij l: =whilesy;
rsy[25l: =arraysy;
rsy[26l: =cOnstsy;
rsy[271: =labelsy;
rsy[28l: =repeatsy;
rsy[29l: =recordsy;
rsy[30l: =downtosy;
rsy[31l: =packedsy';
r sy[ 32l: =progsy;
rsy[33l: =funcsy;
rsy[34l: =procsy;
!indices into rw to find reserved words fast)
frw[Ol:= 0; frw[1l:= 0; frw[2l:= 6; frw[3l:=15; frw[4l:=22;

,.

-0

'"'"

613
6711
675

676
677

678.
679
680
681
682
683
684

68.5
686
687
688

689
690
691
692
693
694
695

696
697

698
699
701
702
703
704
705

706
707
708
709
110

711
712
713
1H
715
716
717
716
719
720
721
722
723
724
725
726
727
728

frw£S.l: =28~ frw[6 1: =32; rrW£71: =33: frw[8J: =35:
{cha.. types}
tor e:=ch!'(O) to ohr(maxcharord) do os[c]:"others:
f'or 0::'0' to '9' do cs[cJ:=dig1t:
f'or c:='A' to 'Z' do cs[cl:=upper;
tor .c:"'a' to 'z.' do cs[c):"lower;
ca[ chr (new! ine) ): =layout :
ca[chrChortab)]: :layout;
ca[ chr (formfeed) ): =layout ;
cs[ch!'( carret)]: =layout:
{characters with corresponding char type in ASCII order}
cst ch!'( tab)}: =tabch:
cs["tt):=quotech;
csr' 'J:=layout;
cs[ 'ft'l::dquotech;
cs[ t • •' 1:.• star;
cs[' ('1: :lparentch;
es[')'] :=rparentch;
cst '-']:=minah;
est '+'l!=pluaoh;
os[',' l:=commach;
cs[ ': 'l:=-colonoh;
cs['. '1::periodch:
cs[' /'): =slash;
'JS[ t='l:=equal;
cs[ '; ']: =semioh;
os[ '(' J: =lessch;
cs[ ') 'J: =greaterch;
os[ '[ '): =lbrackah:
cst '1 'l:=rbrackch;
as[ t"]:=arrowch;
cs[ t{' ]:=lbracech;
{single character symbols 1n chartype order}
<>sy[ rparentoh]: =rparent;
csy[ Ibrackch]: =lbrack;
csy[ rbrackch] : =rbrack;
csy[ commach}: :comma;
"sy[semiah]: =semicolon;
csy[arrowc.h1: =arrow;
csy[pluaoh]: =plUSSY;'
csy[minoh}: =minsy;
esy[slash}: =slashsy;
asy[starl: =starsy;
csy[ equal] : =eqsy;
end;
procedure 1n1t2;
var p,q.:ip; k :idclass;
bea1D
{undefined identifier pointers used by searchid}
f'or k:=types to fUne do
undefip[k]: =newip(k,spaces ,nil,nil};
{standard type pointers. some size are filled in by handleopts}
intptr
:=newsp(scalar,ints1ze);
!"ealptr :=newsp(scalar ,0);
longptr ::newspCscalar ,longsize);
oharptr ::newsp(scalar,chars1ze);
boolptr :=newsp(scalar,boolsize);
nilptr
:=newsp(pointer,O);
st.,,1ngptr: =newspC pointer ,0):
emptyset : :newsp(power ,ints1",,}: emptyset' .elset: =nil;
textptr ::.newspCfiles.O); textptr' .fil type :=charptr;
{standard type names}
enterid(newip(types,' integer '.intptr ,nU»;
enteridCnewip(types, 'real
' .realptr ,nil»;
enterid(newip(types,' "hal'
' ,.,harptr ,nil»;
enterld(newipCtypes, 'boolean ., ,boolptt ,nil»;
enteridCnewip{types. 'text
',textptr ,oU»;
{standard constant namesl
q:=nil; p:=newip(konst,'false
',boolptr,ql; enterid(p);
q:=p; p:=newip(konst.'true
',boolptr,q); p·.value:=l; enterid(p);
boolptr' .fconst: =p;
p:=newip(konst, '_int ',lntptr ,oi1); pA .value :=maxint; enterid(p);
p:=new1p(kcnst. ,spaces,charptr ,oiI}; p'. value: =maxcharord;

729
730

732
133
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
170

charptr .rconst: =p;
A

end;

procedure in1t3.
var j:standpf; p:lp; q:np;
pfn :array[ standprJ of alpha.
ftype:array(feof •• farctan] of sp;
bea1D
{names of standard procedures/functions}
pfn[pread
]:='read
': pfn[preadln
]:='readln ';
pfn[pwrite
):='write
,. pfn[pwriteln
J::'wr,tteln I;
pfn[pput
]:='put
t.
pfn[pget
]:='get';
pfn(ppage
J:='page
'; pfn[preset
]:='reset
pfn(prewrite J:='rewrite '; pfn[pnew
1: =tnew:
';
;
pfn[pdispose ):='dispose '; pfn[ppack
l:='pack
pfn[punpack
):='unpack '; pfn[pmark
):='mark
';
t;
pfn[prelease ):='release '; pfn[phalt
):='halt
,,
pfn[feaf
l:='eof
'; pfn(feoln
l:='eoln
t;
pfn[fabs
]: ='abs
'; pfn[fsqr
J:='sqr
pfn[ford
l:='ord
'; pfn[fchr
]:='chr
';
,;
pfn[fpred
J: ='pred
': pfn[fsucc
J: :'succ
,;
pfn[fodd
]: ='odd
'; pfn[ftrunc
):='trunc
pfn[fround
J:='round
t; pfn[fsin
):='81n
';
pfn[feos
): ='cos
'; pfn[ fexp
J: ='exp
pfn[ rsqrt
):.' sqrt
'; pfn[ fln
]:='In
pfn[farctan
1: =' arctan ';
{parameter types of standard functions I
ftype[feof
J: =nil;
ftype[ feoln
]::nl1;
ft ypeUab s
1 : =nil;
ft ype [ fsqr
J: =nil;
ftype[ford
1: =nU;
ftype[ fehr
l::intptr;
ftype[fpred
):=n11;
ftype[fsuce
]:"n11;
ftype[ fodd
]: :intptr;
ftype[ ftrunc
]:=n11;
ftype[fround J: =nil;
ftype[fsin
1: =realptr
ftype[fcos
]:=realptr:
ftype[fexp
): =realptr
ftype[fsqrt
J:=realptr:
ftype[fln
1: =realptr
ftype[ farctan ]: =realptr;
£Standard procedure/function identifiers}
for j: =pread to phalt do
begin newCp,proc ,standard}; p' .klass:=proa;
p~.name:=pfnrj]; p·.pfkind:=standard; pA.key:"j; enterld(p);

,

.

end;

772
173
774
775
776
777
778

for j: =feo f to fare tan do
beaio new(p,func ,standard); pA .klass:=fUnc; p' .ldtype:=ftype[j1;
lidtype is used not for result type but for parameter type !!
p' .name:=pfn[jJ; p' .pfkind:=standard; p~ .keY:"j; enterid(p);
end;
{program identifier}
progp:=newip(proc. t _main
' ,nllt-ni1);
{new name space for user externals}
new(q,blck); qA .ocaur:=blck; q' .nlink:=top; q" .fname:=nll; top:=q;

779

end;

781
782
783
784

procedure init4;

771

vat" c:char-;

begin
(pascal library mnemonics)

"...m
".

......
o

785
786
787
788
789
790
791
792
793
794
795

196
797
798
799
800
801
802
803
804

805
806
807
808
809
810
811
812
813

an

815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
836
839
8110

lmn[ELK
lmn[WW
lmn[OPN
lmn[RDC
lmn[RLK
lmn[eRE
lmn[WSI
lmn[WRS
lmn[WSB
lmn[WRL
lmn[WRF
lmn[WLK
lmn[ABR
lmn[COS
lmn[LOG
lmn[ABL
lmn[SCP
lmn[SAV
lmn[HLT
lmn[.PAC
lmn[ASa
{options}

.'_018';

h=' e1n';

lmn[EFL ]:.' _en';

lmn[CLS. ]:

J: :t-rdc';

lmn[GETX]; =' _set t ;
lmn[RDR ]:. '_rdr';

lmo[RDI ]:
rdi' ;
lmn[RDL ]: =.' ::rdl';
lmn[WRI
lmn[WSC
lmn[WBB
lmn[WSR

]::'_cos';
]:='_logl;

lmn[PUTX]:.'J>ut ' ;
lmn[WRC ]: .' wrc';
l.Dm[WSS ];.,-..ss';
lmn[WRR J;"-wrr';
lmn[WSL ]:"-wsl';
lmn[WRZ ]: = ':wrz';
lmn[PAG ]:"J>ag';
lmn[RND l:=' rndt-;
lmn[EXPX]: .' ::exp';
l.Dm[ATN h=' _atn';

]::' abl';
]:=':bcp';
h=t sav';
J:='-hl.t';
l:"Jao"
l:.'_asz l ;

lmn[BTS
lmn[RST
lmn[ASS
lmn[UNP
lmn[MDI

1: :,--wdw';
J:='-opn l ;

1: =':rln';
l: .' _ore';
]:=' wsit;
J: = ':wrs';
]:"_wsb' ;
1:=' wrl':

l:=-'-wrf';
l:;':'wln';

]: 0' _abr';

]:=' bts'-;
]:='-rst.·;

J:='-aas t ;
l:::;':unp';
h"_mdi' ;

.'

l: ='_wri 1;
]:=' wsc';

J: ; '-wrb , ;
h=' =wsr':

lmn[WSZ J:='_wsz' ;
lmn[SIN J: =' sin';
lmn[SQT J: :'::sqtt;
lmn[ABI ]:='_abi';
lmn[REl/Xl:· ' _newt;
lmn[INI 1::' _ini' ;
lmn[GTO J:.' gtot;
lmn[DIS ]:. ':dis';
lmn[MDL ]:=t_mdl';

tor o::'a' to ,,,, do beain opt[cl: "a; forcecpt[c]: .ralse end;
opt['a']:.on;
opt [ 'f'l:.noatsize db wordsize:
opt ( '1' J: =inaxsetint+1:
opt[ '1']::00:
opt[ 'o'J:=oo;
opt[ 'p']: .addrsize div word size;
opt('r'l:=on;
sept ::off;·
{scalar variables}
b.nextbp:=nU;
b.le:=o;
b~Ubno:=O;

b.torweount :::;::0;

b.lcbain::nH;
e.o.OOo:=O;
e.llno:=l:
e ... linr :=1:

e.orlg:=l;
e.fnam:=emptyfnam;
souroe::emptyfnam;
lino::O;
dlbllO:=O;
argo:.1;
lastpfno: =0:
swel1ne: .true ;
inoludins: =false;
eofexpected::false:
intypedeo::false;
fltused:.false;
seconddot: :fal se ;
iop[ fal se l: =n11;
iop[truel: =nH;
01"11,'1[01. ad :=-1;

{default real size in words)

{default pointer size in words}

841
842
844
845
846
847
848
849

argv[l ].ad :=-1;

end;

861

procedure handleopts;
begin
copt:=opt[ 'c']:
dopt:.opt[ 'd'];
iopt:'opt[ 'if];
sopt :=opt[ 's'];
realsize:::;::opt['f'] * wordsize; realptr".size:=realsize;
ptrsize:.opt[' p'] * wordsize; nilptr' .size :=ptrsize;
fhsize:=6*intsize + 2*ptrsize;
textptr'" .size: =fhsize+buffsize; stringptr .... size: =ptrsize;
if SOPt<>off then begin copt:'off; dopt:'off end
else i f opt[ 'u']<>off then os[· ']:.lower;
if copt<>off then enterid (newip(types, • string ',stringptr ,nil»;
if dopt<>off then enterid(newip(types. 'long
, ,longptr ,nil»;
i f opt[ '0' J=off then begin gen1(ps mes,mesoptoff); genend end;
if ptrsize<>wordsize then begin gen1(ps mes,mesvirtuall; genend end;
if dopt<>off then ntused:=true; {tempOrary kludge}
eDd;

863

{=•• =. =•• =: ••• : ••• =. =. ==•• ==. =.=== =.=: •••••• =•• ==•• =. =•• =•• =. :.: •• == }

865
866
867
868
869
870
871
872
873
874
875
876
877
878

procedure trace(tname:alpha; fip:ip; var namdlb:integer);
var i :integer;
beain
if opt[ 't' ]<>off then
begin
if namdlb=O then
begin dlbno:=dlbno+1; namdlb:=dlbnc; gendlb(dlbno);
genO(ps rem); write(em1,sp scon,8);
for i;=1 to 8 do write (em1-;-ord(fip' .name[i]); genend;

880
881

f'unction f'ormo:f"( fsp :sp; forms: form set ) : boolean;

883
884
885
886
88T
888
889

fUnction sizeof(fsp:sp):integer;
var s :integer i
begin 8:=0;
if fsp<>nil then s:.fsp' .size;
i f s<>l then if odd(s) then s:'8+1:
sizeof:.s

891
892

function even(i:integer):integer;
begin if odd(i) then i:=i+l; even:.i end;

894
895
896

procedure exchange( 11,12: integer);
var dl.d2:integer;
begIn d1:.l2-11; d2::Uno-12;

850

851
852
853
854
855
856
857
858
859
860

'O

vordaize tben
betiln U lOcal then gen1(op lal,ad) elae gen1(op_lae,ad):
gen1(op loi,az)
-

.....

91-5

916

-

ellIOt

917

U local tben gen1(op_lol,ad) else gen1(op_loe,ad)

918

1iacI:

920
921
922
923
9211
925

procedure pop(local :boole~: ad : integer : az: integer) :

926

ellIOt
....:.U local·tben gen1(op_stl,ad) else gen1(op_ste,ad)

927

beam .assert DOt, odd (ax) :
lr aZ>WOrdsize 'tben
beIIin U local tben gen1(op lal,ad) else gen1(op_lae,ad):
gen 1(op Bti,sz)
end

-

928930
931

procedure lexical(lI:byte: Iv:integer: ad:integer: sz:integer):
beIIm gen1(op_lex,level-lv): gen1(op_adj.,ad): gen1(II,sz) end:

933

proced...

~311

935

936
937
938
939
9110
9111
9112
9113
91111
9115

9111
9118
950

951
952

e loadpos(var p:position: az:integer):
beam witb p do
ir lv<=O tben
lifdef SEGMEllTS
. U sg<>O then
beII,m gen1(op_lsa,sg): gen1(op_adi,ad): gen1(op_loi,sz) end
el_
lend if
push(global,ad ,sz)
ellIOt
'
Ir Iv=leveltben push(local,ad,sz) else
'lexicalCop_loi,lv,ad,sz):
proci8d.... descraddr(var p:position):

'bellm U p.lv=O tben gend(op_lae,p.ad) ellIOt loadpoa(p,ptraize) end:
proced.... loadaddr:
bea1D·lit.tb a do begin
..... Ilk of

953
9511
955
956
957
958
959
960
961
962
963
9611
965
966
967
968
969
910
971
912
913

fixed :
witb pos do
ir 1 v<=O then
IUdef SEGMENTS
if sg<>O then
begin gen1(op lsa,sg): gen1(op_adi,ad) end

915
916
911
918
919
980
981
982
983
984
985
986
981
988
989
990
991
992
993
994
995

procedure load:
var sz: integer:
begin witb a do begin
sz:=aizeof(asp): if not packbit then sz:=even(sz):
if' asp<>nll then
case ak of
cst:
gen1(op loc,pos.ad): {only one-word scalars}
fixed:
loadpos(pos,sz) :
prixed:
begin loadpos(pos,ptrsize): gen1(op_loi ,sz) end:
loaded :

991
998
999
1000
1001
1002
1003
10011
1005
1006
1007
1008

procedure store;
var sz:integer;
begm witb a do begin
sz:=sizeof(asp): if not packbit then sz:=even(sz):
if' asp<>nll then
case ak of
fixed:
witb pos do
if' 1 v<=O then
lifdef SEGMENTS
ir 'sg<>O then
begin genHop_lsa,sg):

e1se

-

'endif
gen1(op lae,ad)
else
ir Iv=level tben gen1(op lal,ad) else
begin gen1(op_lex,level-lv): gen1(op_adl,ad) end:
pfixed:
loadpos( pos,ptrsize):
pl'!aded:

...,
:J>o

en

n

:J>o

rz:

m
en

:£

indexed :
genO(op aas):
eDd: (case!
ak: =ploaded:
end end:

en

m
...,
.....
m

3:

.""
m

""

.....
<0

.....
00

ploaded:
gen 1(op loi ,sz):
indexed: genO(op las):
eDd: (case!
ak: =loaded:
end end:

...,»
en

1ft

.....
N

1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024

pop(global,ad ,sz)
else
i f level=lv then pope local ,ad ,sz) else
lexical (op_sti ,Iv ,ad ,sz);
pfixed :
begin loadpos(pos ,ptrsize); gen 1(op_sti ,sz) end;
ploaded:
gen1(op sti,sz);
indexed: genO(op sas);
end; {case}
end end;

1026
1027
1028
1029
1030

procedure fieldaddr(off:integer);
begin wi th a do'
if (ak=fixed) and not packbit then pos.ad:=pos.ad+off else
begin loadaddr; gen1(op_adi,off) end
end;

1032
1033

procedure loadcheap;
begin i f formof(a.asp;[arrays •• reoordsJ) then loadaddr else load end;

gen1(op adi,ad); gen1(op_sti,sz)
end
else
Hendif

1066
1067
1068
1069
1070
1071
1072
1073

procedure gete;
var b:byte;
begin
if normal then
begin nextch; c:=ch end
else
begin read(em1,b); c:=chr(b) end
end;

1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092

begin
repeat g etc;
i f (o>='a') and (o<='z') then
begin 01:=0; gete; 1:=0;
if c= '+' then begin i: =1; gete end else
it c= '-' then gete else
i f cs[cJ=digit then
repeat i:=i*10 + ord(c) - ord( '0'); getc;
until cs[ cJ <>digit
else 1:=-1;
if i>=O then
i f not normal then
begin forceopt[ci):=true; opt[ciJ:=i end
else
if not forceopt[cil then opt[ciJ: =i;
end;
until c() I , ' ;
end;
procedure linedirective;
var i,j :integer;
begin i:=O; j:=O;
repeat nextch until (ch<>' ') or eol;
while chsy=digit do
begin.i:=i*10 + ord(ch) - ord('O'); nextch end;
while (ch=' ,). and not eol do nextch;
if (ch<>'"') or (1=0) then error( +04) else
begin nextch;
while (ch<>'"') and not eol do
begin
i f oh=' I' then j: =0 else
begin if j~O then e.f'nam:=emptyfnam;
j:=j+1; i f j<=fnmax then e.fnam[jJ:=ch;
end;
nextch
end;
if source=eroptyfnam then souroe:=e.fnam;
inol uding: =souroe<>e .fnam;
i:=i-1; e.linr:=i;
if Dot including then e.orig:=i
end;
while not eol do nextch;
end;
procedure putdig;
begin ix:=ix+1; if ix<=rmax then strbuf[ix]:=ch; nextch end;

1035

{== ==== == === ==== ==== ===== ==== === ==== ======= ===== ========= ======= ==== }

1037
1038
1039
1040

procedure nextch;
begin
eol:=eoln(input): read(input,ch); e.chno:=e.chno+1; chsy:=cs[ch];
end;

1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061

procedure n ex tl n ;
begin
if eof(input) then
begin
if not eofexpected then error(+03) else
begin
if fltused then begin gen1(ps mes,mesfloats); genend end;
genO (ps eof)
end;
Bifdef STANDARD
goto 9999
Hendif
Uifndef STANDARD
halt
Uendif
end;
e.chno:=O; e.lino:=e.lino+1; e.linr:=e.linr+1;
i f not including" then
begin e.orig:=e.orig+'; giveline:=true end;
end;

1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117

1063
1064

procedure options(normal :boolean);
var c ,ei :char; i :integer;

1119
1120

1122
1123
112~

1125
1126
1127
1128
1129
1130
1131
1132
1133
113~

1135
1136
1137
1139
11~0
11~1
11~2

1143
1144
1145
1146
11~7

1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176

procedure inident~
label 1;
val' i,k :integer ;
beCill k:=O; id:=spaees;
repeat
if ehsy=upper thea ch: =eM (ord (ch) -ord ( 'A' )+ord ( , a' » ;
if k(idmax then bes1n k:=k+l; id[k]:=ch end;
nextch
UJltil ehsy>dlgit;
{lower,,0,upper=1,dig1t=2. ugly but tast}
for i:·=1'rw[k-l J to frw[kJ - 1 do
i f rw[1J=id then
begin sy:·=rsy[iJ; goto 1 end;
sy:=ident;
1:
end;
procedure innllDber;
label
1;
const
imax = 1 0:
vsr
i : intell er :
is:packed srray[l .. imaxJ of char:
begin Ix: =0: sy: =lntcst: val: =0:
repeat putdig until chsy<>digit:
if (oh='.') or (ch=-'e') or (ch= 'E ') then
begill
if ch='.' then
begin putdig:
if "h"'.' then
begin seconddot:=true; ix:=ix-l: goto 1 end:
if chsy<>digit then error(+05) else
repeat putdig until chsy<>,jigit:
endiif (ch"'e') or (ch='E') then
begin putd ig:
if (ch='+') or (ch='-') then putdig:
if ohsy<>digit then error(+06) else
repeat putdig until ohsy<>digit:
end.; _

if ix>rmax then hesin error(+07); ix:=rmax end:
sy:=realcst; fltused :=true; dlbn6:=dlbno+1; val :=dlbno;
gendlb(dlbno); genO(ps rom): write(eml.sp rcon,ix):
for i:=l to ix do wr1te(eml,ord(strbuf[il»: genend:
end;
1 :1f (chsy=lower) or (chsy=upper) then teststandard:
i f sy=intcst then
if Ix> imax then error (+08) else
begIn is:='OOOOOOOOOO': i:=1max+1:
while 1x>0 do
begin i:=1-1: is[iJ:=strbuf[txJ: ix:=1x-l end:
if ls<=maxintstring then
while i <= imax do
begin val:=val"10 - ord('O') + ord(is[1]): 1:=i+l end
else i f (1s<=maXlongstring) and (dopt<>off) then
begin sy: =longcst: dlbno: =dlbno+ 1: val: =dlbno;

1177
1178
1179
1180
1181
1182
1183
1184
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
120~

1205
1206

gendlb(dlbno): genO(ps con): write(em1,sp lcon,imax+1-0:
while i<=imax do
begin write(em1 ,0rd(is[iJ»: i :=i+l end:
genend

end
else errorC+09)
end

end;

procedure instring( qc :char):
var i : integer ;
begin ix :=0; zerostring:=qc= '"1;
repeat
repeat nextch: ix:=ix+l: if' 1x<=smax then strbuf[ixJ:=ch:
until (eh=qc) or eol:
if' ch=qc tben ne"tah else error(+010):
until eh<>qc;
if not zerostr ing then
begin ix: =ix-l: if 1x=0 then error(+011) end
else
begin strbul'[tx J: =eM (0): if copt=off then errore +0 12) end:
i f (ix= 1) and not zerostr ing then
begin sy:=charest; val:=ord(strbuf[l]) end
else
begin sy: =str ingest: dlbno: =dlbnO+ 1: val: =dlbno:
if ix>smax tben begin error(+013): ix:=smax end:
gendlb(dlbno); genO(ps rom): write(eml,sp seon,ix):
for i:=l to ix do write(em1 ,ord(strbuf[U»: genend:
end
end;

1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219

procedure incomment;

1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232

procedure insym;
{read next basic symbol of source program and return its
description in the global variables sy, op, 1d, val and Ix}
label 1:
begin
1 : case chsy of
tabch:
begin e.chno:=e.chno - e.chno .od 8 + 8; nextch; goto 1 end;
layout:
begin i f eol then nextln: nextch: goto 1 end:
lower ,upper: inident;
digit: innmber:

var stope :ohar;
begin- nextch; stope:='}I;
if ch= '$' then options( true} :
while (ch<> , }') and (ch<>stopc) do
begin stope:='}'; if ch='*' then stope:=')';
if' ch=':' then error(-(+014»:
if eol then nextln; nextch
end;
if eh<> , }' then teststandard:

.......

...
'·' then sy:=lparent else
begin teststandard; incomment; goto 1 end;

12li7
12li8
12li9
1250
1251
1252
1253
125li
1255
1256
1257
1258
1259
1260
1261
1262
1263
126li
1265
1266
1267
1268
1269
1270

lbracech:
begin incomment; goto 1 end;
rparentoh,lbraokch,rbrackch,commach,semich,arrowch,
plusoh,minch,slash ,star ,equal:
begin sy:=osy[ohsy]; nextch end;
others:
begin
it (oh="') and (e.chno=1) then linedirective else
begin error(+015); nextoh end;
.
goto 1
end;
end {oase}
end;

1272
1273

proeedure next1f( fsy : symbol ; err: integer);
baSin if sy=fsy then insym else errore-err) end;

1275
1276
1277
1278
1279
1280
1281

function find1(sys 1,sys2:30S; err :integer) :boolean;
{symbol of sys 1 expected. return true if sy in sys 1}
begin
i f not (sy in sys 1) then
begin error(err); ""ile not (sy in SYS1+5Y32) do insym end;
find1: =sy in sY51
end;

1283
128li
1285
1286
1287
1288

function f1nd~ (sys 1, sY82: sos; err :integer): boolean;
{symbol of sys 1+sys2 expected. return true if 8y in sys 1}
begin
it not (sy in sYS1+SY52) then
begin error(err); repeat insym until sy in SYS1+3Y32 end;
find2: =sy in sys 1

end;

".

1289

end;

1291
1292
1293
1294
1295
1296
1297

function find3(sy1:symbol; SYS2:80S; err:integer):boolean;
{symbol sy1 or one of sys2 expected. return true i f syl found and skip}
begin find3: =true ;
if not (sy in [syl]+5Y52) then
begin error(err); repeat insym until 5y in [5yl]+5Y52 end;
if 5Y=5yl then· insym else find3: =false
end;

1299
1300
1301
1302
1303

function endofloop(sys1,sys2:sos; sy3:symbol; err:integer):boolean;
begin endofloop:=fa1se;
if find2(5Y52+[5y3],sysl,err) then nextif(sy3,err+1l
else endofloop: =true;
end;

1305
1306
1307
1308
1309

function lastsemicolon( sys 1, 5Y82:808; err :integer) :boolean;
begin last semicolon: =true;
if Dot endofloop(sys1,sys2,semicolon,err) then
if find2(sys2,sys1,err+2) then last3emicolon:=fa15e
end;

1311

{===================================================================}

1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342

function searchid(fidcls: setofids):ip;
{search for current identifier symbol in the name table}
label 1;
var lip:ip; io :idclass;
begin 1astnp: =top;
while 1astnp<>nil do
begin lip:=lastnp' .fname;
while 1ip<>nil do
if lip' .name=id then
if· lip' .klass in fidcl5 then
begin
if lip' .klass=vars then i f lip' .vpos.lv<>level then
lip' • iflag: =lip' .iflag+ [no reg] ;
goto 1
end
else l1p:=l1p' .rlink
else
if lip' .name< id then lip:=lip' .rlink else lip:=lip' .llink;
1astnp: =lastnp' .nlink;

1344

function 3earehseetion(fip: ip):ip;

end;

errid(+016,id) ;
if types in fidc1s
i f vars in fidcl5
if konst in fidc1s
if proc in fidcls
if rune in fide1s
lip: =undefip[ ie];

then
then
then
then
then

ic:=types else
ic: =vars else
ic: =konst else
ic:=proc else
ie:=fune else ic:=fie1d;

1:

-.:
:>-

'"'"

l-

V

searehid: =lip
end;

13q5
13q6
13q7
13q8
13q9
1350
1351
1352
1353
135q

(to find record fields and forward declared procedure id' s

->procedure pfdeclaration
->procedure selector!
label 1;
begin
wile fip<>nil do
if fipA .name=id tben goto 1 else
if fipA .name< id then fip:=fipA .rlink else fip:=fipA .llink;
1: searchsection: =fip
end;

1356
1357
1358
13591360
1361
1362

function searchlab(flp:lp; val :integer) :lp;
label 1;
begin
vbile flp<>nil do
if flpA .labval=val tben goto 1 else flp:=flpA .nextlp;
1: searchlab: =flp

136q
1365
1366
1367
1368
1369
1370
1371
1372
1373
137q
1375
1376

procedure opconvert( ts :twostruct);
var op:integer;
begin with a do begin
case ts of"
ir: begin op:=op cif; asp:=realptr; fltused:=true end;
ri: begin op:=op-cfi; asp:=intptr; fltused:=true end;
11: begin op:=op-cid; asp:=longptr end;
li: begin op:=op-cdi; asp:=intptr end;
lr: begin op:=op-cdf; asp:=realptr; fltused :=true end;
rl: begin op:=op=cfd; asp:=longptr; fltused:=true end;
end;
genO(op)
end end;

1318
1379
1380
1381
1382
1383
138q
1385
1386
1387
1388

procedure negat';( 11 : integer) ;
var 12:integer;
begin
ifa.asp=intptr then genO(op neg)- else
begin 12: =lino; gen 1( op loc, 0);
if a .asp=longptr tbenbegin opconvert(il); exchange(l1,12); genO(op_dsb) end
else (realptrl
begin opconvert(ir); exchange(l1,12); genO(op_fsb) end
end
end;

1390
1391
1392
1393

function desub(fsp:sp) :sp;
begin
if formof(fsp,[subrange]) tben fsp:=fspA .rangetype; desub:=fsp

1395
1396
1397
1398
1399

function nicescalar( fsp:sp) :boolean;
begin _
if fsp=nil then nicescalar:=true else
nicescalar:=(fspA .form=scalar) and (fsp<>realptr) and (fsp<>longptr)

end;"

end;

end;

1q01
1q02
1q03
1404
1405
1406
1407
lq08
1409
1410

function bounds(fsp:sp; var fmin,fmax:integer):boolean;
(compute bounds if pOSSible, else return false!
begin bounds:=false; fmin:=O; fmax:=O;
if fsp<>nil tben
if fSpA • form=subrange then

1412
1q13
141q
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426

procedure genrck( fsp:sp);
var min,max,sno:integer;
begin
if opt[ 'r']<>off tben i f bounds(fsp,min,maxj then
begin
if fsp ..... form=scalar then sno:=fsp ..... saaino else sno:=fsp'" .subrno;
if sno=O then
begin dlbno:=dlbno+1; sno:=dlbno;
gendlb~dlbno); gen 1(ps_rom ,min) ; gencst(max); genend;
if fsp .form=scalar tben fSpA .scalno: =sno else
rsp'" .subrno: =5no

1428
1429
1430
1q31
1432
1433
1q3q
1q35
1436
1q37

procedure checkbnds( fsp :sp);
var min1,max1,min2.max2:1nteger; bool:boolean;
begin
if bounds( fsp,min l,max1) then
begin bool: =bound s( a .asp ,min2, max2 );
if (bool=false) or (min2max1) then
genrck( fsp);
end;
a.asp:=fsp;
end;

1439
1440

function eqstruct(p,q :sp) :boolean;
begin eqstruct:=(p=q)- or (p=nil) or (q=nil) end;

1442
1443
1q44
1q45
1446
1qq7
lq48
14q9
1450
1451
1q52
1q53
1454
1455

function string( fsp:sp) :boolean;
var lsp:sPi
begin string:=false;
i t formof(fsp,[arrays]) then
if eqstruct(fspA .aeltype ,charptr) tben
if spack in fSpA. sflag then
begin lsp:=fspA .inxtype;
i f lsp=nil then string:=true else
If lspA .form=subrange then
If lspA .rangetype=intptr tben
if lsp' .min=1 then
string: =true
end
end;

begin fmin: =fsp"" .min; fmax: =fsp"" .max; bounds: =true end else
i f fSpA .form=scalar tben

if fSpA. fconst<>nll then
begin fmin:=O; fmax:=fsp"" .feonst ..... value; bounds:=true end
end;

end;

gend(op rck,sno);
end

-

end;

......
n11 then if withfile in fsp' .sflag then asperr(err);
subeq:
checkbnds( fsp);
11:
begin -opconvertCts); checkasp(fsp,err) end:

1~98
1~99

il trl ,Ir ,ir:
opconvert(ts) ;

1500
1501
1502
1503

es:

1505

expandemptyset( fsp);
noteq,ri ,se:
asperr(err) ;
end
end;

1507
1508

procedure force(fsp:sp; err:integer);
begin load; checkasp(fsp,err) end;

1510
1511
1512

function newident(kl:idclass; idt:sp; nxt:ip; err:integer):ip;
begin newident: =n11;
if sy<>ident then error(err) else

150~

end;

152~

stringstruct: =lsp;
end;

1526
1527
1528
1529
1530
1531
1532

function address( var Ie :integer; sz:integer; pack:boolean) :integer;
begin
if lc >= maxint-sz then begin error(+017); lc:=O end;
if (not pack) or (sz>1) then if odd(1c) then lc:=lc+1;
address: =10;
Ie! =!c+sz
end;

153~

function reserve( s :integer): integer;

1535
1536
1537
1538

begin r:=address(b.lc,s,false); genreg(r,s,100); reserve:=r;
i f b.lc>lcmax then lcmax:=b.lc
end;

1540

1550
1551
1553

procedure treewalk(fip:ip);

155~

var lsp:sp; l:integer;
begin
if fip<>nil then
begin treewalk( fip' ,llink); treewalk( fip' .rlink);
if fip'.klass=vars then
begin i f not (used in fip' .iflag) then errid(-(+019),fip' .name);
if not (assigned in fip' .ifl~g) then errid(-(+020) ,fip' .name);
lsp: =fip' .idtype;
if not (noreg in fip' .iflag) then
genreg( rip' • vpos .ad ,sizeof( lsp) ,ord (formof( lsp, [pointer 1»);
if lsp<>nil then i f wi thfile in lsp' .sflag then
i f lsp' .form=files then
i f level=1 then
begin
for i: =2 to argc do with argyl i] do

15~3
15~4

1545
15~6

15~7

1548
15~9

1555
1556
1557
1558
1559
1560
1561
1562
1563
156~

1565
1566
1567
1568

z:

m

:E:

tn

var r :lnteger;

f'unction arraysizeCfsp:sp; pack:boolean):integer;
var sZ,min,max,tot,n:integer;
begin sz:=sizeof(fsp' .aeltype);
if not pack then sz:=even(sz);
if bounds(fsp' .inxtype,min,max) then; {we checked before}
dlbno:=dlbno+1; fsp' .arpos.lv:=O; fsp' .arpos.ad:=dlbno;
gendlb(dlbno); gen1(ps rom,min); gencst(max-min);
gencstCsz); genend;
n: =max-mln+ 1; tot: =sz*n;
if sz<>O then i f tot div sz <> n then begin error(+018); tot:=O end;
arraysize :=tot
end:

15~1
15~2

1487
1488

begin newident:=newip(kl,id,idt,nxt); insym end

151~

....
<0

....

00

,.

~

'"rn

....
.....,

1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
158~

i f name=fip' .name then ad:=fip' .vpos.ad
end
else
begin
if not (refer in fip' .iflag) then
begin genl (op_mrk,O);
gen1(op lal,fip".vpos.ad); gen13p(CLS)
end
end
else
i f leveH>1 then errid(-(+021) ,fip' .name)

end

end
end;

1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
160q
1605
1606
1607
1608
1609
1610

procedure constanh(fsys:sos; var fsp:sp; var fval:integer);
var signed,min:boolean; lip:ip;
begin signed :=(sy=plussy) or (sy=m1nsy);
i f signed then begin min:=sy=minsy; insym end else min:=false;
if find1([ident •• l\IUcstJ,fsys.+022) then
begin fval :=val;
case sy of
stringcst: f5P: =stringstruct;
charest: fap: :charptr;
intcst: fsp: =lntptr;
realest: fsp:=realptr;
longest: fsp:=longptr;
nUest: fsp:=nilptr;
ident:
begin lip: =searchid ( [konst J );
fsp:=lip·.idtype; fval:=lip".value;
end
end; {case)
if signed then
if (fsp<> 1ntptr) and (fsp<>realptr) and (fsp<> longptr) then
error(+023)
else i f min then fval:= -fval;
{note: negating the v-number for reals and longs)
insym;
end
else begin fsp:=n11; fval:=O end;
end;

1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
162q

function cstinteger(fsys:sos; fSp:sp; err:integer):integer;
var lsp:sp; lval ,min ,max : integer ;
begin constant(fsys,lsp,lval);
if fs p<> lsp then
i f eqstruct(desub(fsp) ,lsp) then
begin
i f bounds( fsp,min ,max) then
i f (lvalmax) then error(+024)
end
else
begin error(err); Ival:=O end;
cstinteger: =lval
end;

1626

{= ==== ===== === == ===== == === ==== ===== ==== == ==== ===== === == ===== ===== ===)

1628
1629
1630
1631
1632
1633
1634

fun"t10n typid"Cerr:integer):sp;
var lip:1p; lsp:sp;
beg1n Isp:=n11;
if sy<>ident then error(err) else
begin lip:=searchid([typesJ); Isp:=lip' .idtype; insym end;
typid :=lsp
end;

1636
1637
1638
1639
1640
1641
1642
16q3
164q
16q5
1646
1647
1648
16q9
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
167q
1675
1676

function simpletyp( fsys :sos) :5P;"
var lsp,lsp1:sp; lip,hip:ip; min,max:integer; Inp:np;
newsubrange:boolean;
begin 15p:=n11;
if find1 ([ident •• lparentJ,fsys,+D25) then
if sy=lparent then
begin insym; Inp:=top;
{declo consts local to innermost block)
while top' .occur<>blck do top:=top' .nlink;
,lsp:=newsp(scalar,wordsize); hip:=nil; max:=O;
repeat lip:=newident(konst ,lsp,hip,+026);
i f lip<>n11 then
begin enterid(lip);
hip:=lip; lip..... value:=max; max:=max+1
end;
until endofloop( fsys+[rparentJ, [identJ ,comma,+027); {+028)
i f max<=t8 then lsp' .size:=bytesize;
lsp' .fconst :=hip; top:=lnp; nextif(rparent,+029);
end
else
begin newsubrange: =true;
if sy=ident then
begin lip:=searchid([types,konst)); insym;
if lip' .klass=types then
begin Isp:=11p' .idtype; newsubrange:=false end
else
begin lsp1:=lip·.1dtype; min:=lip·.value end
end
else constant(fsys+[colon2, ident •• plussyJ ,lsp1,min);
i f newsubrange then
begin lsp: =newsp(subrange,wordsize); lsp'" .subrno:=O:
i f not nicescalar(lsp1) then
begin error(+030); Isp1:=nil; min:=O end;
lsp' .rangetype :=lsp1;
nextif(colon2, +031); max :=cstihteger( fsys,lsp1,+032);
if min>max then beg1n error(+033); max:=min end;
if (min>=O) and (max

,."

."
-I
,."

:3

co
...,
""

....
oc
....
ident then error(+045) else
begin lid: =ld; insym;
if sy=colonl then
begin tip:=newip(field,lid,nil,nil); enterid(tip); insym;
i f sy<>ident then error(+0'l6) else

1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792

begin { fld list)
iffind2 ([ identl,fsys+[casesyJ, ..060) then
repeat 1 ip : =nil; hi p : =nil;
repeat fip:=newident(field ,nil ,nil ,..061 );
i f fip<>nil then
begin enterid (fip);
i f l1p=nil then hip:=fip else l1pA .next:=fip; l1p:=fip;
end;
until endofloop( fsys+ [colon I, ident •• packedsy ,semicolon,casesyJ,
[identJ,comma,..o62); (+063)
nextif( colon I, ..064);

1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716

begin sepsy:=comma; oksys:=[ident •• lparentJ;
lspl: =simpletyp( fsys+ [comma,rbrack,ofsy ,ident •• packedsyJ);
ok:=bounds( lspl,min,max)
end;
if not ok then begin error( +0'10); lsp 1: =nil end;
lsp~ .inxtype:=lspl
until endofloop( fsys+[rbrack,ofsy, ident •• packedsyJ, okays,
sepsy,..o41); {+042)
nextif(rbrack,..o1l3); next1f(ofsy,..o'l'l);
lsp:=element(fsys) ;
i f lsp<>nil then sflag:=sflag + lspA .sflag * [withfileJ;
repeat {rever se 1 inks and compute s1 ze)
lap1:=hspA .aeltype; hSpA .aeltype:=lsp; hSpA .sflag:=sflag;
if artyp=arrays then hSpA .size:=arraysize(hsp,spack in sflag);
lsp:=hsp; hsp:=lspl
until hsp=nil; {lsp points to array with highest dimension)
arraytyp: =lap
encI;

1718
1719
1720

function type fays :sos): sp;
var lsp"lsp1!sp; oc,sz,mln,max:lnteger;
sflag:sflagset; Inp:np;

1722
1723
1724
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736

function element(fsys:sos):sp
):sp;
var lsp,lsp1,hsp:sp; min ,max. :integer; ok:boolean; sepsy:symbol; lip:ip;
oksys :808;

begin insym; nextif(lbrack,..o34); hsp:=n11;
repeat lsp:=newsp(artyp,O); initpos(lsp~ .arpos);
lsp~ .aeltype:=hsp; hsp:=lsp;
{link reversed}
if artyp=carray then
begin sepsy:=semicolon; oksys:=[identJ;
lip: =newident( carrbnd ,lsp ,n11,..o35);
if" lip<>nil then enterid (lip);
nextif( colon2, ..036);
lip: =newident( carrbnd ,lsp ,lip, ..037);
if"lip<>n11 then enterid(l1p);
next1f(colonl, ..038); lspl: =typid{+039);
ok: =nicescalar( desub( lspl»;
encI

else

begin lid:=id; insym end;
end;
if sy=ofsy then {otherwise you may destroy id)
begin id:=lid; l1p:=searchid([typesJ) end;
end;

if lip=nil then tfsp:=nil else tfsp:=lipA .idtype;
if bounds( tfsp,lnt ,nvar) then nvar: =nvar-int+ 1 else
begin nvar: =0:
i f tfsp<>nil then begin error(+047); tfsp:=nil end
end;
tspA .tfldsp: =tfsp;
i f tip<>nll then {explicit tag)
begin tipA .1dtype :=tfsp;
tip~ .foffset:=address(oc,sizeof(tfsp) ,spack in sflag)
end;
nextif(ofsy,..o48); minoc:=oc; maxoc:=minoc; headsp:=nil;
repeat hsp:=nil; {for each caselabel list)
repeat nvar:=nvar-1;
int: =cstinteger( fsys+[ident .. plussy ,comma ,colon 1, lparent,
semicolon .casesy ,rparent] tfsp, +049);
lsp:=headsp; {each label may occur only once)
while lsp<>nll do
begin if' lspA .varval=int then error(+050);
lsp:=lspA .nxtvar

...,

:J>

en

C'"">

:J>

rz:

FT1

:a::

en

""

N
N

0<>

""

N
\.N

t

end;

vsp:=newsp( variant,O); vsp'" .varval :=int;
vsp'" .nxtvar:=headsp; headsp:=vsp; {ohain of oase labels}
VSpA .subtsp:=hsp; hsp:=vsp;
{use this field to link labels with same variant)
untl.l endofloop( fsys+[oolon 1, lparent,semioolon ,casesy ,rparentJ,
[ident •• plussyJ,comma,..o51~; {+052)
nextif(colonl,..o53); nextif( lparent,+054);
tsp 1: =fldlist (fsys+[rparent ,semicolon ,ident •• plussyJ);
it oc>maxoo then maxoc: =00;
while v sp<> nil do
begin VSpA .size:=oc; hsp:=VSpA .subtsp;
VSpA .subtsp:=tspl; vsp:=hsp
encI;
nextif(rparent ,..055);
oc:=minoc;
until lastsemicolon(fsys,[ident •• plussyJ,..o56); (+057 ..058)
if nvar>O then error(-(+059»;
tsp .... fstvar:=headsp; tsp .... size:=minoc; oc:=maxoc; varpart:=tsp;

V>

...,

FT1

-I
FT1
:3
t:C

......

FT1
::0

<.0

00
.....

...,
,.
en

'"
.....
<.0

1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803

ISp:=typ( fsys+ [oase sy ,semicolonl);
it lsp<>nil then if withfile in lsp·.sflag then
sflag: =sflag+[withfilel;
vbile hip<>nil do
begin hip' .idtype :=lsp;
hip' .foffset:=address(oc ,sizeof(lsp) ,spack in sflag);
hip: =hip· .next
end;
until lastsemicolon(fsys+[casesyl,Udentl,+065); 1+066 +0671
if sy=casesy then fldl1st: =v~part( fsys) else fldlist: =nil;
end;

1806
1807
1808
1809
1810
1811
1812
1813
181'1
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835

hegin (typl
sflag:=[J; lsp:=nil;
if sy=packedsy then begin sflag:=[spackl; insym end;
i t find1([ident •• filesyl,fsys,+068) then
if sy in [ident •• arrowl then
begin i t spack in sflag then error(+069);
if sy=arrow then
begin lsp:=newsp(pointer,ptrslze); insym;
if not intypedec then lsp· .el type: =typid (+070) else
i t sy<>ident then error(+071) else
begin fWptr : =newip(types,id ,lsp,fwptr); insym end
end
else lsp: =simpletyp( fsys) ;
end
else
case sy of
( <<<<<<<<<<<<1
arraysy:
lsp: =arraytyp( fsys ,arrays ,Sflag ,typ);
recordsy:
begin in sym;
new(lnp,rec); lnpA .occur: =rec; lnp"" .nlink: =top;
lnp·.fname:=nil; top:=lnp;
00:=0; lspl:=fldlist(fsys+[endsyl); Ifldl1st updates oc)
lsp:=newsp(records,oc); lsp' .tagsp:=lspl;
lsp· .fstfld: =top· .fname; lsp' .sflag: =sflag;
top:=top' .nlink; nextif(endsy,+072)
end;
setsy:
begin insym; nextif(ofsY,+073); lspl: =simpletyp(fsys);
i t bounds(lspl ,min ,max) then lspl:=desub(lspl) else
if lspl=intptr then
begin error(-(+074»; max:=iopt-l end
else
begin error(+075); lspl:=nll end;
it lapl=intptr then '!z:=iopt-l else
begin it bounds(lapl,min,max) then Inothing}: az:=max end:
if (minsz) or (az div bytebita >= maxsetsize) then
begin error(+076); lapl:=nil: az:=O end:
lap:=newsp(power,az div bytebita +1); lsp·.elset:=lspl;
end;
filesy:
begin inaym: nextif(ofaY,+077l; lspl:=typ(faya);

18~6

1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848

if Ispl<>nll then i t wlthfile ,in lspl·.sflag then error(-(+078»;
sz:=sizeof(lspl): if sz>>>>>>> }
end: (case)
typ:=lsp:

1849
1850
1851
1852
1853
1854
1855
1856

end;

1858
1859
1860
1861
1862
1863
1864

function vpartyp( fsys :sos): sp:
begin
if find2([arraysyl,fsys+[identl,+079) then
vpartyp:=arraytyp( fsys ,carray ,[ l, vpartyp)
else
vpartyp: =typid (+080)
end;

-0

»

en
n

»
.:z
f"Tl
xc

en

1866

(= ========== ===== ===== ====== ==== ===== ============= == ==== ===== == == === )

1868
1869
1870

procedure block( fsys :803; fip :ip); forward;
Ipfdeclaration calls block. With a more obscure lexical
structure this forward declaration can be avoided}

1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888

procedure labeldeclaration(fsys :sos);
var IIp:lp:
begin with b do begin
repeat
if sy<>intcst then error(+081) else
begin
if searchlab(lchain,val)<>nil then errint(+082,val) else
begin new( IIp); IIp· .labval :=val:
if va1>9999 then teststandard:
ilbno: =ilbno+ 1: IIp· .labname: =ilbno: IIp· .labdlb: =0:
IIp' .seen: =false; Up' .nextlp: =lchain; lchain: =llp:
end;
insym

1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900

procedure constdefinition(fsys:sos):
var lip:ip;
begin
repeat lip: =newident(konst ,nl1 ,n11 ,+086 ):
if lip<>n11 then
begin nextif( eqsy, +087):
constant( fsys+[semicolon,identl,lip' .idtype ,lip' .value);
nextif( semicolon ,+088 ): enterid( lip):

1902
1903
1904

procedure typedefinition( fsys :sos);
var lip:ip;
begin fWptr: =nil; intypedec: =true:

en

I'T1
-0
-I
I'T1

3:

'"

I'T1
::0

end

until endofloop( fsys+[semicolonl,[ intcstl,cGmma,+083);
nextif( semicolon ,+085)
end end;

end;

until not find2([identl,fsys,+089);
end;

1+084}

,.

-0
G>

'"
N

o

1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918

end;

1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939

procedure var.declaration( f3ys :S08);
var lip,hip,vip:ip; lsp:sp;
begin with b do begin
repeat hip:=nil; lip:=nil;
repeat vip: =newident(vars ,nil ,nil ,+094 );
i f vip<>nil then
begin enterid(vip); vip· .iflag:=[];
i f lip=nil then hip:=vip else lip· .next:=yip; lip:=vip;
end;
until endofloop( fsys+[colon1, ident •• packedsyl, [identl,comma,+095);
{+096)
nextif( colon1, +(97);
lsp:=typ( fsys+[semicolon,identl);
while hip<>nil do
begin hip· .idtype :=lsp;
hip· • vpos .ad: =address( lc ,sizeof( lsp) ,false); hip: =hip· .next
end;
next1f( semicolon ,+098);
until not find2 ([ identl, fsys, +(99);
end end;

1941
1942
1943
1944

procedure pfhe ad ( fs ys : so s ;
var fip:ip;
var again :boolean;
param:boolean); forward;

1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960

function parlist(fsys:sos; var hlc:integer):ip;
var lastip,hip,lip,pip:ip; lsp,tsp:sp; iflag:iflagset; again:boolean;
sz:integer;
begin parl1st:=nil; lastip:=nil;
repeat {once for each formal-parameter-section)
if find1 ([ ident, varsy ,procsy ,funcsyl,fsys+[semicolonl, +01 00) then
begin
if (sy=procsy) or (sy=funcsy) then
begin
pfhead (fsys+ [semicolon, ident, varsy .procsy, funcsyJ,
hip,again, true);
hip· .pfpos.ad: =address(hlc ,pnumsize+ptrsi ze ,false);
hip· .pfkind:=formal; lip:=hip;
top:=top· .nlink; level :=level-1
end

repeat lip: =newident( types,nil,nil,+(90);
if lip<>nil then
begin next1f( eqsy, +(91);
lip· .idtype :=typ( fsys+[semicolon,identl);
nextif(semicolon,+092); enterid( lip);
end:
until not find2([identl,fsys,+093);
while fwptr<>nil do
begin assert sy<>ident;
id: =fwptr· .name; lip: =searchid ([ typesl);
fwptr· • idtype· .eltype: =lip· .idtype; fwptr: =fwptr· .next
end;
lntypedec: :false:

1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996

else
begin hip:=nil; lip:=nil; iflag:=[assigned,noregl;
if sy=varsy then
begin iflag:=[refer,assigned,used,noregl; insym end;
repeat pip:=newident( vars,nil,nil,+(101);
if pip<>nil then
begin enterid(pip); pip· .iflag:=iflag;
if lip=nil then hip:=pip else lip· .next:=pip;
lip:=pip;
end;
iflag: =iflag+[samesectl;
until endofloop( fsys+[semicolon,colon 1l,
[identl,comma,+(102); (+0103)
nextif(colon1, +01 04);
if refer in iflag then
begin lsp:=vpartyp(fsys+[semicolonl);
sz:=ptrsize; tsp:=lsp;
while formof(tsp,[carrayl) do
begin tsp· .arpos.ad :=address(hlc ,ptrsize ,false);
tsp:=tsp· .aeltype
end;
end
else
begin Isp:=typid(+0105); sz:=sizeof(lsp) end;
pip:=hip;
while pip<>nil do
begin pip· .vpos.ad: =address(hlc,sz,false);
pip· .idtype:=lsp; pip:=pip· .next
end;
end;
if lastip=nil then parlist:=hip else lastip· .next:=hip;
lastip:=lip;
end;
until endofloop(fsys, [ident,varsy ,procsy ,funcsyl,
semicolon ,+01 06); {+01071
end;

1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016

procedure pfhead; (forward declared)
var l1p:ip; ISp:sp; lnp:np; kl :idclass;
begin lip:=nil; again:=false;
if sy=procsy then kl: =proc else
begin kl:=func; fsys:=fsys+[colon1,identl end;
insym;
if sy<>ident then begin error(+0108); id:=spaces end;
i f not param then lip:=searchsection(top· .fname);
i f lip<>nil then
if (lip· .klass<>kl) or (lip· .pfkind<>forwrd) then
errid (+0109, id)
else
begin b.forwcount::b.forwcount-1; again:=true end;
if again then insym else
begin lip:=newip(kl,id,nil,nil);
if sy=ident then begin enterid(lip); insym end;
lastpfno: =lastpfno+1; lip· .pfno: =lastpfno;
end;
level: =level+ 1;

....
oc
....
<.S:>

-0

»

'"m

....
N

2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
20311
2035
2036
2037
2038
2039
2040
20111
2042
2043
2044

20115
20116
2047
2048
2049
2050

2051
2052
2053

2054

2055
2056
2057
2058

2059
2060
2061
2062
2063
2064

2065
2066
2061
2068

2069
2070
2071
2012

nev(lnp,blck); InpA .oecur:=blck: lnp~ .nlink:=top: top:=lnp:
if again tIleD lnp~ .fname:=lip~ .parhead. else
beain lnp~ .fname:=nil:
if.find3(lparent,fsys,..o110) then
betlin lip~ .parhead: =parlist( fsys+[rparentl, lip~ .headle):
nextif(rparent,..o111 )

end:
end;
if (kl=func) an4 not agaln then
beain nextif(colonl,..o112); lsp:=typid(+0113):
i f formof(lsp,[power •• tagl) then
beain error(+0114): lsp:=nil end:
l1p~ .ldtype :=lsp:
end:
fip:=l1P:
aDd:

procedure pfd~laratlon( fsys :sos):
var lip:lp: agaln:boolean: markp:~integer: Ibp:bP:
beain with b do beain
pfbead( fsys+[ident ,semlcolon,labelsy •• beginsyl, lip,again ,false):
next1f(semieolon,..o115);
i f findl ([1dent,labelsy •• beginsyl, fsys+[semlcolonl, +0116) then
if sy=ident then
if ld= 'forward ' then
begin insym:
i f lip~ .pfpos.lv>1 then genpnam(ps_fwp,lip):
1f again tIleD errid(+OI17 ,lip~ .name) else
bea1n lip~ .pfkind:=forwrd: forwcount:=forvcount+l end:
aDd else
i f id= 'extern 'tIleD
betl1n lipA .pfklnd: =extrn:
lipA .pfpos.lv:=I: lnsym: teststandard
end
else errid(+OI18,ld)
else
begin 11pA. pfklnd:=actual:
lifndef STANDARD
mrk(markP);
fendlf
i f not agaln then 1f lipA .pfpos.lv>1 then genpnam(ps_fwp,l1p):
nev(lbp): IbpA:=b: nextbp:=lbP:
lc:=address(l1pA .headle,O,false): {align headle)
llbno:=O: forwcount:=O: lchaln:=nil:
if l1pA .ldtype<>nil then
l1pA .pfpos.ad:=address(lc,sizeof(lipA .ldtype) ,false):
block(fsys+[semicolonl,lip):
b:=nextbpA:
'Under STANDARD
release (markP) :
'endU

8DG:

1f not main tIleD eofexpected: =forwcount=O;
nextlt(semicolon,..o119):
level:=level-l; top:=topA .nlink:

......

;

2074

1= === === === ==== == ==== == ==== === ======= ======= === == ======== == ==== == ==}

2076
2077

procedure expression{fsys :508); forward;
Ithis forward declaration cannot be avoided)

2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094

procedure selectarrayelement( fsys :sos):
var isp,lsp:sp;
begin
repeat loadaddr; isp:=ni1:
if formof(a.asp,[arrays,carray)) then isp:=a.aspA .inxtype else
asperr(+0120):
lsp: =a .asp;
expression( fsys+[commal); force(desub( isp) ,..(121):
Ino range check}
if lsp<>n11 then
begln a.packbit:=spack in lsp~ .sflag:
descraddr( IspA .arpos): lsp: =lspA .ael type
end:
a.asp:=lsp; a.ak:=indexed;
until endofloop( fsys ,[notsy •• lparentl,comma,..(122): (+0123)
end;

2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
21111
2115
2116
2117
2118
2119
2120
2121
2122
2123
21211
2125
2126
2127
2128

procedure selector( fsys: sos: fip:ip: iflag:iflagset):
Iselector computes the address of any kind of ,v,ariable.
Four possibilities:
1. for direct accessable variables t I a' qontains offset and level,
2.for indirect accesaable variables, the address is on the stack.
3.for array elements, the top of stack gives the index (one word).
The address of the array is beneath it.
lI.for variables with address in direct accesslble pointer variable,
the offset and level of the polnter is stored in 'a'.
If a.asp=nil then an error occurred else a.asp gives
the type of the variable.
var lip:ip; 11,12:integer;
bea1n 11:=~ino: lnita(fipA.ldtype,O);
case fipA .klass of
vars: with a do
begin poa:=fip~ .vpcs: if refer in fipA .inag then ak:=pfixed end:
field:
begin a:=lastnp~ .va;
fieldaddr(fipA .foffset); a.asp:=fipA .idtype
end:
func: with a do
if fipA .pfkind=standard then asperr(+0124) else
begin poS:=fipA .pfpos: pos.lv:=pos.lv+l:
1f pos.lv>=level then if fip<>currproc then error(+0125);
if fipA .pfkind<>actual then error(+0126):
if sy=arrow then error(+0127);
end
end; (case)
1Ih1le find2([1brack,period,arrowl,fsys,+0128) do with a do
if sy=lbrack tIleD
begin insym;
selectarrayelement(fsys+ [rbrack,lbrack,period ,arrowl);

:»
""
en
n

,:»
,..,
~

:E

en

""

N
N

...

""
N
\N

......
<.D
00
......

""
...>
m

N
N

2129
2130
2131
2132
2133
213q
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2U7
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162

end;

2164
2165
2166
2167
2168
2169
2110
2111
2112

procedure variable( fsys :sos);
var 11p: ip;
beain
i t sy=ldent then
beain lip: =searchid( [vars ,field); insym;
selector( fsys ,lip, [used ,assigned ,noreg)
end
.
else begIn error(+0135); Inlta(n11,O) end;
end;

nextif(rbrack,..o129); Iflag:=lflag+[noreg);
end else
i t sy=period then

beain Insym; Iflag:=lflag+[noreg);
if sy<>ldent then error(+0130) else
beain
i t not formof(asp,[records) then asperr(+0131l else
beain lip:=searchsecti~m( asp" .fstfld);
it 11p=nil then begIn errld(+0132,ld); asp:=nil end else
heain packblt:=spaek in asp" .snag;
fieldaddr( lip" .foffset); asp: =lip" .1dtype
end
end;
Insym
end
end
elae
beain lnsym; iflag:=[used);
i t asp<>n11 then
If asp=strlngptr thenasperrC+0133) else
If asp" .form=polnter then
beain
if ak=fixed then ak:=pfixed else
bealn load; ak:=ploaded end;
asp:=asp" .eltype
end else
i t asp" .form=files then
bealn 12:=11no; gen1(op_mrk,O); exchange(ll,12); loadaddr;
gensp(WW); asp:=asp".filtype; ak:=ploaded; packblt:=true:
end
else asperrC+Ol~);
end;
fip" • iflag: =rip" • iflag+lfl"t!;

2174

{===================================================================}

2116
2171
2118
2119
2180
2181
2182
2183
2184

funotion pl1stequal(pl,p2:ip) :boolean;
Yar ok:boolean; q1,q2:sp;
beain pl1stequal: =eqstruct(pl " .ldtype,p2" .ldtype);
pl:=pl".parhead; p2:=p2".parhead;
while (pl<>n11) and (p2<>nil) do
begin ok:=false;
if pl" .klass=p2" .klass then
if pl".klass<>vars then ok:=p11stequal(pl,p2) else
bealn ql:=pl".ldtype; q2:=p2".idtype; ok:=true;

2185
2186
2181
2188
2189
2190
2191
2192
2193
2194
2195
2196
2191

while ok and formof(ql, [carray]) and formof(q2, [carray]) do
beain ok:=eqstruct(ql" • Inxtype,q2" .lnxtype);
ql:~ql" .aeltype; q2:=q2".aeltype;
end;
If not (eqstruct(ql,q2) and
(pl" .1flagf[refer ,samesect)=p2". iflagf[refer ,samesect))
then ok:=false;
end;
if not ok then pl1stequal: =fal se;
pl:=pl" .next; p2:=p2" .next
end;
i t (pl<)nil) or (p2<)n11) then pl1stequal :=false
end;

2199
2200
2201
2202
2203
2204
2205
2206
2201
2208
2209
2210
2211
2212
2213
2214
2215
2216
2211
2218
2219
2220
2221
2222
2223
2224
2225
2226
2221
2228
2229
2230
2231
2232
2233
2234
2235
2236
2231
2238
2239
2240

procedure callnonstandard(fsys:sos; moreargs:boolean; fip:lp);
var nxt,l1p:ip; lpos:position; 11,12:1nteger;
lsp,oldasp:sp;
begin with a,lpos do begin
nxt:=flp" .parhead; lpos:=fip" .pfpos;
If tip" .pfkind<>formal then gen 1 (op_mrk,level-lv) else
begin lexical (op_lol,lv ,ad ,ptrsize); genO (op_mrs) end;
while (nxt<)n11) and moreargs do
begin lsp:=nxt" .1dtype;
if nxt" .klass=vars then
if refer In nxt" .1flag then {call by reference}
bealn·ll:=l1no; varlable(fsys); .loadaddr;
if samesect in nxt" .1flag then lsp: =oldasp else
bealn oldasp:=asp; 12: =11no;
while formof(lsp,[carray]) and
formof(asp,[arrays,carray) do
If (compat(lsp" .inxtype ,asp" .lnxtype) ) subeq) or
(lsp" .sflag<)asp" .sflag) then asperr(+0136) else
begln descraddr(asp" .arpos);
asp: =asp" • aeltype; lsp: =lsp" .ael type
end;
exehange(ll,l2) ;

.....

nl1 then error(+OH6);
if fipA .pfkind<>formal then genpnam(op_eal,fip) else
begin lexical(op' loi,lv,ad+ptrsize,pnumsize); genO(op_cas) end;
asp:=fipA .idtype; end end;

2252
2253
2254

procedure fileaddr;

2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266

procedure eallr(11,12:integer);
var la:attr;
begin with a do begin
la:=a; asp:=desub(asp); gen1(op mrk,O); fileaddr;
if asp=intptr then gensp(RDI) else
if asp=ebarptr then gensp(RDC) else
if asp=realptr then gensp(RDR) else
if asp=longptr then gensp(RDL) else asperr(+0147);
if asp<>la.asp then eheekbnds(la.asp);
a:=1a; exchange(11,12): store;
end end:

2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292

procedure callw-Cfsys:sos; 11,12:integer);
var m:libmnem;
begin with a do begin genl(op mrk,O);
fileaddr; exehange(ll,12); loadeheap; asp:=desub(asp);
if string(asp) then
begin gen1(op 10c,aspA .size); m:=WRS end
else
begin m: =WRI ;
i f asp<> intptr then
if asp=charptr then m: =WRC else
if asp=realptr tlien m:=WRR else
i f asp=boolptr then m:=WRB else
if asp=stringptr then m:=WRZ elS!!
if asp=longptr then m:=WRL else asperr(+0148);
end;
if find3(eolonl,fsys,+0149) then
begin expression(fsys+[eolonl]);
force(intptr,+0150); m:=suee(m)
end;
if find3(eolon1,fsys,+0151) then
begin expression(fsys); foree(intptr,+0152);
if m<>WSR then error( +0 153) else m: =WRF ;
end;
gensp(m);
end end;

2294
2295
2296

procedure callrw( fsys :505; Ipar ,w ,In :boolean);
var 11,12,oldlc,errno:integer; ftype,lsp:sp;
begin with b do begin oldIe: =lc; ftype: =textptr;

var la :attr;
begin 1a:=a; a:=fa; loadaddr; a:=1a end;

2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345

inita(textptr ,argv[ord(w) ].ad); a .pos .lv :=0; fa :=a;
if lpar then
begin 11: =11no ;
if w then expression(fsys+[eolon1]) else variable(fsys);
12: =11no;
i f formof( a.asp, [files]) then
begin ftype :=a.asp;
if (a.ak<>fixed) and (a.ak<>pfixed) then
begin loadaddr; inita(nilptr,reserve(ptrsize»;
store; a .ak: =pfixed
end;
fa:=a; {store doesnft change a}
if (sy<>comma) and not In then error<+0154);
end
else
begin i f iop[wl=nil then error(+0155);
if w then callw(fsys ,11,12) else callr( 11,12)
end;
while find3(comma,fsys,+0156) do with a do
begin 11: =11no ;
if w then expression(fsys+[colon1]) else variable(fsys);
12: =11no;
if ftype=textptr then
if w then callw(fsys,11 ,12) else callr<11 ,12)
else
begin errno:=+0157;
if w then force(ftype A.flltype,errno) else
begin store; 12: =1ino end;
gen 1 (op mrk,O); fileaddr; gensp(WDW);
ak:=ploaded; packbit:=true;
i f w then store else
begin 1sp:=asp; asp:=ftype ..... fi1type; force(1sp,errno);
exchange( 11,12)
end;
gen1(op mrk,O); fileaddr;
i f w then gensp(PUTX) else gensp(GETX)
end
end;
end
else
if not In then error(+0158) else
if iop[w]=nil then error(+0159);
if In then
begin if ftype<>textptr then error(+0160);
gen1(op mrk,O); fileaddr;
if w then gensp(WLN) else gensp(RLN)
end;
lc: =oldlc
end end;

2347
2348
2349
2350
2351
2352

procedure callflp( fsys :sos; lpar :boolean; m:libmnem);
begin with a do begin
if Ipar then
begin variable(fsys); 10adaddr;
if not formof(asp,[files]) then asperr(+0161) else
if (m<>EFL) and (asp<>textptr) then error(+0162);

.....
~

00

......

."
".
G>

'"
N

-<=

2353
2354
2355
2356
2357
2358

end
else
i f iop[m=PAGl=nll then error(+0163) else
gen 1(op lae ,argv[ord(m=PAG)l. ad);
gensp(m); asp: =boolptr; {not for PAG}
end end;

2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383

procedure callnd(fsys :sos; m:libmnem);
label 1;
var lsp:sp; sZ,int:integer;
begin with a do begin
if not formof(asp,[pointerl) then asperr(+0164) else
if asp=stringptr then asperr(+0165) else
asp: =asp ..... el type;
while find3(comma,fsys,+0166) do
begin
if asp<>nil then {asp of form record or variant}
if aspA.form=records then asp:=asp·.tagsp else
if asp' .form=variant then asp:=asp' .subtsp else asperr(+0167);
if asp=nil then constant(fsys ,lsp,int) else
begin assert asp' .form=tag;
int: =cstinteger(fsys ,asp' .tfldsp,+0168); lsp: =asp' .fstvar;
vb1le lsp<>nil do
if lsp' .varval<>int then lsp:=lsp' .nxtvar else
begin asp: =lsp; goto 1 end;

end end;

2385
2386

procedure callpg(m:libmnem);
begin gensp(m); if not formof(a.asp,[files]) then asperr(+0169) end;

2388
2389
2390
2391
2392
2393
2394

procedure callrr(m:libmnem);
begin
if not formof(a.asp,[files]) then asperr(+0170) else
if a.asp=textptr then gen1(op 10c,O) else
gen 1(op loc ,sizeof( a.asp· .fIltype»;
gensp(m); -

2396
2397
2398
2399

procedure callmr(m:libmnem);
begin teststandard; gensp(m);
if not formof(a.asp,[pointer]) then asperr(+0171)
end;

2401
2402
2403
2404
2405
2406
2407
2408

procedure callpu(m:libmnem; zsp,asp,isp :sp);
begin fsp:=desub<1sp);
if formof(zsp,[arrays,carray]) and formof(asp,[arrays,carrayl) then
if (spack in (zsp' .sflag - asp' .sflag)) and
eqstruct( zsp' .aeltype ,asp' .aeltype) and
eqstruct(desub(zsp' .inxtype) ,isp) and
eqstruct(desub(asp' .inxtype) ,isp) then
begin descraddr(zsp' .arpos); descraddr< asp' .arpos); gensp(m) end

end;

1:

end;

sz: =sizeof( asp); int: =intsize+ptrsize;
if sz>int then int:=(sz+int-1) div int
gen1(op_loc ,int); gensp(m)

*

int;

end;

2409
2410
2411

else error (+0172 )
else error(+0173)
end;

2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464

procedure call( fsys: sos; tip: ip);
var lkey: standpf; Ipar :boolean; lsp,lsp2: sp;
begin with a do begin fs ys : =fs ys+ [comm a 1 ;
lpar:=find3(lparent,fsys,+0174); if lpar then fsys:=fsys+[rparentl;
if tip' .pfkind<>standard then callnonstandard(fsys,lpar,tip) else
begin lkey:=fip' .key;
if lkey in [pput •• phaIt,feof •• fabs,fround •• farctanl then
gen1(op mrk,O);
if lkey
[pput •• prelease ,fabs •• farctanl then
begin if not lpar then error(+0175);
if lkey <= prelease then
begin variable( fsys); loadaddr end
else
begin expression(fsys); force(fip·.idtype,+0176) end;
end;
case lkey of
pread,preadln,pwrite,pwriteln: {Ot 1,2,3 resp}
callrw(fsys ,lpar ,lkey>=pwrite ,odd( ord( lkey»);
pput:
callpg(PUTX);
pget:
callpg (GETX);
ppage:
call fl p( fsys ,lpar ,PAG);
preset:
callrr(OPN) ;
prewrite:
callrr(CRE);
pnew:
callnd(fsys ,NEWX);
pdispose:
callnd (fsys, DIS);
ppack:
begin lsp: =asp; nextif( comma -0177); expression( fays); load;
lsp2:=asp; nextif(oom~l2,-!/ :8); variable(fsys); loadaddr;
callpu(PAC,asp,lsp,'
"
end;
punpack:
begin lsp:=asp; nex,.. ::f:..canma,+0179); variable(fsys); loadaddr;
lsp2:=asp: nextif(coruma,+0180); expression(fsys); load;
callpu(UNP ,1sp,1sp2, asp)
end;
pmark:
callmr(SAV);
prelease:
callmr(RST) ;
phalt:
begin teststandard;
if not Ipar then gen1(op 10c;0) else
begin expression(fsys); force(intptr,+0181l end;
gensp(HLT) ;
end;

z:

m

:E:

en

in

-0

".
G'>

'"

N
\I1

2465
2466
2467
2468
2469
2470
2~71

2472
2~73

2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520

feof:
aallfip(fsys ,1psr ,EFL);
feo1n:
oallflp( fs:,s ,1par ,ELK l;
fabs:
begin asp: =desub( asp);
i f asp=intptr then gensp(ABIl else
if asp=realptr then gensp(ABR) else
if asp=longptr then gensp(ABL) else asperr(+0182);

end;
fsqr:
begin asp:=desub(asp);
if asp:intptr then
begin gen1(op dup,intsize}; genO(op_mul) end else
i f asp=rea1ptr then
begin gen1(op dup,realsize);
genO (op flnu); f1 tUBed: =true
end
else if asp=longptr then
begin gen Hop dup ,1ongsize); genO (op_dmu) end
else asperr( +0 183);

edd;
ford:
begin if not nicescalar(desub(asp)) then asperr(+01811);
asp: =intptr
end;
fchr:
checkbnds( charptr);
fpred ,fsuco:
begin asp:=desub(asp); gen1(op_1oc,ll;
if lkey=fpred then genO(op_sub) else genO(op_add);
if nicesoa1ar( asp) then genrck( asp) else asperr(+0185)
end;
fodd:
begin gen1(op_loc,l); genHop_and,intsize); asp:=boo1ptr end;
ftr-unc:
begin if asp<>rea1ptr then asperr(+0186); opconvert(ri) end;
fround:
begin if asp<>rea1ptr then asperr(+0187);
gensp(RND); asp:=intptr
end;
fsin:
gensp(SIN) ;
fcos:
gensp( COS);
fexp:
gensp(EXPX) ;
fsqrt:
gensp(SQT) ;
fln:
gensp(LOG) :
fare tan :
gensp(ATN);
end;
end;
if 1par then nextif(rparent,+0188);

2521

end end;

2523

{== ===== ===== ======= ===== === ====== ==== == ==== === ==== =========== ==== == }

2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
251111
25115
25116
2547
2548
2549
2550

procedure convert( fsp:sp; 11 :integer);
{Convert tries to make the operands of some operator of the same type.
The operand types are given by fsp and a.asp. The resulting type
is put in a.asp.
11 gives the 1ino of the first instruction of the right operand.

2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562

procedure buildset( fsys :sos);
{This is a bad construct in pascal. Two objections:
- expr .. expr very difficult to implement on most machines
- this construct makes it hard to implement sets of different size

2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576

procedure genwordsetCs:wordset);
{level 2: « buildset}
var b,i,w:integer;
begin
if s= [) then w: =0 else
if s=[wbm1) then w:=-t15m1-1 else
begin w:=-1; b:=t14;
for i: =wbm 1-1 downto 0 do
begin if i in s then w:=w+b; b:=b div 2 end;
if wbm1 in s then w:=w-t15m1 else w:=w+1
end;
gen Hop 10c ,w)
end;
-

var 12:integer;
ts :twostruct;
begin with a do begin asp: =desub( asp);
ts: =compat( fsp,asp);
case ts of
eq,subeq:

,

rl ,Ii ,ri:
opconvert( compat( asp,fsp));
ri->iretc. }
lr,il,ir:
begin 12:=lino; opconvert(ts); exchange(11,12) end;
se:
expandemptyset( fsp);
es:
begin 12: =lino; expandemptyset( asp); exchange( 11,12) end;
noteq:
asperr(+0189);
end;
if asp=rea1ptr then f1 tused: =true
end end;

const
type
var

ncsw
= 16;
{tunabl"e}
wordset = set of O.. wbml;
i,j ,vall, val2,ncst ,11,12, sz:integer;
cst 1, cst2, cst 12, varpart :boolean;
cstpart:array[l .. ncsw] of wordset;
lsp:sp;

......

""
00

I-'

2578
2579
2580
2581
2582
2583
258q
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602

procedure setexpr(fsys:sos; var c:boolean; var v:integer);
{level 2: « bu11dset}
{update lsp and sz variables of build set and set c and v parameters}
var min ,max : integer ; errno :integer;
be&1D with a do bealn c:=false;v:=O;
expresslon(fsys); asp:=desub(asp);
i f asp<>nU tIleD
bealn
i t lsp=nU then
beain errno: =0;
If not bounds(asp,min,max) tben
i t asp=intptr tIleD max:=lopt-l .else errno:=+0190;
i f max> (maxsetsize-l ) *byteb its + (bytebits-l) tben
errno: =+0191;
it errno<>O tben bealn asperr(errno); max:=O end;
sz:=even(max dlv bytebits + 1); lsp:=asp;
eDCI
else {asp<>nil and lsp<>nil}
i t asp<>lsp tbion asperr(+0192);
i t ak.cst tIleD
i t pos.ad=ncsw"wordbits) tIleD error(+0195) else
tor i:=vall to val2 do
bes1D j:=i dlv wordbits + 1; ncst:=ncst+l;
cstpart[jJ:=cstpart[jJ + [I aod wordbit.sJ
end

else
it varpart then gen 1(op ior ,sz) else varpart: =true;
_tU endonoop( fsys ,[notsy-:-.lparentJ,camma,+0196); (+O197l
ak:=loaded;

2633
2634
2635
2636
2637
2638
2639
2640
2641

if (ncst=O) and not vsrpart tIleD
beain asp:=emptyset; gen1(op_loc,O) eDCI
else
begin asp: =newsp( power ,sz); asp~ .elset:=lsp;
i f ncst>O then
for i:=l to sz dlv wordslze do genwordset(cstpart[iJ);
If varpart Bod (ncst>O) then genHop_lor,sz);
eDCI
elld end;

2643
2644
2645
2646
2641
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688

procedure factor( fsys: ~os);
var lip:ip; 11,I:integer; lsp:sp;
bea1D with a do begin
asp:=nU; packbit:=false; ak:=loaded;
i t findl ([notsy .. nllcst,lparentJ,fsys,+0198) then
case sy of
ident:
beain lip:=searchld([konst,vsrs,field,func ,carrbndJ); Insym;
case lip~.klass of
fune: {call moves result to top stack}
bea1D call(fsys,lip); ak:=loaded; packbit:=false end;
konst:
bea1D asp:=lip~ .idtype;
if nicescalar(asp) tben !including asp=nil}
bea1D ak:=cst; pos.ad:=lip~ .value end
else
beg1D ak: =ploaded;
11: =lino; gend(op_lae ,abs(lip~ .value»;
if asp~ .form=scalar tben
bea1D load; i t lip~ .value
en
n

J>
..-

z:

m

:E:

en

......
stringptr then ak:=ploaded;
end,;

nilcst:
begin insym; asp:=nilptr;
for i:=1 to ptrsize diy wordslze do genHop_loc,O);

end;
lparent:
begin insym;
expresslon(fsys+[rparent]); nextif(rparent ,+0199)
end;
notsy:
begin lnsym; factor(fsys); load; genO(op_teq);
if asp<>boolptr thel! asperr(+0200)
end;
lbrack:
begin insym; buildset(fsys+[rbrack]); nextif(rbrack,+0201) end;
end
-end end;
procedure term(fsys:sos);
var lsy:symbol; lsp:sp; lO,11,12:integer; first:boolean;
begin with a,b do begin first:=true; 11:=11no; 10:=11;
factor( fsys+[starsy •• andsy]);
vbile find2([starsy •• andsy],fsys,+0202) do
begin if first then begin load; flrst:=false end;
isy:=sy; insym.; 11: =11no; lsp:=asp;
factor(fsys+[starsy •• andsy]); load; convert(lsp,ll);
i f asp<>nil tben
case lsy of
starsy:
if asp=intptr tben genO(op_mul) else
if asp=realptr then genO (op_fmu) else
if asp=longptr then genO(op_dmu) else
if aspA .form=power then setop(op_and) else asperr(+0203);
slashsy:
if asp=realptr tben genO (op_fdv) else
i f (asp=intptr) or (asp=longptr) then
begin lsp:=asp;
convert(realptr,11); (make real of right operand)
convert(lsp,11); (make real of left operand)
genO (op_fdv)
end
else asperr(+0204);
divsy:
if asp=intptr tben genO (op_diy) else
if asp=longptr tben genO(op,-ddv) else asperr(+0205);
modsy:
begin 12: =11no; gen1(op_mrk,O); exchange(10,12);
if asp=intptr tben gensp(MDI) else
if asp=longptr then gensp(MDL) else asperr(+0206);
end;
andsy:'
if asp=boolptr then setop(op_and) else asperr(+0207);
end {case}
end {while}
end end;

2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779

procedure simpleexpressionCfsys:sos);
var lsy:symbol: lSp:sp; 11:integer; signed,min,first:boolean;
begin with a do begin 11: =11no; first :=true;
signed:=(sy=plussy) or (sy=minsy);
if signed then begin min:=sy=minsy; insym end else min:=false:
term(fsys + [minsy,plussy,orsy]); lsp:=desub(asp);
if signed then
if (lsp<> intptr) and (lsp<>realptr) and (lsp<> longptr) then
asperr(+0208)
else if min then
begin load; first:::false; asp:=lsp; negate(11) end.;
while find2([plussy,minsy,orsy],fsys,+0209) do
begin if first then begin load; first:=false end;
lsy:=sy; insym; 11 :=lino; Isp:=asp;
term(fsys+[minsy,plussy,orsy]); load; convert(lsp,11);
if asp<>nil then
case lsy of
plussy:
if asp=intptr then genO (op_add) else
if asp=realptr then genO (op_fad) else
if asp=longptr then genO(op_dad) else
if aspA .form=power then setop(op_ior) else asperr(+0210);
minsy:
if asp=intptr tben genO(op_sub) else
if asp=realptr tben genO(op_fsb) else,
if asp=longptr tben genO(op_dsb) else
if asp ..... form=power then
begin setop( op com); setop( op and) end
else asperr(+0211);
orsy:
if asp=boolptr then setop(op_ior) else asperr(+0212);
end {case}
end (while)
end end;

2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800

procedure expression; { fsys :sos }
var lsy:symbol; lsp:sp; 11,12,13,sz:integer;
begin with a do begin 11: =11no ;
simpleexpression( fsys+[eqsy •. insy]);
if find2([eqsy •• insy],fsys,+0213) then
begin 18Y:=SY; insym; lsp:=asp; loadcheap; 12:=lino;
8impleexpression( fsys); load cheap ;
if lsy=insy then
begin
if not formof( asp, [power]) then asperr( +0214) elSE
if asp=emptyset then setop(op_and) else
{this effectively replaces the word on top
stack by the result of the I in I operator:
if not (compat(lsp,aspA .elset) <= subeq) then
asperr(+0215)
else
begin exchange(11,12); setop(op_inn) end
end
else
begin convert(lsp ,12);

the
"31;:'!e

."
}

»

'"'"

N
00

2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844

if asp<>nil then
case asp'.form of

scalar:
if asp=realptr then genO (op emf) else
if asp=longptr then genO(op::::emd) else genO(op_cmi);
pointer:
if (lsy=eqsy) or (lsy=nesy) then genO(op_cmp) else
asperr(+0216);
power:
case lsy of
eqsy,nesy: setop(op emu);
ltsy,gtsy: asperr(+0217);
lesy: l'a<=b' equivalent to 'a-b=[]')
begin setop( op com); setop( op and);
gen1(op 10e,O); expandemptyset(asp);
setop( OP emu); lsy: =eqsy
end;
gesy: {'a>=b' equivalent to 'a=b+a')
begin sz:=even(sizeof(asp»; gen1(op dup,2*sz);
gen1(op beg,-sz); setop(op ior); setop(op emu); lsy:=eqsy end
end; {case)
arrays:
i f string( asp) then
begin 13: =lino; gen1(op mrk,O); exehange(ll,13);
gen1(op loe,asp' .size); gensp(BCP)
end
else asperr{+0218);
records: asperr(+0219);
files: asperr(+0220)
end; {case)
case lsy of
ltsy: genO (op tlt);
lesy: genO (op-tle);
gtsy: genO(op-tgt);
gesy: genO(op-tge);
nesy: genO(op-tne);
eqsy: genO(op::::teq)
end
end;
asp:=boolptr; ak:=loaded
end;

end end;

2846

{== ===== ===== ===== === ===== ======= ====== ==== ==== =============== == ==== )

2848
2849

proc"liure statement(fsys :sos); forward;
{this forward declaration can be avoided}

2851
2852
2853
2854
2855
2856

procedure assigrnnent( fSys :sos; fiD :ip);
var la:attr; 11,12:integer;
begin
11: =lino; seleetor( fsys+[becomesl, fip, [assigned l); 12: =lino;
la:=a; nextif(beeomes,+0221);
expression(fsys}; loadcheap; cbeckasp( la.asp,+(222);

2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867

exehange(ll,12); a:=la;
if not formof(la.asp,[arrays .. recordsJ) then store else
begin loadaddr;
if la.asp' .form<>earray then
gen 1(op blm,even(sizeof(la.asp»)
else
begin genl(op mrk,O); descraddr(la.asp' .arpos); gensp(ASZ);
genO (op blsT
end;
end;
end;

2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897

procedure gotostatement;

2899
2900
2901
2902
2903

procedure compoundstatement( fsys :808; err :integer);
begin
repeat statement(fsys+[semieolonJ)
until endofloop( fsys I [beginsy .. casesy] I semicolon ,err)
end;

2905
2906
2907
2908
2909
2910
2911
2912

procedure ifstatement(fsys :808);
var Ib1,lb2:integer;
begin with b do begin
expression( fsys+[ thensy ,elsesyl);
force(boolptr ,+0225); ilbno :=ilbno+l; lbl: =i1bno; gen 1(op_zeq,lbl );
next1f(thensy ,+0226); statement( fsys+[elsesyl);
if find3(elsesy,fsys,+0227) then
begin ilbno:=ilbno+l; lb2:=ilbno; gen1(op_brf,lb2);

{jtunps into structured statements can give strange results. }
label 1;
var 11p:lp; lbp:bp; diff:integer;
begin
if sy<>intcst then error(+0223) else
begin IIp:=searehlab(b.lehain,val);
if 11p<>nil then
if 11p' .seen then ·genl (op brb,11p' .labname)
else gen 1 (op brf ,11p' .labname)
else
begin lbp:=b.nextbp; diff:=l;
while lbp<>nil do
begin 11p:=searehlab( lbp' .lehain, val);
if 11p<>nil then goto 1;
lbp:=lbp' .nextbp; diff:·=diff+l;
end;
1:
if 11p=nil then errint(+0224, val) else
begin
i f 11p' .labdlb=O then
begin dlbno:=dlbno+l; Up' .labdlb:=dlbno;
gend(ps fwa,dlbno); {forward data reference}
end;
gen 1 (op mrk,diffl; gend (op_lae·, 11p' .labdlb); gensp(GTO);
end;
end;
insym;
end
end;

,.-0
'"'"

2913
2914
2915
2916
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968

genilb( lb1}; statement( fsys}; genilb( Ib2}
end
else genilb(lb1};

2969
2970
2971

end;
genend; genilb(lO); gend(op_lae,dlbno); genO(m}; genilb(11)
end end;

end end;

procedure casestatementCfsys :805);
label 1; ,
type aip= ....caseinfo;
casein fo= record
next: cip;
csstart: integer;
cslab: integer
end;
var lsp:sp; head,p,q,r:cip;
10,11,12, i ,n ,m,min imax :lnteger;
begin with b do begin
expression( fsys+[ofsy ,semicolon,ident .. plussy]); lsp:=a.asp; load;
if not nicescalar(desub(lsp» then begin error(+0228); lsp:=nil end;
ilbno:=ilbno+1; 10:=ilbno; gen1(op brf,IO); {jump to CSA/B}
ilbno:=ilbno+1; 11:=ilbno;
nextif(ofsy,+0229); head:=nil; max:=minint; min:=maxint; n:=O.
repeat ilbno:=ilbno+1; 12:=ilbno;
{label of current case}
repeat i :=cstinteger( fsys+[comma,colon1 ,semicolon], lsp,+0230);
if i>max then max:=i; if i(min then min:=i; n:=n+1;
q: =head; r: =n11; new( p);
while q<>nil do
begin {chain all cases in ascend ing order}
if q".cslab>=i then
begin i f q' .cslab=i then error(+0231); goto 1 end;
r:::q; q:=q".next
end;
1:
p' .next:=q; p' .cslab:=i; p' .csstart:=12;
if r=nil then head:=p else r'.next:=p;
until endofloop( fsys+[colonl ,semicolon] t
[tdent •• plussy), comma, +0232); {+0233}
next1f(colon1, +O234}; genilb( 12); statement( fsys+[semicolon);
gen Hop brf ,11);
until lastsemicolon(fsys,[ident •• plussy),+0235); (+0236 +02371
assert n<)O;
dlbno: =dlbno+1; gendlb(dlbno); genpnam(ps rom,currproc); gencst(-1);
if (max div 3) - (min div 3) < n then
begin gencst(min); gencst(max-min);
m:=op csa;

vhile-head<>nil do
begin
while head' .cslab>min do
begin gencst(-1); min:=min+1 end;
genclb(head ..... csstart); min:=min+l; head:=head" .next

end:
end
else
begin genost(n); m:=op esb;
while head<>nll do
begin gencst(head' .cslab);
genclb(head' .csstart); head: =head' .next
end;

2973
2974
2975
2976
2977
2978
2979
2980
2981
2982

procedure repeatstatement(fsys :808);
var Ibl: integer;
begin wi th b do begin
ilbno:=ilbno+1; lb1:=ilbno; genilb(lb1);
compoundstatement(fsys+[untilsy), +0238); {+0239}
nextif(untilsy,+0240); genlin;
expression( fsys); force(boolptr ,+0241);
ilbno:=Hbno+1; genO(op teq); gen1(op zeq,ilbno);
gen1(op brb,lb1); genilb(ilbno)
-

2984
2985
2986
2987
2988
2989
2990
2991
2992

procedure whilestatement(fsys :sos);
var Ibl,lb2: integer;
begin with b do begin
ilbno:=ilbno+2; Ib1:=ilbno-1; genilb(lp1); lb2:=ilbno;
gen! in; expression( fsys+[dosy]);
force(boolptr,+0242); gen1(op zeq,lb2);
nextif( dosy ,+0243); statementCfsys);
gen1(op brb,lb1); genilb(lb2)

2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024

procedure forstatement( fsys :sos};
{the upper bound is evaluated once and stored in a temporary local}
var lip:ip; dsp,lsp:sp; tosym,cst',cst2,local:boolean;
vall, val2, endlab ,looplab ,oldlc,llc ,lad :integer;
begin with a,b do begin
lsp:=nil; lad:=O; tosym:=true; 10cal:=level<>1; oldlc:=lc;
ilbno:=ilbno+l; looplab :=ilbno; ilbno:=ilbno+l; endlab: =-ilbno;
if sy<>ident then error(+0244) else
begin lip:=searchid([vars]); insym;
lsp: =lip' • idtype; lad: =lip' • vpos .ad;
if local and
«ladlevel)} then
error(+0245)
else lip' .iflag :=lip' .iflag+[used ,assigned);
end;
i f not nicescalar(desub(lsp» then begin error(+0246); lsp:=nil end;
nextif(becomes ,+0247); dsp:=desub(lsp); assert sizeof(dsp)=wordsize;
expression( fsys+ (tosy ,downtosy ,notsy .. lparent ,dosy]);
cst1:=ak=cst; if cst1 then va11:=pos.ad; force(dsp,+0248};
if not cst1 then gen1(op dup,intsize};
if find1 ([tosy ,downtosy)-;fsys+[notsy •• lparent ,dosy) ,+0249) then
begin tosym: =sy=tosy; insym end;
expression( fsys+ [dosy);
cst2:=ak=cst; if cst2 then va12:=pos.ad; force(dsp,+0250};
if not cst2 then
begin llc:=reserve(intsize);
gen 1(op dup ,intsize); gen Hop stl,llc);
end;
if cst 1 then
begin
if tosym then gen1(op_bgt,endlab) else gen1(op_blt,endlab};

end end; -

end end; -

......

'"

00

-0

»

'"
m

o'"

3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042

else
begin Ubno:=ilbno+l;
i f tosym then gen1(op ble,Ubno) else gen1(op bge,llbno);
genl(op beg,-intsize); gen1(op brf,endlab); g;nilb(Ubno)
end;
assert eqstruct(a.asp,dsp);
checkbnds(lsp); pop(local,lad ,intsize); genilbClooplab);
nextif(dosy,+0251); statementCfsys);
push( local ,lad ,intsize);
if cst2 then gen1(op 10c,val2) else gen1(op 101,l1c);
genl(op beq,endlab);-push(local,lad,intsize); gen1(op 10c,1);
if tosyiii" then genO(op add) else genO(op sub);
a.asp:=dsp; checkbnds(lsp); pope local ,lad ,intsize);
gen1(op brb,looplab); genilb(endlab);
lc:=oldlc
end end;

3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061

procedure withstatement(fsys :50-8);
var lnp ,oldtop :np; oldIe :integer; pbit :boolean:
begin with b do begin
oldlc:=lc; oldtop:=top;
repeat variable( fsys+[comma,dosyl);
if not formof(a.asp,[recordsl) then asperrC+0252) else
begin pbit:=spack in a.asp' .sflag;
new( Inp,wrec); lnp..... occur :=wrec; lnp'" .fname: =a.asp"".fstfld;
if a.ak<>fixed then
begin loadaddr: inita(nilptr ,reserve(ptrsize)}; store;
a .ak: =pfixed;
end;
a.packbit:=pbit; Inp' .wa:=a; Inp' .nlink:=top; top:=lnp;
end;
until endofloop( fsys+[dosyl, [identl,comma,+0253); (+0254)
nextif(dosy ,+0255); statement ( fsys);
top:=oldtop; lc:=oldlc;
end end;

3063
3064
3065
3066
3067
3068
3069
3070
3071

procedure assertion(fsys :808);
begin test standard ;
if opt[ 'a' l=off then
while not (sy in fsys) do insym
else
begin gen1(op_mrk.O); expression(fsys); force(boolptr.+0256);
gen1(op_loc,e.orig); gensp(ASS);
end
end;

3073
3074
3075
3076
3077
3078
3079
3080

procedure statement; {fsys: sos}
var lip:ip; IIp:lp; lsy:symbol;
begin
assert [labelsy •• casesY,endsyl <= fsys;
assert [ident,intcstl * fsys = [1;
if find2([intcstl,fsys+[ident),+0257l then
begin 11p: =searchlab(b.lchain ,val);
if IIp=nil then errint(+025S, val) else

gen 1( op loc, vall)
end

-

3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120

begin if IIp' .seen then errint(+0259, val) else IIp' .seen :=true;
genilb( llpA .labname)
end;
insym; next1f(eolonl,+0260);
end;

if find2([ident,beginsy •• casesyl,fsys,+0261) then
begin if giveline then if sy<>whilesy then genlin;
if sy=ident then
it id=' assert 'then
begin insym; assertion( fsys) end
else
begin lip: =searchid( [vars ,field ,fune ,proc]); insym.;
if lip' .klass=proc then call( fsys ,lip)
else assignment ( fsys .lip)
end

else
begin 15Y:=8Y; insym.;
case lsy of
beginsy:
begin compoundstatement(fsys,+0~62);
nextif(endsy ,+0264)
end;
gotosy:
gotostatement;
ifsy:
ifstatement(fsys) ;

(+0263)

casesy:

begin easestatement( fsys}; nextif( endsy ,+0265) end;
whilesy:
whilestatement( fsys);
repeatsy:
repeatstatement( fsys);
forsy:
forstatement( fsys);
withsy:
withstatement(fsys) ;
end
end;
end
end;

3122

{= ======== ==== ==== =========== ====== == ==== ======== ==== === ====== == == == )

3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136

procedure body(fsys:sos; fip:ip);
var i,sz,letdlb,namdlb,inidlb:integer; IIp:lp;
begin with b do begin namdlb:=O;
(produce PRO)
genpnam(ps pro .fip}; gencst( fip' .headle):
gencst(ord(fip' .pfpos.lv<=1);
!initialize files)
if level=l then {body for main)
begin dlbno:=dlbno+l; inidlb:=dlbno; gend(ps fwa.inidlb);
gen1(op mrk,O); gend(op lae.dlbno); gen1(op_Iae.O}; gensp(INI);
end;
trace(' procentr' ,flp,namdlb);
dlbno: =dlbno+l; letdlb :=dlbno:

-0

"'"

m

3137
3138
3139
31~0

3141
3142
31~3
31~4

3145
31~6
31~7
31~8

3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173

gend(ps fwe,letdlb); gend(op beg,letdlb);
{the bodY-itself}
lcmax:=lc; currproc:=fip;
eOlllpoundstatement( fsys ,+0266); {+02671
lcmax:=address(lcmax,O,false); {align lemax}
trace( 'procexit' ,fip,namdlb);
{undefined or global labels}
Up: =lehain ;
....ile IIp<>nil do
begin if not llp~ .seen then errint(+0268,Up~ .labval);
if llp~ .1abdlb<>0 then
begin gendlb( Up~ .labdlb); genpnam(ps rom ,fip);
genelb(llp~.labname); genest(lcmax); genend;
{this doesn't work if local generators are around}
end;
Up:=llp~ .nextlp
end;
{define BUG size}
gend(ps let ,letdlb); genest( lcmax-fip~ .headle);
{finish and close files}
treewalk( top~ .fname);
if level=1 then
begin gendlb(tnidlb); gen1(ps eon,arge+ll;
for i: =0 to argc do with argyl 1l do
begin gencst(ad);
if (ad=-1) and (i>1) then errid(+0269,name)

end.

3175
3176

genend; gen1(op_mrk,O); gen1(op_loc,O); gensp(HLT)
end
else
begin
i f fip~ .klass<>func then sz: =0 else
begin
if not (assigned in fip~ .iflag) then
errid(-(+0270) ,fip~ .name);
sz:=even(sizeof( f1p~ .1dtype»; push(local,fip~ .pfpos.ad ,sz);
end;
gen1(op ret,sz); genO(ps_end);
end
end end;

3178

{= ==== == ======== == ===== ===== ===== ==== == ==== ===== == ======== ======= === }

3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192

procedure block; {forward declared}
var ad : integer ;
begin with b do begin
assert [labelsy •• withsyl <= fsys;
assert [ident,tntcst,casesy,endsy,period] * fsys = [];
if find3 (labelsy ,fsys ,+0271) then labeldeclaration( fsys);
i f find3(constsy,fsys,+0272) then constdefinition(fsys);
i f find3(typesy,fsys,+0273) then typedefinition(fsys);
if find3(varsy,fsys,+0274) then vard,eclaration(fsys);
if fip=progp then
begin
i f iop[truel<>nil then
begin ad :=address( lc,fhsize+buffsize ,false);

317~

3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207

end end;

3209

(= ========= == ======== ======== ======= === == === = == == ======== ==== ===== == )

3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242

procedure programme(fsys:sos);
var stdin,stdout:boolean; p:ip;
begin
nextif(progsy ,+0279); nextif( ident ,+0280);
if find3 (lparent ,fsys+[semicolonl ,+0281 ) then
begin
repeat
if sy<> ident then error( +0282) else
begin std1n:=id='input
'; stdout:=id='output
if stdin or stdout then
begin p: =newi p( var s, id ,tex tptr I nil) ;
enterid(p); iop[stdout]:=p;

argv[1l.ad :=ad; iop[truer .vpos.ad :=ad
end;
if iop[falsel<>nll then
begin ad :=address( lc,fhsize+buffsize ,false);
argv[Ol.ad: =ad; iop[falsel~ .vpos.ad: =ad
end;
if address(lc,O,false)<>O then gen1(ps hol,lc);
Ie: =progp'" .headle; level :=1

(align lc)

-

end; {externals are also extern for the main body}
....ile find2([procsy,funcsyl,fsys,+0275) do pfdeclaration(fsys);
if forwcount<>O then error(+0276); (forw proc not specified)
nextif(beginsY,+0277);
body( fsys+[ casesy ,endsyl, fip);
nextif(endsy ,+0278);

end

else
i'C argc(maxargc then

begin argc: =argc+ 1 ;
argyl argcl. name: =id; argyl argc]. ad: =-1
end;
insym
end
until endofloop( fsys+ [rparent ,semicolon],
[1dentl,comma,+0283); (+0284)
if argc>max argc then
begin error(+0285); argc:=maxargc end;
nextif(rparent,+0286) ;
end;
nextif( semicolon ,+0287);
block( fsys ,progp);
i f opt['l']<>off then
begin genl(ps mes,meslino); gencst(eaorig); genend end;
eofexpected :=true; nextif(period ,+0288);
end;

,.

-0

'"

In

\,N

3244
3245
3246
3247
3248

procedure compile;
var lsys :808;
begin lsys :=[progsy ,labelsy •• withsy];
repeat eofex pected : =fal se ;
main: =find2 ([progsy ,labelsy ,beginsy •• wi thsyl,lsys ,+0289);

N

3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259

/* collection of options, selected by including or excluding 'defines' */

i f main then programmeClsys) else with b do

begin
if find3Cconstsy,lsys,+0290) then constdefinitionClsys);
if find3Ctypesy,lsys,+0291) then typedefinition(lsys);
if find3Cvarsy,lsys,+0292) then vardeclarationClsys);
gen1(ps hol,address(lc,O,false)); lc:=O; level:=1;
while fInd2C[procsy,funcsy],lsys,+0293) do pfdeclarationClsys);
end;
errorC+0294);
until false; {the only way out is the halt in nextln on eof }
end;

3261

{= ===== === ===== ===== == === == === === ==== ========= ============= ========= }

3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280

begin {main body of pcompilerJ
rewrite(errors) ;
lnit 1; lnit2; init3; init4;
{all this initializing must be independent of opts}
resetCem1); if not eofCem1) then optionsCfalse);
rewriteCem1); writeCem1,MAGICLOW,MAGICHIGH);
lifdef GETREQUIRED
get (in put) ;
Hendif
if eofC input) then genO Cps eof) else
begin nextch; insym;
handleopts; {initialize all opt dependent stuff}
compile

end;
Hifdef STANDARD
9999: ;
Hendif
end. {pcompiler}

3

1* select only one of the following: *1

4

D

define
define
define

V7
V6
VPLUS

5
6

1* n
1* I

8
9
10

#

11

I"

13
14
15

n

nifdef BOOT
define
Hendif

INT ONLY

18
19
20
21

Rifndef BOOT
define
define
I" n
R
define
Dendif

HARDWARE FP
INT ONLYSFLOAT

23
24

#

17

1
1
1

1* Unix version 7 *1
1* Unix version 6 *1
1* Unix version 6 plus diff listing *1

1*

n

n
n

C7
C6
NC6

1
1
1

;r,-

en

,»

1* select only one of the following: *1
define
define
define

-0

r,

1* version 7 C-compiler *1
1* version 6 C-compiler *1
1* something between C6 and C7 *1

I" if you've hardware floating point "I
1* for interpreted programs only * /
I" for single precision floats 1/

I" Version number of the EM1 object code "I
define VERSION
2
I" 16 bits number" I

z:

[T\

:E:

en

""
'"
'"
""
""
'"
IJoj

1
2

3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
41
42
43
114

45
46
47
lI8
49
50
51
52
53
54
55

56

'define sp_fmnem 1
#define sp_nmnem 149
'define sp_fpseu 150
ildefine sp npseu 30
'define sp=filbO 180
Ddefinesp nilbO 60
Idefine sp-f

:z
m

'"

en

""

N
N

QO

""

N

""

U)

m

....
"
'"
m
""
3:

;;0

I--'

co

00

"

l>
G>

m

""
""

2

3
II

5
6
7

8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27

28
29
30

31
32

33
34

35
36
37
38
39
110

41
42
43

44

45
46

47
48
49
50
51
52

53

54
55
56

non-standard featUre used

57

identifier 'Ss' declared twice
end of file encountered
bad line d irecti ve
unsigned real: digit of fraction expected
unsigned real: digit of exponent expected
unsigned real: too many digits (>72)
unsigned integer: too many digits (>72)
unsigned integer: overflow (>32767)
string constant: must not exceed one line
string constant: at least one character expected
string constant: double quotes not allowed (see c option)
string constant: too long (>72 chars)
comment: ';' seen (statements skipped?)
bad character
identifier 'Ss' not declared
location counter overflow: arrays too big
arraysize too big
variable '%8' never used
variable 'Ss' never assigned
the files contained in '%s' are not closed automatically
constant expected
constant: only integers and reals may be signed
constant: out of bounds
simple type expected
enumerated type: element identifier expected
enumerated type: I , I or ') t expected
em.nnerated type: 't' expected
enumerated type: ')' expected
subrange type: type must be scalar, but not real
subrange type: t •• I expected
subrange type: type of lower and upper bound incompatible
subrahge type: lower bound exceeds upper bound
array type: '[' expected
conform ant array: low bound identi fier expected
conformant array: ' .. t expected
conformant array: high bound identifier expected
conform ant array: ': t expected
conformant array: index type identifier expected
array type: index type not bounded
array type: index separator or ']' expected
array type: index separator expected
array type: '1' expected
array type: 'of' expected
record variant part: tag type identifier expected
record variant part: tag type identifier expected
record variant part: type must be bounded
record variant part: 'of' expected
record variant: type of caSe label and tag incompatible
record variant: multiple defined case label
record variant: 't' or ':' expected
record variant: t, t expected
record variant: I: t expected
record variant: '( I expected
record variant: ')' expected
record variant part: ';' or end of variant list expected

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77

78
79
80
81
82
83
311

85
86
87
88

89
90
91
92

93

94
95
96
97

98
99
100
101
102
103
104

105
106
107
108

109
110
111
112

record variant part: ';' expected
record variant part: end of variant list expected
record var~ant part: there must be a variant for each tag value
field list: record section expected
record section: field identifier expected
record sec tion: ',lor ':' ex pected
record section: ',' expected
record section: ':' expected
field list: ';' or end of record section list expected
field list: ';' expected
field list: end of record sectio,n list expected
type expected
type: simple and pOinter type may not be packed
pointer type: type identifier expected
pOinter type: type identifier expected
record type: 'end' expected
set type: 'of' expected
set of integer: the i option dictates the number of bits (default 16)
set type: base type not bounded
set type: too many elements in set (see i option)
file type: 'of' expected
file type: files within files not allowed
var parameter! type identifier or conformant array expected
var parameter: type identifier expected
label declaration: unsigned integer expected
label declaration: label '~i' multiple declared
label declaration: ',' or ';' expected
label declaration: ',' expected
label declaration: ';' expected
const declaration: constant identifier expected
const declaration: '=' expected
canst declaration: ';' expected
const declaration: constant identifier or 'type', 'var', 'procedure', 'function' or
type declaration: type identifier expected
type declaration: '=' expected
type declaration: '; I expected
type declaration: type identifier or 'var', 'procedure', 'function' or 'begin' expect
var declaration: var identifier expected
var declaration: ' , or ': t expected
var declaration: , expected
var declaration: ,., expected
var declaration: ,., expected
var declaration: var identifier or 'procedure', 'function' or 'begin' expected
parameter list: 'var',' procedure' , ' function' or identi fier expected
parameter list: parameter identi fier expected
parameter list: ',' or ':' expected
parameter list: ',' expected
parameter list: ': I expected
parameter list: type identifier expected
parameter list: ';' or ')' expected
parameter list: ';' expected
proc/func declaration: proc/func identifier expected
proc/func declaration: previous declaration of ''%s' was not forward
proc/func declaration: parameter list expected
parameterlist: ')' expected
func declaration: ': t expected

~

::t-

V>

C""'>

::t-

o
z

rn

::E:
V>

'It
N
N
I/O

'It
N
V<

,.

-0

'"

113
114
115
116

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

154
155
156
157
158
159
160
16"1
162
163

164
165

166
167
168

func declaration: result type identifier expected
fune declaration: result type must be scalar, subrange or pointer
proc/func declaration: '; I expected
proc/fUnc declaration: block or directive expected
proc/func declaration: '~SI again forward declared
proc/func declaration: ,~s' unknown directive
proc/func declaration: t;. expected
indexed variable: f[' only allowed following array variables
indexed variable: index type not compatible with declaration
indexed variable: I f or I ] t expected
indexed variable: ' I expected
assignment: standard function not allowed as destination
assignment: cannot store the function reaul t
assignment: formal parameter function not allowed as destination
assignment: function identifier may not be de-referenced
variable: t[ I , ' . r, '''''' or end of variable expected
indeXed variable: 'l' expected
field designator: field identifier expected
field designator: ' , only allowed following record variables
field designator: no field '%s' in-this record
referenced. variable: , .... , not allowed following zero-terminated strings
referenced variable: , .... , only allowed following pointer or file variables
variable: var or field identifier expected
call: array parameter not conformable
call: type of actual and formal variaqle parameter not similar
call: packed elements not allowed as variable parameter
call: type of actual and formal value parameter not compatible
call: proc/fUnc identifier expected
call: standard proc/func may not be used as parameter
call: parameter lists of actual and formal proc/fUnc incompatible
call: ',' or ')' expected
call: too many actual parameters supplied
call: ')' expected
call: too few actual parameters supplied
read (In): type must be integer, char or real
write( In): type must be integer, char, real, string or boolean
write(ln): ':', ',' or ')' expected
write(ln): field width must be integer
write(ln): ':', 't' or ')' expected
write (In) : precision must be integer
write(In): precision may only be specified for reals
read/write: too few actual parameters supplied
read/write: standard 'input/output not mentioned in program heading
read/write: '.' or ')' expected
read/write: type of parameter not the same as that of the file elements
read/write: parameter list expected
readln/writeln: standard input/output not mentioned in program heading
readln/writeln: only allowed on text files
eof/eoln/page: file variable expected
eoln/page: text file variable expected
eof/eoln/page: standard input/output not mentioned in program heading
new/dispose: pOinter variable expected
new/dispose: C-type strings not allowed here
new/dispose: ',' or ')' ex~cted
new/dispose: too many actual parameters supplied
new/dispose: type of tag field value is incompatible with declaration

169
170

171
172
173

174
175
176

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

put/get: file variable expected
reset/rewrite: file variable expected
mark/release: painter variable expected
pack/unpack: array types are incompatible
pack/unpack: only for arrays
call: '(' or end of call expected
standard proc/func: parameter list expected
standard proc/func: parameter type incompatible with specification
pack: I , expected
pack: ' • expected
unpack: ' . expected
unpack: ' , expected
halt: integer expected
abs: integer or real expected
sqr: integer or real expected
ord: type must be scalar or subrange, but not real
pred/ succ: type must be scalar or subrange, but not real
trunc: real argtmlent required
round: real argument required
call: ')' expected
expression: left and right operand are incompatible
set: base type must be bounded or of type integer
set: base type upper bound exceeds maximum set element number (255)
set: incompatible elements
set: ']' or element list expected
set: ' .. ' , . or ']' expected
set: elements do not fit (see i option)
set: ',' or ']' expected
set: ' , expected
factor expected
factor: ')' expected
factor: type of factor must be boolean
set: ']' expected
term: multiplying operator or end of term expected
term: '., only defined for integers, reals and sets
term: '/' only defined for integers and reals
term: 'div' only defined for integers
term: 'mod' only defined for integers
term: 'and' only defined for booleans
simple expression: only integers and reals may be signed
simple expression: adding operator or end of simple expression expected
simple expression: '+' only defined for integers, reals and sets
simple expression: '-' only defined for integers, reals and sets
simple expression: 'or' only defined for booleans
expression: relational operator or end of expression expected
expression: set expected
expression: left operand of 'in' not compatible with base type of right operand
expression:. only '=' and ,<>, allowed on pointers
expression: ,<, and ,>, not allowed on sets
expression: comparison of arrays only allowed for strings
expression: comparison of records not allowed
expression: comparison of files not allowed
assignment: f: =' expected
assignment: left and right hand side incompatible
goto statement: unsigned integer expected
goto statement: label '%i' not declared

"'0

»

Ii)

m

225
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

i f statement

type of expression must be boolean
if statement 'then' expected
if statement 'else' or end of if statement expected
case statement: type must be scalar or subrange, but not real
case statement: 'of' expected
case statement: incompatible case 1 abel
case statement: multiple defined case label
case statement: I,' or ':' expected
case statement: t , ex pected
case statement: 1: I expected
case statement: ';' or 'end' expected
case statement: ';' expected
case statement: 'end' expected
repeat statement: '; I or 'until' expected
repeat statement: I;' expected
repeat statement: 'until" expected
repeat statement: type of expression must be boolean
while statem'ent: type of expression must be boolean
while statement: 'do' expected
for statement: control variable expected
for statement: control variable must be local
for statement: type mus.t be scalar or sub range , but not real
for statement: ': = t expected
for statement: type of initial value and control variable incompatible
for statement: 'to' or 'downto' expected
for statement: type of final value and control variable incompatible
for statement: 'do' expected
with statement: record variable expected
with statement: ',t or 'do' expected
with statement: ',' expected
with statement: 'do' expected
assertion: type of expression must be boolean
statement expected
label '$1' not declared
label '$1' multiple defined
statement: ':' expected
unlabeled statement expected
compound statement: ';' or 'end' expected
compound statement: ';' expected
compound statement: 'end' expected
case statement: tend t expected
body: ';' or tend t ex pected
body: ';' expected
body: label 'U' declared. but never defined
program parameter t~s' not declared
function '~s' never assigned
block: declaration or body expected
block: 'const'. 'type'. 'var', 'procedure', 'function' or 'begin' expected
block: 'type'. 'var', 'procedure', 'function' or 'begin' expected
block: 'var'. 'procedure', 'function' or 'begin' expected
block: 'procedure', 'function' or 'begin' expected
block: unsatisfied forward proc/func declaration(s)
block: 'begin' expected
block: 'end' expected
program heading: 'program' expected
program heading: program identifier expect.~-

281
282
283
284
285
286
287
288
289
290
291
292
293
294

program heading: file identifier list expected
program heading: file identifier expected
program heading: ',' or ')' expected
program heading: ',' expected
program heading: maximum number of file arguments exceeded (12)
program heading: ')' expected
program head ing: ';' ex pected
program: '.' expected
'program' expected
module: 'const', 'type', 'var', 'procedure' or 'function' expected
module: 'type', 'var'. 'procedure' or 'function' expected
module: 'var'. 'procedure' or 'function' expected
module: 'procedure' or 'function' expected
garbage at end of program

-0

:>G>

m

63
64
65
6f>

RETURN COHRDL STATElIENl OPTICN SETTI~G.
COPYRIGHT CC) UNIVERSITY OF MINt>i£SOTA
- 1978.
A. 8. MICKEL.
11/06/02.

10 '"

THE ORIGINAL ROUTlNE -OPTION- ACCEPTED A ONE-CHA~ACTER
DPTIONNAHE AND RETURNED AN OPTION SETTING OF +, -.
OR A POSITIVE INTEGEII.

=.

5 ..

6 ..
7 ..
8 ..

9 ..

THIS VERSION. CALLED -OPTIONS-.
ACCEPTS
ANY STRUG
Of 1
TO ill ALP"ANUIIEIUC CHARACTERS (STARTING WITH AN
ALPHA) AS THE OPTION
NAIIE ANDRElURf>S A STRING
OF
1 TO 18 CHARACTERS OR A POSITIVE INTEGER AS THE OPTICN
SETTING. AN EQUALS SIGN HAY BE USED BETWEEN
AN
OPTION
~AIIE
AND ITS OPTION SETTING.
IF THERE IS NO
OPTION SETTING AftER
THE EQUALS
SIGN,
THEN
THE
EQUALS SIGN ITSELF IS USED AS THE OPTION SETTING.
IF
THE OPTION NAME IS FOLLOWED BY A COMMA,
PERIOD,
OR
RIGHT
PARENTHESIS. THE OPTIC II SETTIliIG IS RETURNED AS A
STRING CJO Hi SLANK ("ARACTERS.

10 "
11"

12 ..

13 "

110 ..

15 ..
16 "

17"

18 ..
19 ..

20
21
22
23
210

67
68

~IPTIONS -

1 C....
2 ..
3 ..

"
..
..
..
..

THE INPUT VARIASLE -NAME- IS NOH TYPE ALFA. AND IN THE
RECORD TYPE -SETTING-,
THE FIELD -ONOFF- IS NC~ TYPE
ALfA.

25 ..
26 ..

SEE THE PASCLIS WRlTEUP fOR EXTERl'IAL DOCUMENTATION.
NOIE THAT THENAHE OF THIS VERSION IS -OPTIONS-.

27 ..
28
29
30
31

32

..
..
..
'"

SPlKE LEONARD - SANDIANATlONAL LABORATORIES, LIVERMORE
Z4 FEB 1981

33 FUNCTION OPlIONSCNAHEI ALFA: VAR 51 SETTING'IBOOLEAN:

310
35 CONST
36

69
70
71
72
73

14
75
76
77

78
19
80
8:1.

82
83
84
65
86
87

as

89
90
91
92
93
94
95
96
97

98
99
100
101
10Z
103
104

CSADORESS ,. lOB C"CONTROL STATEMENT ADDRESS"';

37
38 TYPE
39
CSIMAGEP = RECORD CASE BCOLEAN Of
fALSEI " I INTEGER'~
100
TRUE I CP 1 ~LOHCORE'
101

105

I

IF

1= I .. 1;

"I"

CSIHAGE.P1 (IJ
THEN C·CRACK OPTIONS.·'
REPEAT
I 1= I • 1;
J 1= 11
OPNAHE 1= +
.. ;
IF CSIHAGE.P~(IJ IN (+A+ .... Z .. 1 THEN BEGIN
IIHILE ICSIHAGE.P 1 ( l J IN (U ••• +Z ... +O+ .... 9 .. J) AHIlNOT FOIJND
00 8EGIN
OPNAHE(JI
CSIMAGE.P 1 (IJt
J 1= J • 1;

.=

I

.= I

.. U

IF (!lAME = OPNAII£) AND NOT CCSIHAGE.P 1 (IJ IN (+H •• +2+))
THEN BEGIN
FOUND .: TRUE;
If CCSIHAGE.P~(II = +=+, AND
NOT CCSIHAGE.P 1 (I+1J IN [ ........... , .. ' .. 1) THEN

I

.=

I .. U

S.SWITCH .= NOT (CSI~AGE.P~(IJ IN ( .. 0 •••• 9 .. J);
IF S.SWITCH nEN BEGIN
S.ONOFF .= +
.;
K
1;
1
WHILE NOT (CSIMAGE .P [IJ IN (+,+, ....... ' .. n DO BEGIN
S.ONOFF(K] .= CSIHAGE.P~[Il;
K 1= K + 1-'
I
I .. it
END;
END
ELSE
WHILE CSIHAGE.P 1 {I] IN [.0+ .... 9.] DO BEGIN
S.SIZE 1= S.SIZE"10
+ COROICSIMAGE.F1 {IJ' - ORO(+O+I';
I 1= I .. H
END;
END;
END;
END;
IF NOT FOUND THEN
WHILE NOT CCSIIIAGE.P 1 {II IN (.,+,+ •• ,.'.1) 00 I 1= I .. 1:
UNTIL CCSIMAGE.P1 (IJ IN ( .... , . , .. ])
OR FOUND;
OPTION~ I~ fOUND;
END '·OPTIONS·';

.=

.=

U>

rn

."
-I

rn

:3

""
""

rn

......
<.0

00

......

UIO;

102

LOIICORE = PACKED ARRAY(1 •• 801 OF CHAR:

43

"10

45 VAR
46

107

48
49

SO
51

CSIHAGE. CSIHAGEP;
OPNAMEI ALFA;
11 INTEGER
.11 INTEGER
KI INTEGER
FOUNDI BOOLEAN 1

C· IIIOEX I'N CSIHAGE .J:
C. INDEX FOROPNAHE "n
I. I~DEX FOR S.ONOFF .,

~

ITt

52
53 BEGIN C"OPTIONS'"

510
55
56

51
58
59
oll
6J.

62

,.
'"

."

FOUND 1= fALSE:
S .SWITCH 1= FALSE;
S .SI ZE 1= 0;
CSIMAGE.A 1= CSAOaRESS:
I 1= 1 I"SKIP PROGRAM .. AME AND PARAIIETERS.");
HHILE CSIIIAGE.P1 (I] I" {+A+ •• • Z+, "O+ ••• g.. , .. "1 00
I 1= I .. 11
lFfiOT CCSI~AGE.P1(IJ IN (")1', . . . . ll THEN
I 1= I .. 1 C.SKIP SLASH IF fIRST DELIMITER. "';
WHILE NOT tCSIMAGE.P1(Il IN (9/ •• • ''', +,"1) DO

VI
00

TREEPRINT - A Package to Print Trees
on any Character Printer
Ned Freed
Kevin Carosso
Mathematics Department
Harvey Mudd College
Claremont, Calif. 91711

One of the problems facing a programmer who deals with complex
linked data structures in Pascal is the inability to display such a
structure in a graphical form. Usually it is too much to ask a
system debugging tool to even understand records and pointers, let
alone display a structure using them in the way it would appear in a
good t!xtbook.
Likewise very few operating systems have a package
of routines to display structures automatically.
Pascal has a
tremendous advantage over many languages in its abl1 i ty to support
definable types and structures. If the environment is incapable of
dealing with these features, they become far less useful.
This lack became apparent to us in the process of writing an
algebraic expression parser which produced internal N-ary trees
There was no way at the time under our operating system debugge;
(VAX/VMS) to get at the data structure we were generating. When the
routines produced an incorrect tree we had no way of finding the
specific error,
Our frustration led to the development of TREEPRINT.
Starting
with
the
algorithm
of
Jean
Vaucher
[1], we designed a
general-purpose tool capable of displaying any N-ary tree on any
character output device.
The trees are displayed in a pleasant
visual fOrm and in the manner in which they would appear if drawn by
hand.
We feel that TREEPRINT is of general use -- hence its
presentation here.
The structure of TREEPRINT is that of an independent collection
of subroutines that any program can call. Unfortunately standard
Pascal does not support this form, while our Pascal environment
does.
However, building TREEPRUIT directly into a program should
present no difficulty.
TREEPRINT requires no knowledge of the format of the data
structure it is printing. It has even been used to print a tabular
linked structure within a FORTRAN programl In order to allow this,
two procedures are passed in the call to TREEPRINT. One is used to
·walk" the tree, the other to print identifying labels for a given
node.
Other parameters are values such as the size of the nodes,
the width of the page, etc. One of the advantages of this calling
mechanism is that a single version of TREEPRINT can be used to
display wildly different structures, even when they are· within the
same program.

One of the major features of TREEPRINT is its ability to span
pages. A tree that is too wide to fit on one page is printed out in
'stripes. which are taped together edge-to-edge after printing.
In
addition trees may optionally be printed either upside-down or
reversed from left-to-right.
The method used by TREEPRINT is detailed in Vaucher's work [1].
In
its
current
implementation additional support for N-ary
structures has been added, as well as full connecting-arc printing
and the reversal features.
Basically, TREEPRINT walks the input
tree and constructs an analogous structure of its own which
indicates the positions of every node. The new structure is linked
along the left edge and across the page from left-to-right.
Once
this structure is completed, TREEPRINT walks the new structures and
prints it out in order. Once printout is finished, the generated
structure is DISPOSE'd of.
There are only two minor problems in TREEPRINT currently.
The
first is that a structure which contains circular loops will hang
the routine. This could be detected in the POSITION phase of
TREEPRINT by checking each new node against all of its ancestors.
However, if used in a non-Pascal application, this might fail due to
problems in comparing pointers.
If this check is necessary we
suggest it be implemented in the LOWERNODE procedure passed to
TREEPRINT.
This procedure at least understands the type of pointer
it is dealing with.
The second problem is a feature of the POSITION routine which
centers a node above its sons.
This tends to make the trees
generated wider than necessary. This is largely a matter of taste
-- some minor changes would remove this.

en

rn

.."

.....
rn

:.:

......,..,""

;0

to

00
.....

The listing of TREEPRINT which follows should serve to document
the
method
of
calling the routine.
The functions of the
user-supplied procedures are also detailed.
References
[11 Vaucher, Jean, "Pretty-printing of Trees." Software~ Experience, Vol.
10, pp. 553-561 (1980).

Practice

[2] Myers, Brad, Displaying Data Structures for
Interactive
Debugging, Palo Alto: Xerox PARC CSL-80-7 (1980).
{3] Sweet, Richard, Empirical Estimates of Program
Entropy,
Appendix B - "Implementation description", Palo Alto: Xerox
PARC CSL-78-3 (1978).

.."

>

en

In

'"to

1 module TREEPRINT (input,output);
2
3 (*
TREEPRINT - A routine to print N-ary trees on any character
4
printer. This routine takes as input an arbitrary N-ary tree,
5
some interface routines, and assorted printer parameters and
6
writes a pictorial representation of that tree to a file. The
7
tree is nicely formatted and is divided into vertical stripes
8
that can be taped together after printing. Options exist to
9
print the tree backwards or upside down if desired.
10
11
The algorithm for TREEPRINT originally appeared in ·Pretty12
Printing of Trees', by Jean G. Vaucher, Software-Practice and
13
Experience, Vol. 10, 553-561 (1980). The algorithm used here
14
has been modified to support N-ary tree structures and to have
15
more
sophisticated printer format control. Aside from a common
16
method of constructing an ancillary data structure and some
17
variable names, they are now very dissimiliar.
18
19
TREEPRINT
was written by Ned Freed and Kevin Carosso,
20
5-Feb-81. It may be freely distributed, copied and modified
21
provided that this note and the above reference are included.
22
TREEPRINT may not be distributed for any fee other than cost
23
of duplication.
24
25
INPUT - The call to TREEPRINT is:
26
TREEPRINT (TREE,TREEFILE,PAGESIZE,VERTKEYLENGTH,
27
HORIKEYLENGTH,PRINTKEY,LOWERNODE)
28
29
where the parameters are:
30
31
TREE - The root of the tree to be printed. The nodes of
32
the tree are of arbitrary type, as TREEPRINT
33
does not read them itself but calls procedure
34
LOWERNODE to do so. In a modular enviroment
35
this should present no problems. If TREEPRINT
36
is to be installed directly in a program TREE
37
will have to be changed to agree in type with
38
the actual tree's nodes.
39
TREEFILE - A file variable of type text. The tree is
40
written into this file.
41
PAGESIZE - The size of the page on output represented
42
as an integer count of the number of available
43
columns. The maximum page size is 512. Any size
44
greater than 512 will be changed to 512.
45
LOWERNODE - A user procedure TREEPRINT calls to walk
46
the user's tree. The format for the call is
47
described below along with the functions
48
LOWERNODE must perform.
49
PRINTKEY - A user procedure TREEPRINT calls to print
50
out a single line of a keyword description of
51
some node in the user's tree. The description
52
may be mUlti-line and of any width. The call
53
format is described below.
54
VERTKEYLENGTH - The number of lines of a description
55
printed by PRINTKEY. This must bea constant
56
over all nodes. I f VERTKEYLENGTH is negative,
57
its absolute value is used as the key length and
58
the whole tree is inverted on the vertical axis.
59

HORIKEYLENGTH - The number of characters in a single
line of a description printed by PRINTKEY. This
must be a constant. If negative the absolute
value of HORIKEYLENGTH is used and the whole
tree is inverted from left to right.

60
61
62
63
64
65
66

CALLS TO USER PROCEDURES - The calls to user-supplied procedures
have the following format and function:

67
68
69
70

PRINTKEY (LINENUMBER,LINELENGTH,NODE)
LINENUMBER - The line of the node description to print.
This varies from 1 to VERTKEYLENGTH. Since TREEPRINT
operates on a line-at-a-time basis, PRINTKEY must be
able to break up the output in a similiar fashion.
LINELENGTH - The length of the line. PRINTKEY must
output this many characters to TREEFILE - no more, no
less.
NODE - The node of the user's tree to derive information
from.

71

72
73

74
75
76
77
78
79
80
81
82
83
84
85
86

~

.J»

LOWERNODE (NODE,SONNUMBER)
SONNUMBER - The sub-node to return. A general N-ary tree
will have N of them.
NODE - The node of the user's tree to derive the
information from.
LOWERNODE, on return should equal NIL if that node does
not exist, NODE if the SONNUMBER is illegal, and
otherwise a valid sub-node. Note that circular
~
structures will hang treeprint thoroughly. The condition"
that LOWERNODE returns NODE when N is exceeded must be
~
strictly adhered to, as TREEPRINT uses this to know
~
where to stop. LOWERNODE is used to hide the interface
rn
between TREEPRINT and the user's tree so that no format
details of the tree need be resident in TREEPRINT.

87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119

~

:c
......

OUTPUT - All output is directed to TREEFILE. There are no error
conditions or messages.
*)

(* The declaration of the user's node type. If type checking is a
problem this should be changed to match the type for the actual
nodes in a tree. *)
type
nodeptr

"'integer;

procedure treeprint (tree: nodeptr; var treefile : text;
pagesize, vertkeylength, horikeylength
integer; procedure printkey; function
lowernode : nodeptr);
type
refl ink = Alink;
link = record
next : refl ink;
pnode : nodeptr;
pos : integer;
lstem
boolean;
ustem : boolean;

 0 then for charp := 1 to charp do
169
write (treefile,line[charp);
170
charp := 0;
171
writeln (treefile);
172
end;
(* Ctrim *)
173
174
function position (N : nodeptr; var H : refhead; pos : integer)
175
176
: refl ink;

177

178
179

(* Position is a recursive function that positions all the
nodes of the tree on the print page. In doing so, it

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

constructs an auxiliary data structure that is connected
by line number along the edge and position from left to
right. In addition, it stores some of the original tree
connections for a~c printing. *)
var

over, lastover, nodecount
Nlower : nodeptr;
L, left, right : reflink;
needright : boolean;

integer;

begin (* position *)
if N = nil then (* Be defensive about illegal nodes. *)
position := nil
else
begin (* Create a new node in our tree. *)
new (L);
position := L;
L' • pnod e : = N;
LA.ustem := false;
if H = nil then
begin (* A new line has been reached. *)
new (H);
H·.next := nil;
L·.next := nil;
end
else
begin (* Shift position if conflicting. *)
L·.next := H·.first;
if H·.first·:po~ < ~os + 2 then
pos := H .flrst .pos - 2;
end;

H·.first := L;
nodecount := 0;
over := 1;
repeat (* Count the number of lower nodes. *)"
Nlower : = lowerr,ode (N ,over) ;
if ((Nlower <> N) and (Nlower <> nil»
then
nodecouY'-;': := nodecount + 1;
over :=

0"; ,..

.....

'"
.....
00

+ 1;

until Nlower = N;
if nodecount > ~ then
begin (* There are lower nodes, loop to position. *)
L·.lstem := true;
lastover := nodecount - 1;
nodecount := over;
over := - lastover;
needright := true;
repeat (* Recursively evaluate lower positions. *)
repeat (* Find one that is non-nil. *)
~
if nodecount > 0 then
:;:
Nlower := lowernode (N,nodecount)
else
Nlower := N;
nodecount := nodecount - 1;
until Nlower <> nil;
if Nlower <> N then
begin
left :=
pOSition (N10wer, HA.next, pos + over);

240

if needright then

241
begin
242
right ,= left;
243
needright := false;
244
end
245
else left".ustem := true;
246
over := over + 2;
247
end;
248
until (over> lastoverl or (nodecount <= 0);
249
pos := (left".pos + right".posl div 2;
250
end
251
else
252
L.... lstem' := false;
253
if pos > maxposition then maxposition := pos
254
else
255
if pas < minpasition then minpasition := pos;
256
L".pos := pos;
257
end;
(* i f N = nil *)
258
end;
(* Position *)
259
260 begin
(* Treeprint *)
261
262
(* Initialize various variables. *1
263
264
lines := nil;
265
minposition := 0;
maxposition := OJ
266
charp ,= 0;
267
268
269
(* Do various width and length calculations. *1
270
271
if pagesize > 512 then pagesize := 512;
272
width := abs (horikeylengthl + 4;
273
stemlength := abs (vertkeylengthl + 1;
274
vertnodelength := 3 * abs (vertkeylength) + 4;
275
i f (width mod 2) = 0 then width := width + 1;
276
pagewidth := pagesize div width;
277
278
(* Construct our data structure and compute positions. *)
279
280
oldL := position (tree,lines,O);
281
282
(* If the horizontal reverse option is selected, reverse
283
every node on every line of the data structure. It is
284
also necessary to switch .around the states of the USTEM
285
flags that tell who connects above a given node. *)
286
287
if horikeylength < 0 then
288
begin
289
H := lines;
290
291

292
293
294
295
296

297
298
299

while H <> nil do
begin
H".first".pos := maxposition H".first".pos + minposition;
if H".first".ustem then
begin
H".first".ustem := false;
endloop := true;
end
else

300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338

339
340
341
342
343
344
345
346
347
348

endloop := false;
L
nil;
while H" .first" .next <> nil do
begin
H".first".next".pas := maxposition H".first" .next".pos + minposition;
if H".first".next".ustem then
begin
i f not end loop then
begin
H".first".next",ustem := false;
endloop := true;

,=

end;

end
else
if end loop then
begin
H".first".next",ustem :=. true;
end loop := false;
end;

oldL := H".first".next;
H".first",next := L;
L := H".first;
H".first ,= oldL;
end;
H",first",next := L;
H := H".next;
end;
end;

(* If the vertical reverse option is selected, reverse the
entire tree on the vertical axis by flipping all the
head nodes along the edge. Arc reversal is handled in
the actual arc generation routines. They will scan the
previous line of info instead of the current one, *)
slines := lines;
if vertkeylength < 0 then
begin
H :== nil;
while lines".next <> nil do
begin
D := lines".next;
lines .... next := H;
H := lines;

359

 nil do
begin (* Loop over all lines possible, *)
oldL := H".first;

:.en

'"

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418

419

repeat
(* Find a node on current strip, *)
endloop := true;
if oldL <> nil then
if oldL',pos < startposition then
begin
(* Reject this node, *)
oldL := oldL',next;
endloop .: = false;
end;
until end loop ;
for i := 1 to vertnodelength do
begin
(* Loop for each print line in a node. *)
L := oldL;
p := startposition;
while (p < startposition + pagewidth) and
(L <> nil) do
begin
(* Scan for nodes we need to draw, *)
if L',pos = p then
begin (* Found node at current position. *)
if (i <= stemlength) then
begin
(* Draw upper stem part of node, *)
for w := 1 to (width div 2) do
cout (' ');
if «vertkeylength < O) and L',lstem)
or «vertkeylength )= 0) and
(H <> slines»
then cout ('*')
else cout (' I);
for w := 1 to (width div 2) do
cout (I I);
end
else
if (vertnodelength - il < stemlength then
begin
(* Draw lower stem part of node, *)
for w := 1 to (width div 2) do
cout (' ');
if «vertkeylength >= 0) and L',lstem)
or «vertkeylength < 0) and
(H <> sl ines»
then cout (' *' )
else cout (' ');
for w := 1 to (width div 2) do
cout (' ');
end
else
if (i )= stemlength + 2)
and (i <= stemlength * 2) then
begin
(* Print node identifier, *)
cout ('*');

cout

(1

I);

cdump;
printkey (i - stemlength - I,
abs (horikeylength), L',pnode);
cout (' ');

co u-t (I

*I ) ;

end
else
for w := 1 to width do cout ('*');
L := L',next;
end
else
for w := 1 to width do cout (' ');

p := p + 1;

420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

end;

ctrim;
end;

(* for *)

(* Select the proper line to obtain arc info from, *)
if vertkeylength )= 0 then
begin
if H',next <> nil
then L := H',next',first
else L := nil;
end
else L := H',first;
p :~ startposition;
~
while (p < startposition + pagewidth) and (L <> nil) do N
begin
endposition := L',pos;
beginposition := L',pos;
if L',ustem then
while (L',next <> nil) and L',ustem do
begin
L := L',next;
endposition := L',pos;

end;
L := L',next;
if (beginposition < startposition + pagewidth)
and (endposition >= startposition) then
begin
(* Found an arc we should draw, *)
while p < beginposition do
begin
(* Space over to proper position, *l
for w := 1 to width do cout (' ');
p := p + 1;

end;

if beginposition = endposition then
begin
(* Case of one node directly below, *)
for w := 1 to (width div 2) do cout (' ');
if H <> slines then cout('*')
else cout(' ');
for w := 1 to (width div 2) do cout (' ');
p := p + 1;
end
else
begin
(* Normal multi-segment arc, then, *)
if P = beginposition then
begin
(* Begin with a half segment, *)
for w := 1 to (width div 2) do
cout (' ');
for w := (width div 2) to width-1 do
cout ('.');
p := p + 1;
end;
while (p < endposition) and
(p < startposition + pagewidth) do
begin
(* .Connect to the end segment, *)
for w := 1 to width do cout ('*');

p := p + 1;

end;

if p < startposition + pagewidth then
begin
(* Draw end segment of the arc, *)

en
rn
-0

-!

rn

3:

co

rn

;;0

.......


'"

for w := (width div 2) to width-l do

480
481
482
483
484
485
486
487
488
489
490

cout (' *');

for w := 1 to (width div 2) do
cout (' ');
p : .. p + 1;
end;
end;
end;
end;

491

492
493

end;

494

495

9
10

(* We have now finished an entire line of tree. *)

11
12
13
14
15
16
11
18
19
211
21
22
23

H := H".next;
(* while H<>nil

*)

497

startposition := startposition + pagewidth;
(* while startposi tion <= maxposi tion *)

498
499

end;

500
501
502
503

(* All output is finished. It is now time to close out our extra
data structure. *)

while lines <> nil do
begin (* Collect a line of stuff and dispose. *)

504

505

H := linesA.next;

506

510
511

while lines".first <> nil do
begin (* Kill a node. *)
L := lines".first".next;
dispose (lines".first);
lines".first := L;

512

end;

507
508

509

dispose (lines);
lines := H;

513
514
515

end;

516

517 end;

(*

Treeprint

518
519 end.

(*

Of module TREEPRINT

*)
*)

520

written by:

4

5
6
7
8

ctrim;

(* Start up on a new page of material. *)

496

1

2
3

(c) Copyright 1980

The author grants permission to copy for non-profit use, providing
this comment remains.
)

PROGRAM

29
30
31
32
33
34
35

"RECALL".
)

LABEL
13;

CONST
mlnchar
1 (This 15 the ordinal of the smallest cbaracter not to
be ignored, 1.e. in tbis case onlY nulls are ignored.}:
maXdepth
64 {Tbis Should be 2**n, where n is tbe number Of bits
per Character In the character set.},
max length
max depth:
Maxint = 34359138367:
bit.slze
36 {Number of bits per machine word):

=
=

=

=

TYPE
1)1 t

**************************

49

52
5J

54
5!>

5&
57
58

59
60

= 0 ••

out_wort!
alphabet
newchar

1,

=

PACKED ARRAY 11 •• bit_size] OF bit;
•• 127:

= minChar
= RECORD

length: 0 •• maxdepthl
nChar: PACKED ARRAY [1 •• maxdepthl OF bIt
€t;D:
treept ~ • tree;
tree
R€CORD
sum: 1 nte;1er,
left, right: treept
ENOl

=

44
45
4&
41
48
51

out.file):

This program taKes a text file and creates ~ compressed
version using Huffman codes. Savinqs average 30-40\. The compressed
file can be restored to normal using the Sister program called

31>
31
38
39
40
41
42
43

50

compre~s(ln.file,

(

24
25
2b
21
28

Tom Slone
NOV 15, 1980
at Lehigh UniVersity,
8etblehem, PA 18015
on a OEC System 20

VAR
num.ln.cnars, num_out.words: integer:
pos: InteQer;
Ifd: out_word:
In.fUe: text:
out_file: fILE Of out.word;
tally: ARRAY (alphabet] OF RECORD
marKed: boolean;
num.of: integer
END;
trees: RgCORD
t_num: 0 •• maxlenqth;

en

rn

.....
rn
.."

3:

""

.'"

rn

61
62
63
64
65
66
61
68
69

70
71
72
73

trsl ~~RAY [t •• maxlengthl OF treept
END;
newcharsetl ARRAY [alphabet1 OF newchar:

stactc: newchar;
PROCEDURE get_char:
BEGIN
REPEAT num_in_cnars:= num_ln-ehars + t;
UNTIL eof(ln_flle) OR (ord(1n-flh-.) <> 0)
ENDtGET_CHAR);

81
82
83
84

85
86
87

88
89
90
91

92
93

94
95
96
97

98
99

100
101
102

103
104
105
106
101

VAR

no

PROCEDURE exchangeCVAR x, Y: integer):

141
142
143
144
145
146

147
148
149

150
1!>1
152
153

154
l!>5

156
157
158
159
1&0

lot
102
163
Ib4
Ib5
166
167

t&8
11>9

temp: integer:

x,

x := VI

V := temp

E~D

(EXCHANGE):

110
111
112

=
=

I!: NO
I!:LSE

BEGIN
mln2 := sum:
e:r~D;

118
119
120

180

178
179

en
rn

"'tl

.....
rn
3

t:C

rn

::0

.....
<..0
00

=

115
176

117

temp: treept:

count. mini, mln2: integer:

BEGIN tGET_2_MINS}
mint := ~axlnt;
mln2:= maxlnt;
faR count := MinChar TO 127 00
WITH tallvlcountJ DO
If' Nor marlced
THEN
If' num_of < min2
THEN
IF num_of < minl
THEN
BEGIN
tr2 : trl:
min2 := mint:
DOSl
pos2 := posl:
c01Jnt:
mini
num_of
trl := falSe;
END
ELSE
BEGIN
tr2 := false:
pos2 := count:
11I1n2 := num_of
END:
FOR count :
1 TO trees. t_num on
WITH trees. trs [count] ., DO
If' sum < dn2
rH I!: Pi
IF su'" < mini
THEN
BEGlPi
pos2 := posl:
tr2 := trl:
mi02 := m1nl:
post := count,
trl := true,
mini := sum

173
114

PROCEDURE .. aKe_new_chars:
116 (~aKe the Huffman Characters based on the character frequencies
117 of the file.)
VAR

VAR

140

BEGIN
reset(1n_file 1I
FOR count := 'ftlnchar.J'O 127 DC?,
WIrH tallylcountl'DO
.
1= 0
BEGIN marKed: e falsel
IF NOr eol(1n_file)
THEN
BEGIN
IJet_char:
WHILE NOT eofCin_file) DO
8EGIN
THEN
If' ord(1n_flle-) < minchar
BEGU
writelnCtty, 'Bad character in input!·~·, ordC
in_file-» :
GOTO 13
END:
tallylord(1n_Hle-)]. num_of 1= tally[ordCin_flle-.>
]. nu .. _of + 1;
get_Char I
END
END
END (FILL_T~LLr):

temp :=

END

PROCEDURE 1et_2_minsCVAR posl, pos2: inte1er: VAR trl, tr2:
134
boolean):
135
U6 (Find the two Characters or character trees with the smallest
117 frequpncles.)
U8
139

BEGTN

sum := val

III

count: integer:

VAR

B£GIN left:= NIL:
ENO (GROUND):

1J2

108

109
110
111
112
113
114
115

123

III

74

78
79

poSl, pos2, cOQnt: inteqer:
done, trl, tr2: boolean:

124
PROCE~URE 1roundCt: treept: val: Integer):
125
126 (Ground the character tree With NIL's)
127
128
BEGIN
WITH t-, DO
129

75 PROCEDURE fIll_tally:
H. (Scan the file the first tIme and get a character count on
77 WhIch to maKe the new Huffman character set.)
80

121
122

NOT trl
IF NOT tr2
If'

END

THEN
THEN

tGEr_2_~INSJ:

00s2 :

tally[posl]. marKed := truel
tally[pos2]. marked := true

= count

"'tl

»

G>

Ul

U2
lY3

U4
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

202
203
204
205
206

BEGIN ("AKE..NEW.CHARS)
trees. t-num := 01
REPEAT
qet.2.mlns(posl, pos2, trl, tr2)J
IF trl AND tr2
THEN
WITH trees DO
-/
BEGIN
IF pos2 < posl
THEN exchan!ie(posl, poS2l~,
,
ne"(temp):
tempft.• SUIII := trs [posl) ft. sum + trs[p9s2t~, sum'
temp·~ left := trs[posll:
temp .... rIght := trs [poS21;
trs[posll := temPJ
t.num := t.num • I:
FOR count := pos2 TO t.num DO
trs[countl := trslcount .. II
END
EI.SE
IF NOT trl AND NOT tr2
THEN
WIT!! trees DO
BEGIN
t.nlllll := t~num + 11
new(trs It.num]);
NI-fH trs (t.numl ft DO
BEGIN
sum := tallylpostJ. nURl.of .. t'ally[pos21.
num_ofl

207
208
209
210
211

212
213
214
215
216
211
218
219
220

.. 221
',. 222
223
224
225

new(left):
new(riqht):
groundCleft, post):
ground(right, pos2)

END
END
EI.SE
WITH trees DO
BEGIN
IF tr2
THEN e~ch8nge(post, pos2)1
new(temp}J
tellpft.• SURI :_ trs [pasO ft. sum + tally Ipos21.
nUIR..ot;

left := trs[poslJ:
newCtemp-. right),'1roun NIL
237
THEN
238
IiI TH stack DO
219

240

BEGIN

241
242
243
244
245
246
247
248
249
250
251

nChar[length] t= 0,
length := length + I,
nchar[length] := 1,
next.chlltCtpt'. rigntH
A
next_CharCtpt • left):
length := length - 1

END
EI.SE newcharset[tpt A • sum] I_ staclt
EI'4D IN:EXT.CIiAR}:

BEGIII {get.new.char.setJ
staCk. length := 0:
next-char(trees. trslll)
END (get.new-char.set):

252
2!>3
254 PROCEDURE put.wordCI: bit)1
255 (Add a btt to the output buffer word and print when full.)
25&
257
BEGIN
pas := pas t I,
.2

out.flle~

:= w 0
THEN
BEGIN
nUlll.out.words :. nURl.out.words + 11
put(out.flle)
END
ELSE pos:= bit.slze1
convert(pos, wd),
num.out.words 1= num.out.words + 11
out.Jlle ft. :& wd,
put(out.flle)
END (FI.USHt;

2Y8
289
290
291
292
293
294
295
296
291 PROCEDURE write.lnteger(i: integer}1
<198 (Print an Integer btt oy bit.)
299

.....
O
)!>t
352
3!>]
354

355
356
357
358
359

3bO

31>6

31>7
3&8
31>9

310

315
316

31>2 PROCEOURE print.statu
3b3 {Print the number percentaqe of paqes saved. Note: The D~C·20
3&4 stores files by units Of pages which are 512 words eaCh.}
3b5_

BEGIN
lnit.out,
reset(in.f1Ie),
IF NOT eof(in.flle)
THEN
BEGU
IF orcHln.flle A,) .. 0
THEN qet.charl
WHILE NOT eof(tn.flle) DO
BEGIN
put.new.char(newcharset[ord(in.flleA)])1
~et.enar:

ENOl
flUSh
END
END {TRANSLATE),

3'19
380

181
382
383
384
385

386
387
388
389
3'10

391
J!12
393
394

.."

FUNCTION pages(1: Integer): integer,
BEGIN
IF 1 MOD 512 = 0
THEN pages:= I DIV 512
ELSE paqes:- 1 DIV 512 + 1
END (PAGES.,

»

en
n

»

r
z

.."
:E:

en

BEGIN (PRINT.STATS)
num.in.chars := num.ln.chars DIV 2;
IF num.in.chars MOD 5 = 0
THEN num.1n.chars:= num.in.chars OIV 5
ELSE num.ln.chars:= num.in.chars OIV 5 + 1,
wrlteln(tty, 'Tnere has been a " «(paqes(num.ln.chars) • pages
(nulII.out.words)) I pages (num.tn.chars» • 1 00: 2: t,
" saving on your file,')
END {PRINT.STATS',
BEGIN (MilItO
writeln(tty,
'Version 2,02 of Compress'),
pos := 0;
num_in_chars:= 0;
num_out_words:= 0;
IIriteln(tty, 'Scanninq.'),
fill.tallv,
wrlteln(tty, 'Calculating.'l1
malce.new.charsl
qet.new~char.set;
.rlteln(tty, 'Compressing,'),
translate,
print.stats;
13:
END (!lAIN),

en

.."
.."

.....
.."

3:

.."
""
,.,

.....
<.J:)

00
.....

I

61

2

Written by:

j

4
5
b
7
II

62

Tom Slone
"ov 15, 1<180
at Lehigh University,
Bethlehem, PA 18015
on a DEC SYstem 20

1>3

(c) Copyright 19RO

9

10
11 The author grants permission to copy for non-protit use, providing
12 this comment remains.
13
14 }
15 PRoGRAM recall On_file, out_flle);
{
16
Thts program reads the Huffman codes printed In tne
17
18 beginning of a tile produced by the sister program, ·COMPRESS·
19 and restores the rest of the file to its orIginal form.

20

21
22

•

24
25
26

13;

CONST
minchar

27

m8xdepth

28
29
30
31
32
J3

= I IThiS is the minimum recognizable character
(nulls are ignored)};
= 64 {ThiS number shOUld correspond to the one

~axlnt

=

bit_size

= maxdeptn;
= 31> {This number
3435913R361;

bit_size In

should correspond to the one tor
'CO~PRESS'};

34

35
Jb

37
38
39
40
41
42

43
44
45
4b
47
48
49

50
51

52
53

54
55
5&
57
58

81
88
89
90
91
92
93
94

TYPE
oi t = 0.. t;
in_word
PACKED ARRAY II •• bit_size) OF bit;
alphabet - mlnchar •• 127;
old_char
RECORO
length: 0 •• maxdepth;
nChar: PACKED ARRAY II •• maXdepthl OF bit
END;
treept
tree:
tree = RECORD
CliSE fruit: boolea'n OF
true: (ch: alphabet)~
false: (left, right: treept)
END:

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

VAP

110

=
=

= '"

in_fUel FlI,E or in_word:
out_fUel text;
branch: treept;
lnpl, Inp2: in_word;
num_left, pos: 0 •• bit_s1ze;
hay_dos, done: boolean:
depth: Inteqer:

59

bU

14
75
16
71
78
19
80

86

for

rnaxdepth In "CDMPRF.SS·';

rnaxlength

11
12
73

81
82
83
84
85

LAB€L

23

64
65
6&
67
68
69
1U

PROCEDURE init:

B£GIII
new(branch):
branch
fruit := falSe;
branCh". left
NILI
branch
right := NIL,
resetCln..fllell
Inpl ,= In-Ute'"
A
getCln_fUel1
Inp2:= In_fHe , '
get(1n-fllel1
pos ,a' 1,
haY_dos, := true:
done
false
END UNIT);
A

A

,a:

..

•

,a

FUNCTION get_bit: bit'
VAR
con: RECORD
CASE boolean OF
true: (Int: Integer),
false: (w, In_word)
END,

BEGIN
IF NOT eoUin_fUe)
THEN
IF pos < bit_size
THEN BEGIN get-blt := Inpl[poIJ,
pos ,= POI ~ 1 END
ELSE
BEGIII
get_bit :_ lnpl [bit_size],
pos':a I,
Inpl ,a inpU
Inp2 :s in_flle",'
qetUII-fUe)
EIID
ELSE
BEGIII
IF hay_dos THEN
BEGIII
con. w :a Inp2I
nUII..left ,a' eon. Int~ POI - 11
hay_dOl :a' false
END,
get-bit := Inpl[pol]'
IF pos "nue_left
THEN done ,- true
ELSE POI
POI ~ 1
END
END {GET-BIT},

,=

PROCEDURE Ull_tree,
VAR
1: Integer;
save_tree: treeptl

FUNCTION get_Integer: integer,

111

112
113

114
115
116
117
118
119
120

Vll.R

pow-2, ans, count: Integer,

BEGIII
pow_2 := lIaxdepthl
ani la,O,
FOR count 1= 1 TO 7 DO
BEGIN
anI := ani ~ pow_2 • qet.blt,
END,

POW"

,a

DOW'"

Drr J

.<0

....
00

121

122

get~lnteger := ans
END {GET_INTEGER}:

181

182
183

123
124

125
126
127
128
129
130
131
132
133
134
135
136
137

PROCEDURE add_one(nu~_left: integer: VAR
treept) :

~h:

alphabet: VAR tr:

189
190
191
192
t~,.

left := NIL;

138
139

140
141
142
143
144

145
146
147
148

149
150
151
152

153
154

155
156

157
158
159
160
161

162
163
164
165
166

167
168
169
170

BEGIN (ADO_ONE)
depth := depth t 1:
IF depth > max depth THEN
BEGIN
wrlteln(tty,
'Your file is not compatible with this programS'G'),
GOTO 13
END:
IF num_left = 0
THEN BEGIN tr·,. fruit := true;
tr·,. ch := kh END
ELSE
IF get_bit = 0
THEN
BEGIN
start(tr·,. left),
add_one(num_left - 1, kh, tr·,. lett)
END
ELSE
BEGIN
start{tr·,. rlqht)'
add_one(num_left - 1, kh, tr",. rlqht)
END,
depth := depth - 1
END UDD-ONE};

118
180

198
199

re~rlte(out_flleJ:

WHILE NOT done DO

convert(branch)

END (TRANSLATE):
FlEGIIl (RECALL}
N
wrtteln(tty,
N
'version :I of Recall (Not co~patable with version I)S'):
Init:
1epth:= 0;
flll_tree; ~
wrlteln(tty, 'In1tlallzing,'l;
tranSlate;
13:
~
wrlteln(tty, 'RecalUnq.'l;
VI
END (RECALL}.

""

-cD
00

add_one(qet_inteqer, I, branch)'

,.-u
'"m

PROCEDURE translate:
PROCEDURE convert(t: treept):

177
179

194

195
196
197

BEGIN (TRANSLATE)

save_tree := branch;

FOR 1 := mlnchar TO 127 DO
branch := save_tree
END (FILL_TREE),

172

174
115
116

193

=

BEGIN (FILL_TREE)

111
113

1115
1116
187
188

PROCEDURE start(VAR t: treept):
BEGIN
IF t = NIL THEN
BEGIN
new(t):
t"~ fruit := false:
to,. right := NIL
END
END (STARTt,

184

U' done
THEN ~rlteln(tty, 'WarningS Character mlsmatchS"G')
ELSE
IF get_bit
0
THEN convert(t·. left)
ELSE convert(t·. right)
END (CON VERTI:

BEGIN
IF to,. fruit
ELSE

THEN

write(out_flle, chr(t·, ch»

Articles
The Performance of Three CP/M-Based Pascal Translators

Thus we eliminate from consideration several "tiny" Pascal translators. among
others.

Mark Scott Johnson and Thomas O. Sidebottom
106 Mission Drive
Palo Alto. California 94303

Translators

1981 October
Abstract
The translation-time .md run-time performance of three CP/M-based
Pascal translators - Sorcim's Pascal/M. MT MicroSYSTEMS' Pascal/MT+, and
Ithaca InterSystems' Pascal/Z - are compared. Using a benchmark of eight
programs on a 4MHz Z80-based microprocessor. we find that Pascal/M excels
in translation time and that Pascal/Z excels in run time.
Pascal/MT+'s
translation time approaches that of Pascal/M for long programs.
Several
translator limitations are also illustrated by the benchmark.
Introduction
We
recently had the opportunity to
use and evaluate four
mlcropro .essor-based Pascal translators. We are reporting here the results of
one asped of this evaluation (namely. performance) for three of them.
The performance of a piece of software. such as a programming language
translator. is measured in terms of the amount of resources required by the
software to produce some useful result.
The primary resource we are
interested In is time. We measured both the time required to translate a
source program into a machine-executable form and the time required to
execute the translated program. The former is termed translation time and
the latter run time (or execution time).
The three Pascal translators we evaluated are Sorcim's Pascal/M.
MT MicroSYSTEMS' Pucal/MT+. and Ithaca InterSystems' Pascal/Z. All three
run under Digital Research's CP/M operating system. We also evaluated a
fourth translator. the UCSD Pascal system. which runs under its own
operating system. We have excluded UCSD Pascal from our report because we
do not feel a fair comparison of translator performance can be made across
operating systems. Separating the performance attributable to the operating
system from that attributable to the translator is a difficult task.
Other
translators beside these three run under CP/M. however. We limited the
study to translators that accept essentially the full Pascal programming
language and that are widely accessible to the general microcomputing public.

Copyright c 1981, Mark Scott Johnson and Thomas O. Sidebottom.
profit reproduction is permitted; all other rights are reserved.

Not-for-

To better understand the behavior of the three Pascal translators and to
better appreciate the performance results. we begin with a brief introduction
to translator construction. We use translator in the generic sense any
software system that accepts as input a program in one language (the source
language) and that produces as output a functionally equivalent program
written in another language (the object language). If the source language is
a high-level language such as Pascal and the object language is a low-level
language such as assembly language or machine language. then the translator
is called a compiler. If both the source and the object languages are lowlevel. then the translator is called an assembler. If the object language is
not the machine language of some real machine. it becomes necessary to
execute the object code with an interpreter. which simulates the object
language on a real computer.
Compilers that translate source programs directly into object programs
are called one-pass compilers. Sometimes compilers are written to perform
one or more intermediate transformations between source and object; these are
called multi-pass compilers. Multi-pass compilers generally take longer than
one-pass compilers. but they often require ·Iess 'llain memory, compile longer
source programs, provide more complete diagnostics. and generate better
object code. To conserve main memory (and again to increase the size of
source programs that can be translated), multi-pass compilers often write out
their intermediate transformations to temporary disk files.
We used version 3.19 of the Pascal/M translator. It is patterned after
the UCSD Pascal system. comprising two components: a compiler that
translates a Pascal source program into P-code - object code for a fictitious.
Pascal-like P-machine - and an interpreter for the P-machine. It is a onepass compiler written in Pascal. For short and moderately-sized programs the
compiler uses no memory overlays. but long programs require swapping from
the disk of segments of the compiler. It runs in 56K of main memory and
requires no temporary files. The output from the compiler is a file containing
P-code instructions, which is input to the p.-machine interpreter.
For
compactness and efficiency. the interpreter is written in the assembly
language of the host computer (a Zilog Z80, in our case).
We used version 5.2 of the Pascal/MT+ translator. It is a true compiler
that generates object code for any of several microprocessors. including the
Z80. It is a three-pass compiler written in Pascal: the first pass converts a
source program into a sequence of logically related characters called tokens.
the second pass builds a symbol table. and the third pass generates object
code and places it in a Microsoft-format. relocatable object file. The compiler
runs in 56K of main memory. using five memory overlays. and it uses one
temporary file for the tokens.

."

»

'"'"

V'1

o

We used version 3.2 of the PascallZ translator. It is also a compiler,
but it generates an assembly-language program a'S its output. This assembly
language requires a special assembler that is supplied with the translator,
which can only generate zao object code. PascallZ is a one-pass compiler
written in Pascal.
It requires 56K of main memory (although 64K is
recommended), using one memory overlay, and it requires no temporary files.
Benchmark
To adequately compare performance, we needed a benchmark - a point
.of reference for our . measurements.
A benchmark for a translator is a
collection of source programs, written in the language the translator
understands, that exercises various aspects of the translator's capabilities.
Such benchmarks generally include short programs, long programs, and
programs that stretch the limits of the translator, such as programs with
deeply nested control structures or large data storage requirements.
The
idea is to include a mix of programs that are representative of the programs
that the translator will encounter in normal, everyday use.
Rather than develop our own benchmark from scratch, we relied heavily
on the work of others.
In particular, seven of the eight programs in our
benchmark were adapted from a performance study of the CDC 6400 Pascal
translator running under the SCOPE 3.4 operating system, made several years
ago by Niklaus Wirth, the designer of Pascal. We restricted our adaptations
exclusively to the removal of implementation-dependent features, such as the
presence of a hardware clock on the CDC 6400 and the maximum size of
integers and reals.
It is important to note that we made no other
modifications to these programs. Several of them would not compile under one
of the translators. We probably could have modified these programs to make
them compilable. We opted instead to let our evaluation rest on a translatorindependent benchmark.
The first benchmark is a 47-line program to compute the first 90 positive
and negative powers of 2. The algorithm uses integer arithmetic exclusively,
including multiplication and division. No standard Pascal functions (such as
SQRT) are used, and arbitrary precision is simulated by storing each digit of
the result separately in the elements of an array. "Powers of Two" is a
useful benchmark since it heavily exercises integer arithmetic.
The second benchmark is a 4J-line program to sort a 10,000-element
array of arbitrary integers into ascending order. The sorting algorithm is
called Quicksort, which relies extensively on a recursive procedure.
The
maximum depth of recursion is In (10,000)=10. "Quicksort" is useful since it
exercises recursion and array manipulation.

The third benchmark is a 32-line program to write and to read a file
containing 1000 real numbers. First the numbers are written out, one per
record, to a file. Then the file is reset and the numbers are read back in.
The numbers are stored in internal format (that is, not in human readable

form); no input/output conversions are performed.
it exercises "naked" file handling.

"Real 10" is useful since

The fourth benchmark is a 51-line program to solve the "eight queens"
problem. The problem is to find the 92 configurations of eight queens on a
chessboard such that no queen attacks another queen. The algorithm uses
backtracking and recursion to exhaustively try all plausible chessboard
positions.
"Eight Queens" is useful since it heavily exercises iterative
constructs such as for-loops and if-then-else statements, together with simple
but repetitive array manipulation.
The fifth benchmark is a 47-line program to compute the first 1000 prime
numbers. "Primes" uses essentially the same language features as Powers of
Two, but involves more computations.
The sixth benchmark is a 29-line program to compute the ancestors of a
group of individuals, given their parents. It uses a looxloo-element Boolean
matrix to represent the individuals and the parentloffspring relationships
among them. "Ancestor I" is useful since it contains deeply nested control
constructs and two-dimensional arrays, and thus exercises these aspects of a
translator's capacity.
The seventh benchmark is a reimplementation of the previous one, using
a 100-element Pascal set in place of a Boolean matrix. "Ancestor 2" is useful
for comparing the performance of the implementation of sets.
The last benchmark is a 280-line program we wrote to compute the
position of the moon at a given time and date. The program uses nine real
arrays indexed by enumerated types, two record types, ten internal
functions, and five internal procedures. Most of the functions are one-line
long, and do such things as calculate the trigonometric functions in degrees
and convert to and from radians and degrees. "Moon Position" is a useful
benchmark since it heavily exercises real arithmetic and the compiler's
capacity to handle moderately long programs.
Hardware
All of our benchmark programs were run on NorthStar Horizons,
containing 4MHz ZSO microprocessors, 56K of main memory, and two doubledensity, single-sided 5-1/4-inch Shugart SA400 floppy disk drives. Although
some of the manufacturers claim their translators will operate on smaller
systems, we believe our system is the minimum configuration

required

for

reasonable response and minimal frustration. All three translators were run
under CP/M 2.2, using the NorthStar version distributed by Lifeboat
Associates.

,.

"0

'"rn

'"

I-'

Methods
For each translator we first verified that each of the benchmark
programs produced the correct results. We then removed all statements that
wrote to the terminal screen, except for a WRITELN at the beginning of each
program that wrote "GO" and a WRITELN at the end of each that wrote
"STOP". We did not use these output messages for our measurements; they
were merely to give us feedback that something was happening.
To
guarantee comparable run-time statistics, we compiled each program with all
error checking, such as range checking and 10 failure detection, disabled.
Because NorthStar Horizons are not equipped with hardware clocks, all
timing measurements were made using a stopwatch.

We timed each separate

step (compile, assemble, link, and run) by typing the appropriate CPIM
command line, waiting for the disk drives to stop spinning, and then
simultaneously. hitting the RETURN key and the start button on the
stopwatch.
We stopped the watch when the next CPIM command prompt
("A>") appeared. Thus all of our measurements include the time required by
CPIM to process the command line, to locate and load the appropriate software
into memory, and to prompt for the next command. This method does not
measure the "bare bones" performance of the three Pascal translators and the
object code that they produce. Nevertheless, we believe that it reflects the
typical user's interactions, and thus the method accurately measures the
performance that such users can expect for themselves.
Several of the measurements were taken twice to check for timing
variance. In no case did the times differ by more than 0.3 seconds, which
we attributed to variations in controlling the stopwatch. Thus the variance
appeared insignificant.

code per minute for the short programs, but rose to 70 lines per minute for
the long program. Total translation time was about 25 lines per minute for
the short programs and 56 lines per minute for Moon Position.
Two of the programs would not compile under PascaliZ (Table 3). Both
had control structures too deeply nested (about eight levels) for the compiler
to handle.
PascallZ's compile time is only about one-third longer than
PascallM's and about twice as fast as PascaliMT+'s for short programs
(approximately 65 lines per minute).
But the extra assembly step "equired
takes up to twice as long as the compile time. Table 4 shows that the overall
translation time of PascaliZ is three to four times slower than PascallM and
ranges from about 25% to 200% slower than PascaIiMT+. Translation time for
long programs decreased slightly (25 lines per minute as opposed to 20 lines
per minute). Nevertheless, PascaliZ consistently produced faster code than
did PascaI/MT+, ranging from about 1000 to 150% faster.
Conclusions
For applications that require frequent compilation but infrequent
execution, or where run-time speed is unimportant, PascallM is a good
choice.
PascallZ is the best alternative when run-time performance is paramount
and your code only needs to run on Z80s.
But be prepared for
excruciatingly slow translation time, especially on long programs. Also be
prepared to restructure your programs to get them to compile, especially if
your system has less than 64K of main memory.
Pascal/MT+ lies somewhere between these extremes. Translation time is
slow, but the relative speed (that is, lines of code per minute) improves

Results

significantly as program size increases.

Tables 1 thru 3 show the results of translating and executing the
benchmark programs with each of the three translators. Each column in the
tables represents one CPIM command. Tables 4 and 5 summarize the results
of the first three tables. In Table 4 translation time is computed as the sum
of all the steps necessary to make the object programs executable.
Table 1 shows that Real 10 would not compile under PascaliM.
does not support the READ and WRITE procedures on the type
REAL.
As expected with an interpreter-based system, PascallM
quickly, but interpretation of the P-code is slow. Compile time
approximately 80 lines of source code per minute, even with long
such as Moon Position.

PascaliM
FILE OF
compiles
remained
programs

Pascal/MT+ successfully compiled all the benchmark programs (Table 2).
Compilations are typically up to three times longer than with PascallM; total
translation time is up to four times longer. Nevertheless, run time ranges
from about 30% to 200% faster.
Compile time was approximately 30 lines of

Similarly,

run time is much better

than PascaliM, but not as good as PascallZ for most programs.
Run-time
performance for the two recursive benchmarks, Quicksort and Eight Queens,
was relatively poorer than for the nonrecursive benchmarks.
We conclude with a strong admonition. We have reported here only one
aspect of comparison between the three translators, namely time performance.
There are many other aspects that must be considered when deciding on a
translator to suit your own needs, such as robustness, documentation,
support, language extensions, error handling, size of object code, and ease
of use.
For example, in applications where reentrant code is important,
PascaliZ is the only alternative of the three. We decided on Pascal/MT+ for
our own applications, primarily because of the language extensions it provides
(it is the most complete systems implementation language of the three) and its
robustness (we seldom have to massage our code to get it to compile).

-0

»

'"rn
U1

N

Acknowledgements

Program

We extend our thanks to Dionex Corporation,
Hewlett-Packard
Laboratories, and Pluto Research Group for access to their computers and
other resources during this study.

Powers of Two
Quicksort
Real 10
Eight Queens

Compile Time

Primes

Program

Compile Time

Powers of Two
Quicksort
Real 10
Eight Queens
Primes
Ancestor 1
Ancestor 2
Moon Position

34.6
32.3
unsuccessful
36.1
33.9
32.3
31.5
3:30.3

Run Time

41.8
3:34.6

Compile Time

5:02.8
1 :13.8
1:51.3
43.4
17.4

Program

Lines

Powers of Two
Quicksort
Real 10
Eight Queens

Link Time

Run Time

Ancestor 1
Ancestor 2
Moon Position

Moon Pos ition

1 :31.3
1 :30.7
1 :26.0
1 :32.8
1 :31. 6
1 :30.5
1:28.3
3:59.5

8.9
1 :05.5
20.9
53.4

N/A
N/A
1 :03.2
6:06.5

46.3
1 :42.1

19.0
10.5

N/A
N/A

N/A

Table 3: Pascal/Z Timing Results (in minutes and seconds).

Primes

Powers of Two
Quicksort
Real 10
Eight Queens
Primes
Ancestor 1
Ancestor 2

Run Time

46.8
48.6
56.1
49.7
N/A

N/A

Table 1: Pascal/M Timing Results (in minutes and seconds) .

Program

Link Time

58.0
59.3
58.9
1 :04.0

unsuccessful
unsuccessful

Ancestor 1
Ancestor 2
Moon Position

29.5
5:23.0

Assembly Time

44.8
43.3
38.3
48.0

30.4
39.0
38.7
30.9
30.3
33.6
31.5
53.2

9.6
2:47.6
37.0
2:30.5
11.6
24.9
23.8
12.8

Table 2: PascallMT+ Timing Results (in minutes and seconds).

47
43
32
51
47
29
29
280

Pascal/M
34.6
32.3

N/A

36.1
33.9
32.3
31.5
3:30.3

Pascal/MT+

Pascal/Z

2:01. 7
2:09.7
2:04.7
2:03.7
2:01.9
2:04.1
1 :59.8
4:52.7

2:29.6
2:31.2
2:33.3
2:41.7

N/A
N/A

2:31.3
1 :23.2

Table 4: Summary of Translation-Time Results (in minutes and seconds).

Program

Powers of Two
Quicksort
Real 10
Eight Queens
Primes

Ancestor 1
Ancestor 2
Moon Position

Pascal/M

Pascal/MT+

Pascal/Z

29.5
5:23.0

9.6
2:47.6
37.0
2:30.5
11.6
24.9
23.8
12.8

8.9
1 :05.5
20.9
53.4

N/A

5:02.8
1:13.8
1 :51.3
43.4
17.4

N/A
N/A
19.0
10.5

Table 5: Summary of Run-Time Results (in minutes and seconds).

""0

J>
CO>

m

***********************

MACALESTER COLLEGE
1600 GRAND AVENUE
SAINT PAUL, MINNESOTA 55105
612-696-6000

A Geographer Teaches Pascal -- Reflections on the Experience

October 7,

1981

Macalester College, a small (1700 students), liberal arts institution
located in St. Paul, Minnesota, recently initiated a new major in Computer
Studies. Several courses in programming have been offered over the years
but increased student demand for a wider range of offerings and faculty
recognition that a full and complete program would be necessary in order
for us to keep pace with the rapidly growing field of computer science
necessitated this significant change.

Mr. Riek Show
Pascal Users Group
P.O. Box 888524
Atlanta, Georgia 30338
Dear Mr. Shaw:
The enclosed article reports my reactions and those of my students to the first Poscal
programming course that.1 taught •• I am fairly n:~ to the field of computer science
and this particular teachIng experience was excIting to say the least.
I hope this short piece will prove to be af interest to you and your readers.

Sincerely,

~~PitZI

Associate Professor

GRP:ba

Encl.

Jerry Pitzl
Macalester College
St. Paul, Minnesota

As a further enhancement to the computer program, Macalester College,
in 1979, became the recipient of a National Science Foundation grant to be
used to expand the use of computers within science laboratory settings.
Initial
purchases of hardware included three DEC MINC-ll computers
especially configured for laboratory applications.
In addition, the
departments of geography, of which I am a member, and geology received a
Magnavox S-4 Orion stand-alone graphics system, a 22" x 22" Talos S622
digitizer, and a 300 LPM Printronix Printer/Plotter. The graphics system
is used primarily within the geography department in a computer mapping
course.
Dul"ing the academic year 1979-80 I was on a sabbatical leave and spent
virtually all my time at the University of Minnesota auditing courses in a
variety of computer and mathematics related areas.
I had no prior
knowledge of computer languages, but I knew that I would have to become
familiarized as quickly as possible because I was slated to do the computer
mapping course. Needless to say, the transition to the "kind of thinking"
required for success in the computer field did not come that easily for me
a t first;
my long-term background, primarily in the humanistic realms of
geography, had produced a "mind set" that was placed in a mild form of
intellectual shock at first exposure to computer operations, and this
condition perSisted for at least the first few weeks.
Fortunately, however, my intrOduction to computer programming was
through the Pascal language.
I found the language to be logically
constructed and relatively easy to use. The form of program development
using algorithm formulation and structure provided an ideal transition to
the eventual writing of actual Pascal code. I soon became unequivocally
"hooked" on Pascal.
So much so that in the following year I set out to
develop a course in programming with Pascal which was introduced during our
January "interim" session of 1981. Interim is a one-month period in which
courses not available in the regular semesters are given.
It is a good
time to introduce and test a topic or theme which may later become a
regular curricular offering. In our case, Pascal was not a new topic on
campus;
it is being taught along with other languages in a one-semester
course. However, I felt that the language should receive a great deal more
emphasis and perhaps eventually be the sole subject of a full semester. It
is, as most agree, the most appropriate language for" teaching the concepts
of structured programming.

--- There were no "no's" ---

The interim course contained 20 students, half

of

whom

had

varying

degrees of experience with computer science and the rest with no Axperience
whatever.. The four-week time frame with tWo-hour sessions five days a week
left little free time for either the students or the instructor~ \"e

covered all aspects of the language including a brief introduction

to

the

use of records, 9xterna1 files and the pointer.
The students prbduced eight programs of varying difficulty and took
four quizzes.
The assigned readings came from Schneider, Weingart, and

Perlman, Introduction to lr.:og.ramming and Probl~ Solvi~ with P~cal, a
widely used and thorough introduction to the language.
As an added
feature, G. Michael Schneider, one of the authors of the text, visited the
class and gave us a most stimulating presentation.
As a final exercise in the course, the students were asked to complete

a critique of the experience. Some of the questions asked and a sampling
of the responses are presented here:
Item No.

1--Did you know a programming language before this course?

a. I f yes, how would you compare Pascal to the language( s) you already
know?
Responses:
requires new ways of thinking ••• about flow of
control; most flexible language I know;
much prettier ••• easy to
use and efficient once the bad habits of needing the "go to"
sta tement are broken; easier to understand than COBOL or FORTRAN;
more high-powered than BASIC and more structured; more can be done
with Pascal; more ways to approach a problem; compared to BASIC,
Pascal is much more fun;
more closely related to the English
language.
b. I f no, did you find that Pascal provided a meaningful introduction
to programming?
If yes, why? If no, why not? Responses: Yes, I
think the structure is important; yes, it provides the basis for a
new way of thinking;
yes, good intro to the computer and how i t
works; yes, judging from the experiences of those in the terminal
room using other languages, i t seems that Pascal is the best
language for understanding programming; yes, it is easy to work
with; yes, Pascal has provided me with a meaningful introduction to
programming; yes, it is easy to read a program ••• and the language
is interesting;
yes, Pascal was a good introduction in that I
learned that programming is mostly paperwork bef2re hand.
Item No. 7--Do you think that Pascal should be offered as a full, regular
semester course? If yes, please state why; i f no, please state why not.
Responses: Yes-- interesting, powerful; important for computer stUdies
majors.;
good for structured programming; i t is a relatively new language
and computer studies majors should know it;
i t is the direction that
oomputer languages will go; best for general purpose computing; becoming
more widely accepted and used; valuable course for learning many aspects
of co~uter science;
better for beginners -- neat, beautiful language;
more hme needed than is available during interim; '1ersatility and uses of
the language are great; better to learn as a "first" language· a "fun"
language; a "logical n language; '1ery powerful.
'

Item No. 9--Do you think that you will choose to use Pascal in the
if YOLl write computer programs?

future

--- All yes's

How would you ra te our guest lecturer, Professor Schneider?
Responses: good, 9xcellent; interesting; informative; amusing; a good
prospect for a Mac prof; I3xcellent; very knowledgeable; knows his stuff;
great future; lTery good; great -- too bad we cant t be assured of having
him here; great teacher; 8 on a scale of 10; excellent; he really knows
his stuff; excellent; 10 of 10; great; great guy;
really knows what
he's doingj liked him; slick and intelligent guy; fantastic; sparked my
interest in computer science; the high point of the class; he is like the
pointer -- dynamic.
Final Item--General comments.
Responses: best interim course ever taken; more challenging than BASIC;
impressive language;
I now have an understanding and a respect for
computers; revived my ability to concentrate for extended periods of time;
computers -- "it's rather amazing, isn't it?"
As the responses clearly suggest, the entire class was more than
satisfied with the course and unanimous in their assessment of Pascal as a
sound and usable programming language. It would be sheer understatement on

my part to say that I was pleased with the outcome. I was ecstatic! The
course is scheduled for the interim term of 1982 and the Pascal language
offering during the regular semester will be expanded within the existing
course framework.

I conclude with a plea to all who are in an academic setting to
encourage the expanded offering of Pascal as the most appropriate language
to use for introducing programming. I believe this to be true not only for
students, but for others (faculty and staff) who are being tasked to climb
aboard the expanding computer applications wave that apparently is nowhere
near cresting.

***************

">-

'"'"

money management systems. inc.
30S wyman.-.., • waltlhem. ~_t1:B • 02154
(817) BSO-2070

An Extension that Solves Four Problems
by Jonathan A. Yavner
1.

Yet Another Extension

This conversion problem is actually a special case of a more
basic difficulty which has received occasional mention in this journal
(though I can't find the references). Programming generality can
be promoted by avoidi.ng an either/or choice for main versus peripheral
memory storage of f11es. In one of the references which I can't find,
IBM's 48-bit unified addre.ssing scheme is given as an example of where
the capability to code storage-Iocation-independent routines's
provided to the assembly programmer.

The Dynamic Array.

The specification of dynamic arrays is currently a point of heated
discussion among Pascal theorists. Pascal News 119 (la~eled "17")
contains eleven doubie-density pages'()1 de'bateonthe merits <)f the
p~oposal contained in the DP 7185.1 standard.
The most telling
argument against the Sale syntax is the assertion that it is not
intuitively obvious and therefore does not belong in a language whose
users consider it the guardian of rational programming. ~he poin~
is substantiated by the sheer prolixity of the bombast on the sub;ect
that has been published in PN, shouted across standards-committee
conference tables, or otll.erwise made public.
If the dynamic array
really belongs in Pascal--and is not present because certain vociferous
fanatics chanting ·Stamp out the FORTRAN dinosaur!" want to maKe Pascal
able to do everything FORTRAN can and don't care if Pascal becomes
FORTRAN in the process--there has to be a better way.
2.

8-Sep-Sl

Memory-resident Format.Conversion.

I wonder about those fanatics, though. My company produces
financial database-management systems, for which one would think Pascal
an ideal language, given its da ta-secur i ty emphasis •. However, such
programming requires certain features commonly available in FORTRAN
and BASIC which are difficult to simulate in Pascal. Such a feature
is memory-resident for;nat conversion.
In most high-level languages,
format conversion i~ performed as an integral part of I/O. Sometimes
it is necessary to Perform such conversion in memory, perhaps to add
commas before output or to delete them after input. For these
occasions FORTRAN provides its ENCODE and DECODE s ta tements. BASIC
implementations tend to have two or more string functions (with different names and formats for each implementation) to perform these
conversions.
I hear no fanatic-talk about adding these features to
Pascal, yet the only way to force Pascal to perform non-I/O conversion
is to declare an external procedure and then attach it to the appropriate routine in the run-time-library using some sort of aliasing
mechanism--an extremely implementation-dependent method.
If the
implementation doesn't support external procedures or doesn't list
the names of its library routines or doesn't allow them to be called
by the user, the program must contain a source-code duplicate of the
conversion routine--an extremely inefficient metr:od.

Anyone who uses a version of BASIC (among others) that has a
garbage collector becomes addicted to strings and finds Pascal and
FORTRAN irritatingly restrictive. LiKe its close relative the dynamic
array, there seems to be no obvious method of specifying string definition and manipulation.

Pascal can be implemented on any computer with at least a processor and two magtapes. Such a computer is incapable of random-access
I/O. For this reason no mention of such I/O appears in the standard.
For this reason each of the vast majority of implementations which
can supply random access has implemented incompatible extensions to
provide this capability. The standard would be superior if there
were some way to specify the format of such operations without either
requiring them of all implementations or layering the standard. Use
of a layered standard to define a language which includes intuitive
obviousness among its design goals is a paradox.
~The S~~ion.

The solution to the problems delineated above lies in the realization that dynamic arrays, strings, and files are but different
facets of the same data structure. Simply extending slightly the
definition of the file structure would allow files to perform the
duties of strings and dynamic arrays. To avoid actually implementing
garbage collection, files could be allocated in segments on the heap,
each segment containing x sequences of the file and a pointer to the

next segment, where x is determined from the equation
x=((nice segment size)-(pointer size» DIV (sequence size).
Deletions from the standar.d: All references to comformant arrays,
comformant array schemata, and compliance levels.
~~~':..~

f.M has the
exists an
the file.
the values

the standard, 6.4~2.~1!.~~~L:.. The file element
enumerated values (Generat~on, Inspect10n, Direct). There
element f.Len whose value is the number of sequences in
The notation f[n] denotes the nth sequence of the file;
for n are 0 •• (f.Len-l). There exists an element f.Pos,

-c

»

Gl

m

V1
0">

8-5ep-81

Yet Another Extension

whose value is such that f.R.first=f[f.Pos).
F.Pos shall be equal
to f.Len if f.R=5{).
Rule (b), describing the structure of a file
of type text in Generation mode, shall apply also for Direct mode.
Changes to the standard, 6.6.5.2 (file-handling_procedures):
get(f): If fO.M=Direct,
pre-assertions:
fO.L is defined
fO.R<>5 ()
post-assertions:
f.M=fO.M
f.Len=fO.Len
f.Pos=fO.Pos+l
f.L=fO.L-fO.R.first
f.R=fO.R.rest
I f f .R<>5 ()
ft=f.R.first
otherwise
ft is undefined
put(f): If fO.M=Direct,
pre-assertion:
fO.R, fO.L, and fOt are defined
post-assertions:
f.M=fO.M
f.Pos=fO.Pos+l
f.L=fO.L-5(fOt)
f.R=fO.R.rest
I f fO.R=5 () ,
f.Len=fO.Len+l
otherwise
f.Len=fO.Len
I f f .R<>5 ()
ft=f.R.first
otherwise
ft is undefined
Additions to the standard, 6.6.5.2:
init(f)
pre-assertion:
true
post-assertions:
f.M=Direct
f .L=f .R=S ()
ft is undefined
f.Len=f.Pos=O
seek(f,p)
pre-assertions:
fO.L and fO.R are defined
fO.M IN [Direct)+seekmodes
p IN [O •• fO.Len)

8-5ep-8l

Yet Another Extension

post-assertions:
f.M=fO.M
f. Len=fO. Len
LPos=p
f.L=f[O)-f[l)-f[2)- ••• -f[p-l)
f.R=f[p]-f[p+l)- ••• -f[f.Len-l)
if L R<>S ()
f1'=feR.first
otherwise
ft is undefined

-c
):>

en

n

):>

r(f.L=S() if p=O)
(LR=S() i f p=LLen)

z:
rn
x:
en

The implementation-defined set seekmodes shall be equivalent
to the set of values for f.M other than Direct for which see~ snaIl
be valid.
The procedures d(f,p,vl,v2, ••• ,vn), where  shall
be replacable by any of (read, write, readln, writeln), shall be
equivalent to
begin seek (f ,p);  (f ,vl,v2, ••• ,vn) end.
Addit!2ns to the ste.ndard,

en
rn

§..6.5:.~-.i£rdin~~~;:cctions):

length(f) The function shall return the value of the element f.Len
of file f; the set of values for f.M other than Direct for
which f.Len is defined shall be implementation-defoned.
pos(f)

The function shall return the value of the element f.POE
of file f; the set of values for f.M other than ~irect for
which f.Pos is defined shall be implemen~atio~-defined~

-c

......
en

:3

""

rn

'"

,....
<.D
00

,....

~~~ample Progr~~

This program fragment uses many facets of the extension outlined
above.
It has not been parsed, since currently there ~s no proce£sor
which accepts the extension.
It is asserted t~at one of ?ascal s
greatest strengths lies in its ab- ~ty to make this kin~ of generalpurpose program reasonably port ·:Le. comments would be a~p!:ecia'.:.ed,
as it is conceivable that I mai'" inl ,.ict upon the world a Pascal processor with this extension unless either I am drowne~ in a sea of
hate mail or the proposal ceases to be an extens"on.
l

-0

>

program

Money~arketIII

const
24;
ScreenHeight
ScreenWidth
79;
MaxField
32;
MaxScale
9;
type
Whole
O•. MaxInt;
Short
-32768 •• 32767;

(input,outP'lt) ;

'"'"

8-Sep-81

Yet Another Extension

Byte
0 •• 255;
SHlndex
1 •• ScreenHeight;
= 1 •• ScreenWidth;
SWIndex
Scale Index
-MaxSca1e •• MaxScale;
( A,B1,B2,B4,D,X );
FieldTypes
TableTypes
( Contro1,FieldDesc );
:: packed record
Date
year
1901.. 2l00;
month
1 •• 12;
day
1. .31;
end;
TypeCross = packed record { All implementation-dependent trickery
goes through this type, thus isolating the programming changes
necessary to move to a new processor. }
case FieldTypes ot
A :( aval
Real);
Bl :( blval
Byte);
B2 :( b2val
Short);
B4 : (b4val
Integer);
D :( dval
Date);
X : (xval
packed array [1. .MaxField] of Byte );
end;

TableRec
packed record
case rectype:TableTypes of
Control
:( { Control record for each data file)
name: packed array[1..8] of Char;
fd
: Whole { Pointer to first field descriptor };
nent : Short { Number of field descriptor entries };

Yet Another Extension

8-Sep-81
scale
leng

Sca2.e~ndexi

Byte

t

This semicolon is illegall

-)0

"

»

!;

U)

n

) ;

»

rz

var
temp

Text;

nonrcac,x

Whole:

."
:0::

en

abscale
O .• MaxScale i
comma
0 •• 2:
begin
abscale:=abs(scale) ( Number of implied fractional disits } ;
ini~(output) i

write{output,exp(ln{abs(input)}-ab 9 cale*lnlO) :l:abscale};
nonfrac:=length(output)-abscale-l i Non-fractional digits

comma:=(nonfrac-l) MOD 3;
ini t (temp)

""

N
N

...

""
""

N

};

i

seek (output,O) ;
for x:=l to nonfrac do begin
write (temp,outputi) ;
get (output) ;
if comma>O then comma:=cow~a-l else begin
if x<>nonfrac then write(temp,' ,f) i

en

."
-0
-I

comma:=2;
end;
end;

,..,

:3

""

if scale1 0' :
if outputj<>'.'

then begin

seek(output,nonfrac) ;
for x:=nonfrac to x do begin

write (ternp,outputt) ;
get (output) ;
end;
end;

end
else if scale>O then while NOT eof(output) do begin
write (temp,outputj) ;
get (output) ;

i, J e~a:
Dat:afile ,
packed file of Byte;
TableFile = file of TableRec;
var
filcon : TableRec { File control record };
table : /i'ableFile;
data
: DataFile;
filnum ,: Byte { Data-file number };
page
Byte;
lnl0
Real;

( Space should be recovered here
x:=leng-length(temp)-ord(input then write (output,' ':x);
if .input' , OR pos(temp)=O;
i f temPi=' , then goto 1; Xl= l"""(teM~); seek.(te.NP)o
for ><:=1 to x do begin
}
write (output,tempi) ;
get(temp);
end;

1

1:
writeln(output) ;

end;
end;
procedure FillScreen( { Format and print a record}
var output
: Text;
var table
: TableFile { Possibly peripheral; so what? };
var data
: DataFile { Almost certainly peripheral; requires
that seek() be allowed on files which are associated with an
external storage device and are in Inspection mode. }
var tab1entry
TableRec;
page
: Byte;
) ;

Text;
Whole;
TypeCross;

to be assignment-compatible would create an

ambig~~~y

either of whose resolutions contains a paradox.
Oh well, such
are the breaks • • •
I
begin
seek (output,y*30+x) { Note that an end-of-line, in conformance

to tne standard, is assumed to occupy one sequence in the
file.
Some ASCII computers use the old-fashioned chr(13)chr (10) terminator instead of the ANSI-standard chr (10).
Some computers have weird character sets that require escapes
to enable certain subsets. Many EBCDIC computers derive eoln
from (file-position MOD record-length).
Such diffic~lties
may force some implementations to prohibit the use of seek()
on externally-associated textfiles and to use special-case
Direct-mod'e-only code in all the file-hand-ling procedures
to produce extra-wide characters with special b:.ts to indicate
prefixes.
Ugh.
As I have suggested, my extension simplifies
the programmer's job at the expense 0'£ creating dQuble the workload for the run-time library.
But anyone Efraid of a little
inefficiency should use an assembler--or a bett.er. com,9uter!};
reset (input) ;
while NOT eof(input) do begin
write (output,inputtl ;
get(input);
end;
end;
begin { FillScreen
ini t (screen) ;
for i:=l to ScreenHeight do writeln(screen,' • :Screenwidth);
base:=pos(data) { Assume data file already positioned };
with tablentry, convert do begin
seek(table,fd) ;
for i:=l to nent do begin
with tablet do if p=page then begin
seek(data,base+loc);
for j:=l to leng do read(data,xval[j]);
for j:=leng+l to MaxField do xval[j] :=' *'
case ft of
A
Format(field,aval,af,vl);
Bl
Format(field,blval,O,vl);
B2
Format(field,b2val,0,vl);
B4
Format(field,b4val,0,vl);
D
FormatDate(field,dval);

....cD
00
....

-0

:>
G'I

rn
V1

cD

8-Sep-81

Yet Another Extension
x

write(field,xval:vl);

end;

Posit(screen,field,vx,vy);
init(field);
write(field,name:nl,' (' ,fx:l,')');
Posit(screen,field,nx,ny);
end:
get (table) ;
end:
end;

Dump(output,screen);
end;
begin { MoneyMarketIII }
InlO:=ln(10.0);
{ Determine filnum }
dread(table,filnum,filcon);
connect (data,filcon.name) " external is standard, w'r•.i not connect? }:
reset(data) { Requires random-I/O ability in run-time environment );
{ Po"j.tion datafile and determine page}
FiIIScreen(output,table,data,filnum,page,ScreenHeight,ScreenWidth);
{ Other processing }
end.
~!:~~t:.~inU~!l~

The main point of this essay (whenever it pretended to have one)
has been that Pascal has always had string-handling ability and that
the addition of a few functions could provide enough improvement to
obviate any need for a heavyweight boxing match to decide which dynamic
array description method should be used. However, the example program
is in many ways redundant, since the same kinds of code sequences
appear repeatedly. For this reason the following suggested list of
string functions i8 proposed.
Implementing them in assembly would
remove the restriction that the files must be of a specific type.
The "type" File, as used below, reflects this generic capability,
available only to intrinsic procedures.
procedure Append(var output,input:File);
begin
reset(input) ;
while NOT eof(input) do begin
write(output,inputt);
get(input);
endi
t:!nd;

procedure Copy (var output,input:File);
begin
i.nit(output);
Append(output,input);
end;

8-Sep-Sl

Yet Another Extension

procedure Posit{var output,input:File; sequence: Integer) :
begin
seek(output,sequence);
Append(output,input):
end;

procedure Switch(vat output,input:File):
begi"
Copy {output, input) ;
init(input) ! Actually, since the internal pointers are being
switched, the input file would be left undefined (closed). }

,..
"0

,..nen
rz:
m
20
en

end;

procedure Extract(var input,output:File; loc,leng:Integer);
var x:lntegeri
begin
seek(input,loc) ;
init(output):
for x:=l to leng do begin
write(output,inputt);
get (input) ;
end;
end;

procedure Insert(var output,input:File; sequence: Integer) ;
var
temp: File;
x
: Integer:
begin
Extract (output,temp,O,sequence) ;
Append(temp,input);
while NOT eof(output) do begin
write(temp,outputt);
get (output) ;

...
...

rightt then Compare:=1+2*ord(lefttGl

m

Three RIvers
Computer CoIporotIon

195 Farmington Avenue
Form;ngtof\ Connecticut 06032
203/674-8367

TRW
September 24, 1981
October 28, 1981
Pasca 1 User Group
P. O. Box 888524
At 1anta, GA 30338
Attn:

""
N

Pascal User's Group
P.O. Box 4406
Allentown, PA 18170

Rick Shaw

N

to

""
N

Vol

RE:

Rush Request for Software Package Information

Dear Rick,

Dear Sir or Madame:

It was good talking with you last night. I would appreciate you
placing the following text in your newsletter:

I have the responsibility of identifying "all" of the. available software
products and packages written in PASCAL. As you are aware, this is a very
large task, and I have a very short time to acquire as much information as
possib1e--about two weeks.

We would appreciate contact from anyone utilizing Pascal under
a VAX/VMS. We are specifically interested in the run-time
effi ci ency of executable code. Any other comments woul d be
appreci ated. PI ease Contact:
Jim Corrigan
TRW, Inc.
5205 Leesburg Pk. (Suite 1106)
Fa 11 s Church, VA 22041
(703) 931-2017

Thanks again, Rick.

I need your help, and the help of as many people as you can contact. There
is a benefit to at least some respondents. As you may know, our company
produces a high-speed unshared computer (PERQ) which is a Pascal-based
machine. We are looking for purchase, contract, OEM, third party and
contributed or public domain applications and any other Pascal software.
We will be negotiating distribution and license agreements il1l11ediately
with qual ified software sources.
Can you please assist me by: I) forwarding any present compilations
or catalogues you have of available software, to me immediately; 2) passing
on this request to any other appropriate parties, by phone, if possible.

en
,..,
....
,..,
,..,
"",.,

."

3

....
....
<0

00

I greatly appreciate any information you can provide. Please feel free to
contact me anytime at (203) 674-8367. Thank you. I shall look forward to
hearing from you.

Yours truly,
."

»

GEB/cao

en

m

en
V1

JSC/dm

DEFENSE AND SPACE SYSTEMS GROUP OF TRW INC

SKYUHf O""'C£' 5205 LEESBURG PIKE. SUITE 1106, FALLS CHURCH, VIRGINIA 22041. (103) 931-2010,931-2017

~~1

~; Coulter Electronics. Inc.
Council for Educational Teclmology

GEI'tERAL OFFICE" 590 WEST 20111 STREET "1fIALEAH. Fl33010 •. ~HONE: 30H85-0131

.. Devonshift Street, London W'lN 2-BA T.,...,: 01·'636 4186 Ch4inn4,.: P_rofessor J C -West,

MrN Huf/tes
:SheU andte 1

CBE

Di,"wr: G Hubbard

The Burl ei gh Centre
Wellfield Road
HATFlfLD
Herts. AlIO OBZ
Tel: Jlatfield 74497

WALI.S

Shet land ZEZ 9PF
3rd December 1981

=
,...,

:c
en

PASCAL IJSEF:S GROIJP
C/O RICI( SHAW
BOX BB52'!

ATLANTA, GA. 30338
Pear Hick

DEA'RRICf( ,

CET TQ.ESOFnlARE ·PROJECT

I
have spoken
atteMpt :lo Pt1fchsse

I

Thank you for your letter of 19th November.
earHer.

I am sorry I hav.e not replied

Although all our current progralllS are in BASIC, our fonnat was i.ntended to
be independent of language. We would like to distribute programs in other
languages, including PASCAl, but on looking into the question, there appear
to be a few problems which need to be sorted out first.
Firstly, therea.re a few character.s us.ed in PASCAl not covered by our format
recQIIIIIlefldations. I hope you have now recei ved your copy of the
recOflJIIendations ilnd we would, ,of course, be interested in any cQlIIJlents fram
membersafPtlG.
Secondly. as you 'know, ,our telesoftwaresystem at present is only available
for ,use with the 380Z. Although PASCAl can be obtained for the 380Z, it
wHl \onl, 'worJr on 5'1( full disc machines with8{) character display.

j3

with the sales people at Microsoft
in an
cop~ of their new release of Pascal too run

on CP 1M ~

The~~ to 1 d Me -that the'.:! I.... ef e not f:i-€ 11 i ng to €-~n-d u~;;,-er 5 at
this, tiMe onI'.:! to OEM. The'.:! also would not reveal the naME'S of
an!5 of t,heir OEM I..isers but that :if I cDLlld. locat.e (done Masbe one
would sell to Me. Would ~DU, MrtShaw. be able to refer ME' to ans
Msnu-factvrers
who -are u:~ing Microsoft Pascal i~f'ld who hopefl)lll;l
~ould consider selling to an end user.

The M_ain rea-son I t4Bnt. Microsoft Pascal is the C'oMpatibilit'::)
their
object file forMat to Digital Research's for link and
locate with RMAC asseMbled files. If ~ou know an~ other suppliers
whose Pascal is cOf"JPatible to Dis.:i.tiSl Resear-ch"'s
f-o-r-Mat
please

of

let Me JI:.rtow.

.....

I

also would like to receive SOMe inforMation on the Pascal
U-se-r s G:r Oup {.
Tharik

Thi.rdly,it awears that very few Computer Assisted tearning programs have
so far 'been written i.nPASCAl.

~ou

for

~Ol..lr

t,iM.-e.

u:>

00
.....

A-n!;:C help wi 11 be iSpp.reciated.

~;;~

In view of these problems, it is Ijkely that in the immediate future only a
few people _ldbe able to obtain PASCAL by ,t+lesoftware and find it useful.
I therefore dp not thin~PASCAl can be.one of our first priorities,and we
'\iIOuld ,not v.' (-/ . ~ ~
e.
'iiQXti~ 5/a.e.t.lo.Ad, 2E.2
UX.

,f~1<.S.I'C'iVS;2 rl-~se
1 ~". 'ft.r..(ttK) e>N
I t'f{II.$TLU- d'19IA-/N>X
jp, Dtr.,S'7/ 3SCJ
C(HI'NCI'L

F01~

9".

oro:

';;~K ht".#..o<"

/'U4

{u.~}

\?I'Cl SHE.TA,qA(2)T/2'''-,
No,

lllHJCATlONAL

OFFICES: ATLANTA. BOSTON. CHICAGO. CINCINNATI. CLEVELAND. ;DALLAS • 'DETROIT" -HGUST-ON
KANSAS· CITY • _LOS_ANGELES. _NEW ORf.,.;fANS • NEW YORK. ORLANDO. _ST. 'LOU1S • SAN f.RANClSCO • SEATTL'E
WASHINGTON. D.C. • TORONTO. CANADA

1t/;<;I,,/-5

SHET/.~/l!:l> .

ZE:Z

TECHN~LOGYFO'R



n
'"
>

r-

z:

I'T1
>C

'"

Dear Rick:
Nova Robot i cs is a new USer of the Oregon Software OMS I Pasca.1-2
and we ar" int"rested in what the Pascal Users Group has to offe~.
We have the OMSI Pascal On a PDP 11/34 running RSX-l1M V3.2. Enclosed
is our check for a one-year subscription.
We =256 selections} •
A semantic stack
overflow occurred after 109 labels.
Test 6.8.3.5-18 shows the undefined state is the pr.evious
state at the end of the for-loop. The range is checked.
Test 6.8.3.9-20 shows for-loops may be nested to a
of ,6.

The general breakdown of errors is as follows:

depth

Test 6.8.3.10-7 shows with-lo.ops may be nested to a depth
of 7.
Test 6 • 9. 4-1 0 shows that the output buffer is fl ushed
the end of a program.

at

These problems are intimately tied to the EXEC 1100 operating system and its penchant to pad blanks on the end of a
line. There is no plan to try to correct this problem.
Does an external file of pointers make sense!

Chang es in the standard
Jensen and Wirth (second edition) was used as the standard
for
development
of
this compiler.
Since there are
discrepencies between it and the ISO proposed standard.
several deviations occured.
The compiler will be brought
into conformance on most of these errors when some standard
is adopted.
Restrictions
Some restrictions will be kept, even after a standard is
adopted.
GOTO's out of procedures will probably never be
implemented, but STOP and ABORT statements have been added
to the language to alleviate the problem.
Bugs
Several previously unknown bugs were found by running the
validation suite. Professor Fischer has been notified. and
corrections should be included in the next release of the
compilers.
One area that should be emphasized is the clarity of the diagnostics produced by the compiler.
All diagnostics are selfexplanatory, even to the extent of saying "NOT YOUR FAULT" when
an internal compiler error is detected. A complete scalar walkback is produced whenever a fatal error occurs. The compiler attempts error correction and generally does a very good job of
getting the program into execution.
The relocatable compiler has extensive external compilation
features. A program compiled using these facilities receives the
same compile-time diagnostics as if it were compiled
in one
piece.

IMPLEMENTATION DESCRIPTION.
DEC-Ie, DEC-28 (LOTS)

+ Future Plans:

..
..
..
..

PASCAL/PASSGO at LOTS

1. DISTRIBUTOR/IMPLEMENTOR/MAINTAINER:
Distributor /M. intainer:
J. Q. Johnson
LOTS Computer F.cility
Stanford University
St.nford, CA 94385

Arpanet:
Adm;n .JQ,J@S'J-SCORE
(415)497-3214

Implementor /Haint. iner:
Armando R. Rodr i9uez

7. STANDARD:
+ It
..
..
..

supports the standard as defined in Jensen lie Wirth, except:
Records, Arrays and Files of Files are not supported .
Read and Write to non-text Files are not supported.
Set expressions that contain a range delimited by variables
or expressions are not supported.
- The he.p works as a stack. Procedure DISPOSE • pops' the given
item and everything else that was created .fterwards.
+ Set size is 72 elements, set origin is zero.
+ Type CHAR includes only from space to underbar. No lower case.
+ EXTENSIONS: Type ASCII; funct ions FIRST, LAST, UPPERBOUND,
lOWERBOUND for sc.1ars and arrays, respectively; IIIN and MAX;
separ.te1y compiled procedures; a string manipulation package;
LOOP-EXIT
construct;
OTHERWISE
in
CASE
statements;
initialization procedures; DATE, TIME, REALTIME.

Computer Scfence Departlnent'

St.nford University
St.nfor", CA 94385
2. MACHINE:

Digital Equipment Corp. DEC-I8 and DEC-Z8.

3. SYSTEM CONFIGURATION:
DEC TOPS-18, TOPS-28; TENEX and WAITS ,nitors,
using Concise Command Langu.ge (CCL). Uses KA-18 instrull.on set.
Modifications for KI-18 Improved inst. set, under development.
4. DISTRIBUTION:
+ Nond_~sclosure agreement required. ,See accompanying form.
(.We .requ i re th I s wi th two purposes:
a) To know how many copies are around, and who has them.
b) To prevent the use of our improvements by profit-oriented
organizations in products that would later be sold.*)
+ You should provide the transport medium. Methods used unt 11 now:
- Through the Arpanet.
- You send us a 9 tr.ck tape (no less than 1288 feet.
please).
Specify density and
format
desired.
(default: 1688 bpi, DUMPER/BACKUP INTERCHANGE ormat).
- You come by and g.t it on ·your tape.
+ Distributed on an "as is· basis. 8ug reports are encouraged and
we will try to fix them and notify you as soon as possible.
+ The compiler is going through ,a continual, although slow,
improvement process. Users, and PUG, will be notified of major
n.wre1e.ses and critical bugs.
5. OOCUHENTATION:
+ A modified version of the machine-retrievable manual from the
original H.mburg package, as • complement to J.nsen '" Wirth.
+ A "help" file for online access. to the most r.1evant topiCS.
+ A NOTES file with c .....nts and hil\ts from local users.
+ An imp1 .... nt.tlon checklist.
+ A description of interesting parts of the internal policies
(P.cking mechanism, link.ge conventions, the symbol table. a
complete list of error "essages, and • checklist to add
predefined procedures).
+ All the documentation machine-r.triev.b1e.
6. MAINTENANCE POLICY:
+ We are our own main user: maintenance benefits us first:.
+ No gu.renteed rep 1y-t ille.
+ One to four releases a year, for the next two years, at least.

Support full Standard Pascal
Opti.onal flagging of use of non-standard features.
Sets of any size (probably 144-e1ement sets first)
CHAR going from space to t}' .
Make the heap a real heap •
28-native version.
A more friendly user interface: Improvements in the
debugger, more and better utility 'programs, more
measurement tools; better error messages.

8. MEASUREMENTS:
12888+ 11nes of PASCAL code, 598,888+ chars including comments.
COMPILATION SPEED: around 13.888 charslsec of CPU time on 8 2858.
EXECUTION SPEED: as good as th.t of the non-optimized FORTRAN
compi ler.
COMPILATION SPACE: the compiler takes 58k of upper segment, .nd
can work with 16k lower segment.
You receive two compilers (hence the name). They support exact 1y
the same language and features. but one of them (PASSGO) V oduces
the code incore, which saves 25% CPU time and. lot of 1/0 i. the
compile-load .. and .. go sequence. This is ideal for developmfflt, and
particularly helpful in a student environment.

en
'"
...,
......

rn

:3

co

rn

""

9. RELIABLILITY: Very good. It is very heavily used at LOTS (the ero<;;< M
that runs the most, .fter the editor). Implemented at 38+ sites.
18.

DEVELOPMENT METHOD:
We started with the H.mburg-76
compiler.
distributed by DECUS, which is a very good compHer itself. \Ie
have been cleaning bugs, adding missing parts of the standard, and
adding fe.tures in the last 18 months.

ll. LIBRARY SUPPORT AND OTHER FEATURES:
+ Only the essential runtime routines are written in MACRO:
most of the libr.ry is written in PASCAL.
+ Access to the FORTRAN library support.
+ Access to external FORTRAN .nd MACRO routines.
+ Separate compilation.
+ Symbolic Post-mortem dump.
+ Interactive runtime source .. level debugging package.
+ PCREF, a cross .. referencer derived from Hamburg's CROSS.
+ PFORM, a prettyprinter.
+ Statement counts.

...,
".
Gl

m

Rational Data Systems

Rational Data Systems

PASCAL VALIDATION SUITE REPORT
Processor Identification

Pascal Users Group
c/o Rick Shaw
Digital Equipment Corporation
5775 Peachtreee Dunwoody Road
Atlanta, Georgia 39342

Computer:

Data General Eclipse
AOS operating system

Processor:

Rational Data Systems Pascal
AOS version, release 2.19

(Implementations for Nova and microNova under RDOS, DOS and MP/OS
operating systems are functionally equivalent but were not tested.)
Test Conditions

Dear Rick,

Tester:

Enclosed is a copy of the report of the Validation Suite (2.2)
for our Pascal implementations on Data General machines.

Validation Suite Version:

Please let me know if you need any further information for
publication of this report in Pascal News.

Rational Data Systems
2.2

General Notes
Several tests contained statements of the form "read (f, a[i])", where
"f" is a textfile and "a" is a 'packed ,_,ay [l..] of char". In RDS
Pascal, the rule that
components of variables of ",','" t>'-.e designated
packed shall not be usth identifiers and reserved words.
6.2 •. 2-3; Type decla rati on 'p = Anode" is incorrectly
handled when types named "nOde" are present both
late.r in same SCope and e!lrlier in outer scope.
6 •. 4.3.3-1, 6.4.3.3-3. 6.8.2.1-1: Empty records and empty
field lists within record variants are rejected.
6.4.3.3-4; Tagfield "case which:· boolean" is rejected
when ·which" is a known type identifier.
6.5.1-1: A file may not be an element of a record or
OF an array.
6.6.3.1-5, 6.6.3.4-1, 6.6.3.4-2, 6.6.3.5-1: Procedural
and functional parameters are not supported.
6.6.5.3-2: Standard procedure "dispose." is not supported.
(Implementation planned for release 2.211).
Details of erroneous tests:
6.1.8-3: Latest draft standard defines "{*" as exactly
equivalent to "{ft, "*1" exactly equivalent to "I".
6.6.5.2-3: Some opera.ting systems distinguish "empty"
files (length = 9) from "nonexistent" files
(name not known) I while others do not.
6.9.4-4: Draft standa.rd requires ·"write (f, S.Il:6)" to
produce floating-point form ("0.lle+llS" or similar);
suite is testing for fixed-point form ("S.ll").
6.9.4-7: Latest draft standard el

'"

m

ERROR HANDLING
Tests in wMOO errOJ:awere correctly detected
Tests showing true extensions
Tests in whiOO errcu:swere not detected

IMPLEMENTATION DEFINED
19

Number of tests run

1

26

(18 causes)

15

Details of erroneous tests:

6.6.5.2-1.: After a file has been opened .with -reset",
bo,tn"get" and "put" operations are allowed.
(In fact, both operations are permit.ted at all
times. regardless of how the file waa opened.)
This extension is provided to permit convenient
random processing. RDS Pascal provides the
ability to reposition files with the predeclared
procedure "seek «filename>, (integer expression»".
(Not permitted for files of type "text".)

Alternate comment delimiters no longer belong
to category "implementation-defined"; explicitly
required by latest draft standard.
6.11-2: Equivalent symbol for uparrow no longer belongs
to category "implementation-defined-; explicitly
required by latest draft standard. Equivalent
symbols for colon, semicolon, assignment symbol,
and square brackets no longer defined; deleted
from latest draft standard.
6.11-3: Equivalent symbols for comparison symbols not
listed in draft standard.

Details of failed tests:

Details of other tests:

6.2.1-7, 6.4.3.3-6, 6.4.3.3-8, 6.5.4-1, 6.5.4-2,
6.8.3.9-5, 6.8.3.9-6:
No check is done at runtime for variables with
·undefined" (uninitialized, etc.) values'.
6.4.3.3-5, 6.4.3.3-7: Storage redefinition is permitted.
6.4.3.3-12: Empty record rejected at compile time.
6.4.6-7, 6.4.6-8, 6.7.2.4-1: No runtime check for illegal
set assignments.
6.6.2-6: No runtime OOeck for function that fails to
execute assignment statement.
6.6.5.2-6, 6.6.5.2-7: File may be repositioned while
buffer is "var- parameter or is record variable
of "with- statement.
6.6.5.3·-3, 6.6.5.3-4, 6.6.5.3-5, 6.6.5.3-6: Standard
procedure -dispose" not supported.
6.6.5.3-7, 6.6.5.3-8, 6.6.5.3-9: Misuse of variable
created by variant form of -new- is tolerated.
6.8.3.5-5, 6.8.3.5-6: No runtime error when case-index
expression matches none of the case-constants.
6.8.3.9-171 Nested -for- statements may have the same
control variable.

6.4.2.2-7: The value of "maxint" is 32767. (But the
value -32768 can be created by writing --maxint-l"
and is not rejected as erroneous.)
6.4.3.4-2: Declaration "set of char" is permitted.
6.4.3.4-4: Implementation permits sets to contain as many
as 4888 elements. No set may contain negative elements;
e.g. "set of 8 •• 4879" is acceptable, "set of -1 •• 4878is not. This test brought to light a compiler error;
the unacceptable declaration "set of -1 •• +1- was
accepted by the compiler. However, an attempt to
insert a negative element into a set (any set) will
cause a runtime error. (Fixed in release 2.11).
6.6.6.1-1: Procedural and functional parameters not supported.

Details of test showing true extension:

6.11-1:

I-'

<.D
00

6.6.6.2-11: Reals are implemented using Data General's
standard single-precision floatingpoint format:
sign:
one bi t
exponent: 7 bits, excess-64 notation
fraction: 24 bits (6 hexadecimal digits)
All results are normalized (i.e. leftmost hexadecimal
digit of fraction is always > 9). However, the range
of values that can be r,ead from or written onto
textfiles is smaller than the range of values that
can be represented internally: conversion to/from
ASCII is supported only for values in the range
1.ge-75 •• 1.ge+75. Because this test relies on
non-detection of underflow at runtime, it could not
be executed without extensive modification. Ultimate
results were:
beta
16
t
6
rnd
9
ngrd
1
machep -5
negep
-6
iexp
7
minexp -64
maxexp 63
eps
9.53674e-7
epsneg 5.96946e-8
xmin
5.39769e-79
xmax
7.2379ge+75
6.7.2.3-2: Boolean expression "a and b" is fully evaluated.
6.7.2.3-3: BO,olean expression "a or b" is fully evaluated.
6.8.2.2-1: Selection then evaluation for "ali) := expr".
6.8.2.2-2: Selection then eva~uation for "pA := expr".
6.9.4-5: Two digits written in an exponent.
6.9.4-11: Default field widths for "write" to textfiles:
integers
variable
Booleans
variable
reals
8 characters

Details of other tests:
5.2.2-1, 6.1.3-3: Significance limit for identifiers
is eight characters.
No warning message generated when comment extends
across several source lines.
6.2.1-8: Accepted 59 type declarations.
6.2.1-9: Accepted declaration and siting of 59 labels.
6.4.3.2-4: Declaration "array [integer] of integer"
produced error message "array index may not be
of type INTEGER".
6.4.3.3-9: Reverse correlation of fields in record.
6.4.3.4-5: This test was revised to use the RDS "time"
extension, which is accurate only to the second.
Procedure "Warshallsalgorithm" required 184 bytes
of object code, and approximately 5 seconds of
elapsed execution time (on a multi-user system).
6.5.1-2: Long declarations allowed.
6.6.1-7: Procedure/function nesting limit is eight.
6.6.6.2-6 (sqrt), 6.6.6.2-7 (arctan), 6.6.6.2-8 (exp),
6.6.6.2-9 (sin & cos), 6.6.6,.,2-10 (In):
RDS personnel not trained in numerical analysis,
unable to interpret results of these tests.
6.8.3.5-2,: No warning message when a "case" statement
contains an unreachable path.
6.8.3.5-8: Accepted large "case" statement.
6.8.3.9-18: After normal termination (i.e. no "goto")
of a "for" loop, the control variable has the
value of the limit expression. (After execution
of "for i : = red to pink do ;", the value of "i"
is "pink".)
6.8.3.9-20: Accepted "for" statements nested 15 deep.
6.8.3.19-7: Nesting limit of "with" statements is 12.
6.9.4-19: Textfile output is flushed at end of job
when linemarker is omitted. (Note that no
linemarker is inserted, ho\qever.)

6.1.8-4:

<

QUALITY
EXTENSIONS
Number of tests run

23
Number of tests run

1

Details of erroneous tests:
6.7.2.2-4: Test of "mod" operator not in conformance
with latest draft standard. Caused runtime error
message "Non-positive Divisor in MOD Operation".
6.9.4-14: Recursive 10 using same file allowed. This
test contains a superfluous program parameter
which caused the error message "program parameter
not declared as file in outermost block". After
correction of the error, it ran successfully.

Details:
6.8.3.5-14: The "otherwise" clause in a "case" statement
is not supported. (Refer to error handling tests
6.8.3.5-5 and 6.8.3.5-6.)

......
u::>
00

1101
From.

Pascal

ALPHA MICROSYSTEMS AM-I001T

c/o> Rick Shaw

NeWs"

David I'ntersl _ _ - liIe Marco-Shatz Corp,.

Pascal Validation Suite Report
Here is a

COI"Y

of .. validation of the AlphaPASCAL compiler.

have 8iven .. few com_nts on the compiler and the validation suite in the
validation report.

Pascal Processor Identification
Computer'

I have .ent a copy of the report to Prof. Sale.

Processor.

Alpha Microsystems AM-I00/T
AlphaPASCAL V2.0

Installation.

De Marco Shatz Corporation. Torrance. Ca •• USA.

David Intersimone

'I\~~

De Marco-Shatz Corp.

312 Maple Ave.
Torrance. Ca. 90503
(,21,3) 533-5080

>ll..>/ti.3
Test Conditions
Tested BY'
Date.

David Intersimone

February

I

March 1981

Validation Suite Version.

2.2

Report Sent To.
Alpha Microsystems. Soft .... re Department. Irvine. Ca •• USA.
Pascal NelliS. clo Rick Shalll. Atlanta. Ga •• USA.
Prof. Arthur Sale. Department of Information Science.
University of Tasmania, Hobart7 Ta.sman'i., Austral ia.

-0

>

'"
m

Note.
'AlphaPASCAL' and 'AM-I00/T' are trademarks of
Alpha Microsystems. Irvine. Ca •• USA.

Test 6.9.3-1 The READLN function is not correctly implemented.

Conformance Testst

Tests 6.9.4-3. 6.9.4-4. 6.9.5-1 It is illegal to READ into a
packed character field.

Total Number of Conformance Tests' 139
Number of Tests Passed'
103
Number of Tests Failed' 34 (19 reasons)

Test 6.9.4-7 WRITE and WRITELN do not accept a Boolean variable
as an arsument. Also, as with tests 6.9.4-3 et a1, it is
illegal to read into a packed. character field.

Details of Failed Conformance Tests'

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

Tests 6.1.2-3. 6.3-1 8-character significance for identifiers.
Tests 6.1.6-1. 6.1.6-2. 6.2.1-1. 6.2.1-2. 6.2.2-5. 6.8.2.4-1.
6.8.3.7-3. 6.8.3.9-8 GOTO statements are not permitted
without th~ e.G+) compiler option.
Test 6.2.2-3 The global type for the variable 'node' was used
causins a mismatched type in the assignment of ptrA.=truel

Deviance Tests.
Total Number of Deviance Tests. 94
Number of Deviations Correctly Detectedt 55
Number of Tests Not Detectins Erroneous Deviations. 25 (16 reasons)
Number of Tests Showing True Extensions. 2 (2 reasons)
Number of Tests Incorrectly Handled'
12 (6 reasons)

Tests 6.4.3.3-1. 6.4.3.3-3 Empty records are not allowed.
Test 6.4.3.5-1 Only type or constant identifiers are allowed
for file types.

Detai I s of Tests Not Detecting Erroneous Deviatior.s.

Tests 6.4.3.5-2. 6.9.1-1 EOLN and EOF are not correctly implemented.

Test 6.1.2-1 nil can be used with types other than pointers.

Test 6.5.1-1 The tYPe of record fields and arrays cannot be a
FILE type.

Test 6.1.7-6 Strinss can have bounds other that (l •• n).

Tests 6.6.3.1-5. 6.6.3.4-1. 6.6.3.4-2 6.6.3.5-1 procedures and
functions pass.d as para.meters are not allowed"

Test 6.6.3.2-3 failed at runtime with 'invalid filename in RESET'.
Test 6.6.5.2-5 A REWRITE of the file setsEOF false.
Test 6.6.5.3-2 DISPOSE is not imple~ented. AlphaPASCAL uses
MARK and RELEASE to recover memory allocated by NEW.
Test 6.6.5.4-1 PACK and UNPACK are not implememted.
automatically unpacks packed data structures.

AlphaPASCAL

Test 6.7.1-1 Operator precedence was changed for compatability
with other Alpha Micro lansuase processors.
Test 6.8.3.5-4 Crashed the compi ler •.
Test 6.8.3:9-1 Both expressions in a 'FOR' statement are not
evaluated before assisnment is done.

Test 6.1.7-9 Cases 1-4 were accepted. Cases 5-7 rejected.
Tests 6.2.2-4. 6.3-6. 6.4.1-3 Some scope errors are not detected.
Test 6.3-3 Sisned constants are allowed in places other than
constant declarations.
Test 6.4.3.2-5 Strinss can a subranse of other than intesers
as an index tvP••
Test 6.4.5-2. 6.4.5-3. 6.4.5-4. 6.4.5-13 Type compatibility
is used for variables.
Test· 6.4.5-11 Operations on strinss with different numbers
of components are allowed.
Test 6.6.2-5 Function declarations with no assisnment for the
function identifier are allowed.
Test 6.6.6.3-4 TRUNC and ROUND will accept inteser parameters.
Test 6.7.2.2-9 The unarY operator plus(+) can be applied to

Test 6.8.3.9-7 ended UP in an infinite loop showins that the
test at the last increment caused wraparound(overflow)
of the FOR variable.

non-numeric operands.
Tests 6.8.3.9-2. 6.8.3.9-3. 6.8.3.9-4 Assisnment Can be made
to the FOR control variable.

"»
'"

m

Tests 6.S.3.9-9. 6.S.3.9-14. 6.S.3.9-19 Non-local variables
can be u.ed a. FOR control variables.
Test 6.S.3.9-16 cause. endle •• loop.
can be READ.

FOR control variables

Details of Error. not Detectede
Test 6.2.1-7 Local variables have values even thoueh they
were never assiened.

Te.t 6.9.4-9 Field width parameters, can be zero and negative.
Field widths zero and -1 printed the same as field width 1.

Tests 6.4.3.3-5. 6.4.3.3-6. 6.4.3.3-7. 6.4.3.3-S No checking
is done on the til., field of variant records.

Test 6.10-3 Show. that the standard file OUTPUT can be redefined.
Compiled and caused a runtime error.

Tests 6.4.6-7. 6.4.6-S Bounds checkin, is not done on
set types.

Details of Tests Showin. True Extensions'
Test 6.1.7-11 null strines are allo.ed.
Te.t 6.10-1 Default file declarations in the pro,ram headin,
are i.nored.
Details of Tests Incorrectly Handlede
Test 6.2.1-4 caused a bad poiner reference error in the compi ler •.
Test 6.4.3.3-11 Empty records are not allowed.

Test 6.6.2-6 Execution of a function without assi,nment of
a value to the function variable is allowed.

-0

:>
n
:>

'"

rz:

I'T'I
EO

'"

Test 6.6.5.2-2 OET when the file is at eof does not cause
a runtime error.
Tests 6.6.5.2-6. 6.6.5.2-7 did not cause a runtime error when
the file position was chan,ed while the file variable
was in use.
Tests 6.6.5.3-7. 6.6.5.3-S. 6.6.5.3-9 No checks are made on
pointers when they are assiened usine the variant form
of NEW.
Test 6.6.6.4-4 SUCC on the last value of an ordinal type does
not cause a runtime error.

en

I'T'I
-0

-<

I'T'I

Test 6.4.5-5 EiehtlS) character identifier si,nificance.
Te.t 6.6.1-6 The procedure call onelc) did not have a semicolon
II) at the end of statement. An error messa,e for the
undefined forward procedure was not printed.
Test. 6.6.3.5-2. 6.6.3.6-2. 6.6.3.6-3. 6.6.3.6-4, 6.6.3.6-5
Procedures and functions passed as parameters are not
allo_d.

Test 6.6.6.4-5 PRED on the first value of an ordinal type doe.
not cause a runtime error.
Test 6.6.6.4-7 CHR on a value past the limits of CHAR type does
not cause a runtime error.

:3:

"'"
""

I'T'I

....

.0

....
00

Test 6.7.2.2-6. 6.7.2.2-7 An error does not occur when the result
of a binary inte,er operation is not -maxint <= 0 <= +maxint.
Test 6.7.2.4-1 Overlappin, sets do not cause runtime errors.

Tests 6.S.2.4-2. 6.8.2.4-3. 6.8.2.4-4 OOTO statements are not
permitted without the (.0+) compiler option.

Error Handline Test ••
Total Number of Error Handline Tests: 46
NUllber of Error. Correctly Detected' 14
Number of Errors not Detectede 27 116 reasons)
NUllber of Tests Incorrectly Handled' 5 12 reasons)

Tests 6.8.3.5-5. 6.S.3.5-6 A runtime error does not occur when
a CASE statement doesn't contain a constant for the value
of the case expression.
Tests 6.8.3.9-5. 6.8.3.9-6 A FOR control variable can be used
without an intervening assi,nment.
Test 6.8.3.9-17 Two nested FOR statements can use the same
control variable.
Tests 6.9.2-4. 6.9.2-5 No error occurs when readin, characters
that don't form a valid inteeer or real.

-0

»

'"'"

Qualit"y Tests:
Test .6.4."3.3-12 EmPty "eco"ds a"enot al1o .... d.
tests 6 .• 6.5.3-3. 6.6.5.3-4. 6.6.5.3-5. 6.6.5.3-6 DISPOSE
i.not i.lIlple_te4.

Total Numbe" o~ Quality Tests: Z3
Numbe" of Tests Incorrectly Handled:

7 (3 "easons)

Details of Quality Test.s:
Tests 5.2.2-1. 6.1.3-3

Eight(8) character identifi .. r significanc ...

Test 6.1.8-4 Unclosed comments are not detect .. d.
Total NuIIlberof Impl .._ntation n .. finedTestsl
15
NumI>e,. ofTest"tnco... "ectly Handled: 4 (4 reasons)
Test 6.2.1-9 Fifty(50) LABELS .... re acc .. pted.
Test 6.4.3.2-4 Gave th .. compil ..-tim.. m.. ssa .. e:
'" Ar ra. vis t·o-'O 1 a.rge" •
Test 6.4.3. 3-9 Exact corr .. l ation b .. tw .. en variant r .. cord fi .. ·l ds.
Test 6.4.3.4-2 S .. tsof cbaracters a ..... allo.... d.

T....ts 6.7.2.3-2. 6.7.2.3-3 Boo' ..an e)QOressions

T.. st 6.5.1-2 Long d"claration lists ar .. al10 .... d.

&".

fully eval uated.

T.sts 6.'9 • .2;.:2-1. 6.8.2.2-:2 Variab.' . . caN. selected tb .. " .. valuat .. d.
Test 6 •.1'()-:2A REWRITE on tbestandard o·utput f i 1.. is all o.... d.

Test 6.6.1-7 S .. v ..n(7) proc .. dure/function d .. clarations could
be nested.
Not .. : the compil .. r manual stat .. s that th ..
max n .. stin .. l .. vel is 12.
Test 6.7.2.2-4 nIVbv ne.ativ.. op.. rands is implem .. nt .. d and
consist .. nt. DIV into ne.ativ.. op .. rands is inconsist .. nt.
Q,uoti .. nt=TRUNCHVcB) for ne.ativ.. op .. rands. MOD(A,B)
lies in (0, B-1 l.

.....
co

00

T,est 6.8.3.5-2 Impossible CASE paths ar .. not d .. tected.
T.. st 6.8.3.9-18 .Ran!'" ch.. cking is don.. on a CASE state,ment
aft .. r .a FOR loop.
T.st 6.8.3.9-20 FOR stat ..ments canb .. n.. st.. d to
> fift .... n(t5) L .. v .. l s.

".s1:6.9.4-'3 e_c,uted i", an endless to.oP. Out'Put f.i1 .. fl'om
4:',tle WlU'T'ELN stat.. ment containedlABC.

T.. st 6.8.3.10-7 EI .. venUl) WITH stat ..m.. nts can b .. nest .. d.
Th.. compil .. rnranual .stat .. s that the maximum n .. xting of
p/,oc .. dur .. s, ..1 t,h-do. and r .. cord tyP" des<:/'iptions is t ..el ve(12).
T.. st 6.9.4-10 Output is flush .. d at .. nd-of-J.ob.
Test 6.9.4-14 Recur .. ive 110 is allo ....d.

,."
'"

.m

00

o
netail$o~

T .... ts Incorl".. ctlv Handl .. d'

T.. st6.4.3.4-5'processtime' is not implem .. nted.

Tests 6.6.6.2-6. 6.6.6.2-7,6.6.6.2-8. 6.6.6.2-9. 6.6.6.2-10
Failed to compile beca.. se inte,er const ... nts must be in
theram.e +-32767, 'e' is not accep'ted ...5 '... substitute
for ':E' i,n real const ... nts. the pro'r ... m 'blocks .. her .. too
lar,efo,. 'the compile.. t,o handle .... nd thecompi l .. rthou.ht
it had hit the enil of thepre......m .. h,en it hadn't.
N,otetth" compiler m... nua 1 states that the object code for
anY proc,edure or function cannot belar,e,r than 2000 bytes.
Test 6.8.3.5-8 f ... iled to compile afte,r 121 case state .... ntp...rts
becaus.. the progr...m block ' _ 5 too lar.e.

Extension Tests.
Total. ,of Extension Test's.

Comments on the Validation Suitet
1)

Some tests are too lar,e (oriented to .. ards mainframes?).
SQRT. ARCTAN. LN, etc. tests (6.6.6.2-6.,7.8.9.10) should
be broken UP. These cause problems with a compiler on
smaller machines. Correctness of function should use
tests accept ... ble to large and small computers.

2)

How about a -new val idati-on section called "performance"?
Would showing the p .. rfol'mance of compil ... tion ... nd execution
(could be part of the QUALITY tests). Could check to
see whattails ,of 'Extension Tests:
Test 6.8.3.'5-14 The extensi,o,n 'OTl£RWlSE' is not implemented.
'ELSE' i's ...ccepted to 'handle t,he same funct,i'on.

.....
""00
.....
Notes .boutthe Ah-haPASCAL compileN
Previousversio,ns of cAlphaPASCAL used the UCSD Pascal
P1'O.rammi,n. svs't.m. Th.n... Al phaPASCAL ,svstemconsists
ofacompiler, I inker" external 1 ibrary and a run-time
packa.e. Text edi to.." ,a.. e used to create source pro"l',ams.
Thecompil,e'r Hne,rates inte..mediate fil es for-use by 'the
1,inker. T1MI linker takes 'the ,int.,..ediatefi h,s ilind an
external Hbrarv 'toe...at. ;a ,runnable J>-code fil ....
,Exttl..,nal,proced..res ,and fU1Ictions can be se""'l'at·e'lv compi lecd
and placlI'd in a"extern.;! Tii>'rarvfor- fut,uF'elinkin. wi th
.... o.rams. 'Machin. lanBua.e sui>'routines can a
be .. ritten
and It,nked .i nt:o _,o'I"alll5.

''''0

AI,...haPASCAL '!'!un-time ;Us.es a virt_.,1 memorv ..a1!lins system 5,,,
ther. is no 111.%. Hm"t 'on 'P-code fi·,.... The run-time ...... cl<"'....
,... ov! 

'"m

00
.....

IMPLEMENTATION NOTES ONE PURPOSE COUPON

o.

DATE

1.

IMPLEMENTOR/MAINTAINER/DISTRIBUTOR

2.

MACHINE/SYSTEM CONFIGURATION

(* Give e person. eddress end phone number. *)

(* Any known limits on the configuretion or support softwere required. e.g.

opereting system. *)

3.

DISTRIBUTION

4.

DOCUMENTATION

5.

MAINTENANCE

6.

STANDARD

(* Who to esk. how it comes. in whet options. end et whet price. *)

(* Whet is eveileble end where. *).

(* Is it unmeinteined. fully meinteined. etc? *)

(* How does it meesure up to stenderd Pescel?ls it

7. MEASUREMENTS

a subset? Extended? How. *)

(* Of its speed or space. *)

8.

RELIABILITY

9.

DEVELOPMENT METHOD

(* Any information about field use or sites installed. *)

10. LIBRARY SUPPORT

(* How wes it developed and what wes it written in? *)

(* Any other support for compiler in the form of linkages to other languages. source libraries. etc. *)

(FOLD HERE)
~~~--~~-----------------~------~-----------------~--

PLACE
POSTAGE
HERE

Bob Dietrich
M.S. 92-134
Tektronix t Inc.
P.O. Bo)( 500
Bedverton, Oregon

U.S.A.

97077

(FOLD H6RI!)

NOTE: Pascal News publishes all the Checklists it

getS. implementor. shOuld send us their checkli-st$
for their products $:0 the thousands of committed
Pascalefs can judge them fot their merit. Otherwise
we must F81y on tumors.

Plea•• fM' free to

iJ'. additional .heets of paper.

IMPLEMENTATION NOTES ONE PURPOSE COUPON



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date                     : 2011:06:15 19:56:43-08:00
Modify Date                     : 2011:06:15 20:11:37-07:00
Metadata Date                   : 2011:06:15 20:11:37-07:00
Producer                        : Adobe Acrobat 9.43 Paper Capture Plug-in
Format                          : application/pdf
Document ID                     : uuid:5a6adebf-336f-420b-9562-05ef21b34c57
Instance ID                     : uuid:d0e03d2d-d01d-485a-a0b0-dec843f654eb
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 90
EXIF Metadata provided by EXIF.tools

Navigation menu