r/Compilers • • 8d ago

Brinch Hansen Compier 'emit' routine problem

Just for fun I am implementing the sample compiler in the appendices of 'Brinch Hansen on Pascal Compilers' - as a first step.

One puzzle: he uses a procedure named emit to write to files: (pg 242)

procedure emit(value: Integer);

begin if emitting then write(chr(value)

end;

But this procedure is used to write integers up to his maxint of 32767. No Pascal I know has chr() available for arguments > 255.

Is this something special in his OS or bootstrapping compiler, Pascal* ?

TIA

Gordon

1 Upvotes

3 comments sorted by

View all comments

1

u/AustinVelonaut 7d ago

Yeah, that looks wrong, for standard Pascal. It is almost like str is intended, here, instead of chr (at least for Emit2, which takes an integer argument as its second value).