Check-in [8e126288ba]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Original P4 Pascal Compiler
Timelines: family | descendants | trunk
Files: files | file ages | folders
SHA1:8e126288ba15229c0cfaf010a58a1ef317a47881
User & Date: tonyp 2014-10-16 09:17:01
Context
2014-10-16
09:22
P5 Pascal Compiler upgrade check-in: ec0b3dba13 user: tonyp tags: trunk
09:17
Original P4 Pascal Compiler check-in: 8e126288ba user: tonyp tags: trunk
Changes

Added pcom.p.

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
84
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
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
161
162
163
164
165
166
167
168
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
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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
349
350
351
352
353
354
355
356
357
358
359
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
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
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
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
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
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
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
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
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
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
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
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
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
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
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
2293
2294
2295
2296
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
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
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
2465
2466
2467
2468
2469
2470
2471
2472
2473
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
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
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
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
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
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
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
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
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
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
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
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
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
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
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
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
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
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
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
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
(*$c+,t-,d-,l-*)
 (***********************************************
  *						*
  *	 Portable Pascal compiler		*
  *	 ************************		*
  *						*
  *		Pascal P4			*
  *						*
  *     Authors:				*
  *	      Urs Ammann			*
  *	      Kesav Nori			*
  *	      Christian Jacobi			*
  *     Address:				*
  *	  Institut Fuer Informatik		*
  *	  Eidg. Technische Hochschule		*
  *	  CH-8096 Zuerich			*
  *						*
  *  This code is fully documented in the book	*
  *	   "Pascal Implementation"		*
  *   by Steven Pemberton and Martin Daniels	*
  * published by Ellis Horwood, Chichester, UK	*
  *	    ISBN: 0-13-653-0311			*
  *       (also available in Japanese)		*
  *						*
  * Steven Pemberton, CWI/AA,			*
  * Kruislaan 413, 1098 SJ Amsterdam, NL	*
  * Steven.Pemberton@cwi.nl			*
  *						*
  ***********************************************)

program pascalcompiler(input,output,prr);

const displimit = 20; maxlevel = 10;
   intsize     =      1;
   intal       =      1;
   realsize    =      1;
   realal      =      1;
   charsize    =      1;
   charal      =      1;
   charmax     =      1;
   boolsize    =      1;
   boolal      =      1;
   ptrsize     =      1;
   adral       =      1;
   setsize     =      1;
   setal       =      1;
   stackal     =      1;
   stackelsize =      1;
   strglgth    =     16;
   sethigh     =     47;
   setlow      =      0;
   ordmaxchar  =     63;
   ordminchar  =      0;
   maxint      =  32767;
   lcaftermarkstack = 5;
   fileal      = charal;
   (* stackelsize = minimum size for 1 stackelement
		  = k*stackal
      stackal     = scm(all other al-constants)
      charmax     = scm(charsize,charal)
		    scm = smallest common multiple
      lcaftermarkstack >= 4*ptrsize+max(x-size)
			= k1*stackelsize	  *)
   maxstack   =       1;
   parmal     = stackal;
   parmsize   = stackelsize;
   recal      = stackal;
   filebuffer =       4;
   maxaddr    =  maxint;



type							(*describing:*)
							    (*************)

     marktype= ^integer;
							    (*basic symbols*)
							    (***************)

     symbol = (ident,intconst,realconst,stringconst,notsy,mulop,addop,relop,
	       lparent,rparent,lbrack,rbrack,comma,semicolon,period,arrow,
	       colon,becomes,labelsy,constsy,typesy,varsy,funcsy,progsy,
	       procsy,setsy,packedsy,arraysy,recordsy,filesy,forwardsy,
	       beginsy,ifsy,casesy,repeatsy,whilesy,forsy,withsy,
	       gotosy,endsy,elsesy,untilsy,ofsy,dosy,tosy,downtosy,
	       thensy,othersy);
     operator = (mul,rdiv,andop,idiv,imod,plus,minus,orop,ltop,leop,geop,gtop,
		 neop,eqop,inop,noop);
     setofsys = set of symbol;
     chtp = (letter,number,special,illegal,
	     chstrquo,chcolon,chperiod,chlt,chgt,chlparen,chspace);

							    (*constants*)
							    (***********)
     setty = set of setlow..sethigh;
     cstclass = (reel,pset,strg);
     csp = ^ constant;
     constant = record case cclass: cstclass of
			 reel: (rval: packed array [1..strglgth] of char);
			 pset: (pval: setty);
			 strg: (slgth: 0..strglgth;
				sval: packed array [1..strglgth] of char)
		       end;

     valu = record case intval: boolean of  (*intval never set nor tested*)
		     true:  (ival: integer);
		     false: (valp: csp)
		   end;

							   (*data structures*)
							   (*****************)
     levrange = 0..maxlevel; addrrange = 0..maxaddr;
     structform = (scalar,subrange,pointer,power,arrays,records,files,
		   tagfld,variant);
     declkind = (standard,declared);
     stp = ^ structure; ctp = ^ identifier;

     structure = packed record
		   marked: boolean;   (*for test phase only*)
		   size: addrrange;
		   case form: structform of
		     scalar:   (case scalkind: declkind of
				  declared: (fconst: ctp); standard: ());
		     subrange: (rangetype: stp; min,max: valu);
		     pointer:  (eltype: stp);
		     power:    (elset: stp);
		     arrays:   (aeltype,inxtype: stp);
		     records:  (fstfld: ctp; recvar: stp);
		     files:    (filtype: stp);
		     tagfld:   (tagfieldp: ctp; fstvar: stp);
		     variant:  (nxtvar,subvar: stp; varval: valu)
		   end;

							    (*names*)
							    (*******)

     idclass = (types,konst,vars,field,proc,func);
     setofids = set of idclass;
     idkind = (actual,formal);
     alpha = packed array [1..8] of char;

     identifier = packed record
		   name: alpha; llink, rlink: ctp;
		   idtype: stp; next: ctp;
		   case klass: idclass of
		     types: ();
		     konst: (values: valu);
		     vars:  (vkind: idkind; vlev: levrange; vaddr: addrrange);
		     field: (fldaddr: addrrange);
		     proc, func:  (case pfdeckind: declkind of
			      standard: (key: 1..15);
			      declared: (pflev: levrange; pfname: integer;
					  case pfkind: idkind of
					   actual: (forwdecl, externl: boolean);
					   formal: ()))
		   end;


     disprange = 0..displimit;
     where = (blck,crec,vrec,rec);

							    (*expressions*)
							    (*************)
     attrkind = (cst,varbl,expr);
     vaccess = (drct,indrct,inxd);

     attr = record typtr: stp;
	      case kind: attrkind of
		cst:   (cval: valu);
		varbl: (case access: vaccess of
			  drct: (vlevel: levrange; dplmt: addrrange);
			  indrct: (idplmt: addrrange))
	      end;

     testp = ^ testpointer;
     testpointer = packed record
		     elt1,elt2 : stp;
		     lasttestp : testp
		   end;

								 (*labels*)
								 (********)
     lbp = ^ labl;
     labl = record nextlab: lbp; defined: boolean;
		   labval, labname: integer
	    end;

     extfilep = ^filerec;
     filerec = record filename:alpha; nextfile:extfilep end;

(*-------------------------------------------------------------------------*)

var
    prr: text; (* comment this out when compiling with pcom *)
				    (*returned by source program scanner
				     insymbol:
				     **********)

    sy: symbol;		     (*last symbol*)
    op: operator;		   (*classification of last symbol*)
    val: valu;		      (*value of last constant*)
    lgth: integer;		  (*length of last string constant*)
    id: alpha;		      (*last identifier (possibly truncated)*)
    kk: 1..8;		       (*nr of chars in last identifier*)
    ch: char;		       (*last character*)
    eol: boolean;		   (*end of line flag*)


				    (*counters:*)
				    (***********)

    chcnt: integer;		 (*character counter*)
    lc,ic: addrrange;	       (*data location and instruction counter*)
    linecount: integer;


				    (*switches:*)
				    (***********)

    dp,			     (*declaration part*)
    prterr,			 (*to allow forward references in pointer type
				      declaration by suppressing error message*)
    list,prcode,prtables: boolean;  (*output options for
					-- source program listing
					-- printing symbolic code
					-- displaying ident and struct tables
					--> procedure option*)
    debug: boolean;


				    (*pointers:*)
				    (***********)
    parmptr,
    intptr,realptr,charptr,
    boolptr,nilptr,textptr: stp;    (*pointers to entries of standard ids*)
    utypptr,ucstptr,uvarptr,
    ufldptr,uprcptr,ufctptr,	(*pointers to entries for undeclared ids*)
    fwptr: ctp;		     (*head of chain of forw decl type ids*)
    fextfilep: extfilep;	    (*head of chain of external files*)
    globtestp: testp;	       (*last testpointer*)


				    (*bookkeeping of declaration levels:*)
				    (************************************)

    level: levrange;		(*current static level*)
    disx,			   (*level of last id searched by searchid*)
    top: disprange;		 (*top of display*)

    display:			(*where:   means:*)
      array [disprange] of
	packed record	       (*=blck:   id is variable id*)
	  fname: ctp; flabel: lbp;  (*=crec:   id is field id in record with*)
	  case occur: where of      (*	 constant address*)
	    crec: (clev: levrange;  (*=vrec:   id is field id in record with*)
		  cdspl: addrrange);(*	 variable address*)
	    vrec: (vdspl: addrrange)
	  end;		      (* --> procedure withstatement*)


				    (*error messages:*)
				    (*****************)

    errinx: 0..10;		  (*nr of errors in current source line*)
    errlist:
      array [1..10] of
	packed record pos: integer;
		      nmr: 1..400
	       end;



				    (*expression compilation:*)
				    (*************************)

    gattr: attr;		    (*describes the expr currently compiled*)


				    (*structured constants:*)
				    (***********************)

    constbegsys,simptypebegsys,typebegsys,blockbegsys,selectsys,facbegsys,
    statbegsys,typedels: setofsys;
    chartp : array[char] of chtp;
    rw:  array [1..35(*nr. of res. words*)] of alpha;
    frw: array [1..9] of 1..36(*nr. of res. words + 1*);
    rsy: array [1..35(*nr. of res. words*)] of symbol;
    ssy: array [char] of symbol;
    rop: array [1..35(*nr. of res. words*)] of operator;
    sop: array [char] of operator;
    na:  array [1..35] of alpha;
    mn:  array [0..60] of packed array [1..4] of char;
    sna: array [1..23] of packed array [1..4] of char;
    cdx: array [0..60] of -4..+4;
    pdx: array [1..23] of -7..+7;
    ordint: array [char] of integer;

    intlabel,mxint10,digmax: integer;
(*-------------------------------------------------------------------------*)
  procedure mark(var p: marktype); begin end;
  procedure release(p: marktype); begin end;

  procedure endofline;
    var lastpos,freepos,currpos,currnmr,f,k: integer;
  begin
    if errinx > 0 then   (*output error messages*)
      begin write(output,linecount:6,' ****  ':9);
	lastpos := 0; freepos := 1;
	for k := 1 to errinx do
	  begin
	    with errlist[k] do
	      begin currpos := pos; currnmr := nmr end;
	    if currpos = lastpos then write(output,',')
	    else
	      begin
		while freepos < currpos do
		  begin write(output,' '); freepos := freepos + 1 end;
		write(output,'^');
		lastpos := currpos
	      end;
	    if currnmr < 10 then f := 1
	    else if currnmr < 100 then f := 2
	      else f := 3;
	    write(output,currnmr:f);
	    freepos := freepos + f + 1
	  end;
	writeln(output); errinx := 0
      end;
    linecount := linecount + 1;
    if list and (not eof(input)) then
      begin write(output,linecount:6,'  ':2);
	if dp then write(output,lc:7) else write(output,ic:7);
	write(output,' ')
      end;
    chcnt := 0
  end  (*endofline*) ;

  procedure error(ferrnr: integer);
  begin
    if errinx >= 9 then
      begin errlist[10].nmr := 255; errinx := 10 end
    else
      begin errinx := errinx + 1;
	errlist[errinx].nmr := ferrnr
      end;
    errlist[errinx].pos := chcnt
  end (*error*) ;

  procedure insymbol;
    (*read next basic symbol of source program and return its
    description in the global variables sy, op, id, val and lgth*)
    label 1,2,3;
    var i,k: integer;
	digit: packed array [1..strglgth] of char;
	string: packed array [1..strglgth] of char;
	lvp: csp; test: boolean;

    procedure nextch;
    begin if eol then
      begin if list then writeln(output); endofline
      end;
      if not eof(input) then
       begin eol := eoln(input); read(input,ch);
	if list then write(output,ch);
	chcnt := chcnt + 1
       end
      else
	begin writeln(output,'   *** eof ','encountered');
	  test := false
	end
    end;

    procedure options;
    begin
      repeat nextch;
	if ch <> '*' then
	  begin
	    if ch = 't' then
	      begin nextch; prtables := ch = '+' end
	    else
	      if ch = 'l' then
		begin nextch; list := ch = '+';
		  if not list then writeln(output)
		end
	      else
	     if ch = 'd' then
	       begin nextch; debug := ch = '+' end
	     else
		if ch = 'c' then
		  begin nextch; prcode := ch = '+' end;
	    nextch
	  end
      until ch <> ','
    end (*options*) ;

  begin (*insymbol*)
  1:
    repeat while ((ch = ' ') or (ch = '	')) and not eol do nextch;
      test := eol;
      if test then nextch
    until not test;
    if chartp[ch] = illegal then
      begin sy := othersy; op := noop;
	error(399); nextch
      end
    else
    case chartp[ch] of
      letter:
	begin k := 0;
	  repeat
	    if k < 8 then
	     begin k := k + 1; id[k] := ch end ;
	    nextch
	  until chartp[ch] in [special,illegal,chstrquo,chcolon,
				chperiod,chlt,chgt,chlparen,chspace];
	  if k >= kk then kk := k
	  else
	    repeat id[kk] := ' '; kk := kk - 1
	    until kk = k;
	  for i := frw[k] to frw[k+1] - 1 do
	    if rw[i] = id then
	      begin sy := rsy[i]; op := rop[i]; goto 2 end;
	    sy := ident; op := noop;
  2:    end;
      number:
	begin op := noop; i := 0;
	  repeat i := i+1; if i<= digmax then digit[i] := ch; nextch
	  until chartp[ch] <> number;
	  if ((ch = '.') and (input^ <> '.')) or (ch = 'e') then
	    begin
		  k := i;
		  if ch = '.' then
		    begin k := k+1; if k <= digmax then digit[k] := ch;
		      nextch; (*if ch = '.' then begin ch := ':'; goto 3 end;*)
		      if chartp[ch] <> number then error(201)
		      else
			repeat k := k + 1;
			  if k <= digmax then digit[k] := ch; nextch
			until chartp[ch] <>  number
		    end;
		  if ch = 'e' then
		    begin k := k+1; if k <= digmax then digit[k] := ch;
		      nextch;
		      if (ch = '+') or (ch ='-') then
			begin k := k+1; if k <= digmax then digit[k] := ch;
			  nextch
			end;
		      if chartp[ch] <> number then error(201)
		      else
			repeat k := k+1;
			  if k <= digmax then digit[k] := ch; nextch
			until chartp[ch] <> number
		     end;
		   new(lvp,reel); sy:= realconst; lvp^.cclass := reel;
		   with lvp^ do
		     begin for i := 1 to strglgth do rval[i] := ' ';
		       if k <= digmax then
			 for i := 2 to k + 1 do rval[i] := digit[i-1]
		       else begin error(203); rval[2] := '0';
			      rval[3] := '.'; rval[4] := '0'
			    end
		     end;
		   val.valp := lvp
	    end
	  else
  3:	begin
	      if i > digmax then begin error(203); val.ival := 0 end
	      else
		with val do
		  begin ival := 0;
		    for k := 1 to i do
		      begin
			if ival <= mxint10 then
			  ival := ival*10+ordint[digit[k]]
			else begin error(203); ival := 0 end
		      end;
		    sy := intconst
		  end
	    end
	end;
      chstrquo:
	begin lgth := 0; sy := stringconst;  op := noop;
	  repeat
	    repeat nextch; lgth := lgth + 1;
		   if lgth <= strglgth then string[lgth] := ch
	    until (eol) or (ch = '''');
	    if eol then error(202) else nextch
	  until ch <> '''';
	  lgth := lgth - 1;   (*now lgth = nr of chars in string*)
	  if lgth = 0 then error(205) else
	  if lgth = 1 then val.ival := ord(string[1])
	  else
	    begin new(lvp,strg); lvp^.cclass:=strg;
	      if lgth > strglgth then
		begin error(399); lgth := strglgth end;
	      with lvp^ do
		begin slgth := lgth;
		  for i := 1 to lgth do sval[i] := string[i]
		end;
	      val.valp := lvp
	    end
	end;
      chcolon:
	begin op := noop; nextch;
	  if ch = '=' then
	    begin sy := becomes; nextch end
	  else sy := colon
	end;
      chperiod:
	begin op := noop; nextch;
	  if ch = '.' then
	    begin sy := colon; nextch end
	  else sy := period
	end;
      chlt:
	begin nextch; sy := relop;
	  if ch = '=' then
	    begin op := leop; nextch end
	  else
	    if ch = '>' then
	      begin op := neop; nextch end
	    else op := ltop
	end;
      chgt:
	begin nextch; sy := relop;
	  if ch = '=' then
	    begin op := geop; nextch end
	  else op := gtop
	end;
      chlparen:
       begin nextch;
	 if ch = '*' then
	   begin nextch;
	     if ch = '$' then options;
	     repeat
	       while (ch <> '*') and not eof(input) do nextch;
	       nextch
	     until (ch = ')') or eof(input);
	     nextch; goto 1
	   end;
	 sy := lparent; op := noop
       end;
      special:
	begin sy := ssy[ch]; op := sop[ch];
	  nextch
	end;
      chspace: sy := othersy
    end (*case*)
  end (*insymbol*) ;

  procedure enterid(fcp: ctp);
    (*enter id pointed at by fcp into the name-table,
     which on each declaration level is organised as
     an unbalanced binary tree*)
    var nam: alpha; lcp, lcp1: ctp; lleft: boolean;
  begin nam := fcp^.name;
    lcp := display[top].fname;
    if lcp = nil then
      display[top].fname := fcp
    else
      begin
	repeat lcp1 := lcp;
	  if lcp^.name = nam then   (*name conflict, follow right link*)
	    begin error(101); lcp := lcp^.rlink; lleft := false end
	  else
	    if lcp^.name < nam then
	      begin lcp := lcp^.rlink; lleft := false end
	    else begin lcp := lcp^.llink; lleft := true end
	until lcp = nil;
	if lleft then lcp1^.llink := fcp else lcp1^.rlink := fcp
      end;
    fcp^.llink := nil; fcp^.rlink := nil
  end (*enterid*) ;

  procedure searchsection(fcp: ctp; var fcp1: ctp);
    (*to find record fields and forward declared procedure id's
     --> procedure proceduredeclaration
     --> procedure selector*)
     label 1;
  begin
    while fcp <> nil do
      if fcp^.name = id then goto 1
      else if fcp^.name < id then fcp := fcp^.rlink
	else fcp := fcp^.llink;
1:  fcp1 := fcp
  end (*searchsection*) ;

  procedure searchid(fidcls: setofids; var fcp: ctp);
    label 1;
    var lcp: ctp;
  begin
    for disx := top downto 0 do
      begin lcp := display[disx].fname;
	while lcp <> nil do
	  if lcp^.name = id then
	    if lcp^.klass in fidcls then goto 1
	    else
	      begin if prterr then error(103);
		lcp := lcp^.rlink
	      end
	  else
	    if lcp^.name < id then
	      lcp := lcp^.rlink
	    else lcp := lcp^.llink
      end;
    (*search not successful; suppress error message in case
     of forward referenced type id in pointer type definition
     --> procedure simpletype*)
    if prterr then
      begin error(104);
	(*to avoid returning nil, reference an entry
	 for an undeclared id of appropriate class
	 --> procedure enterundecl*)
	if types in fidcls then lcp := utypptr
	else
	  if vars in fidcls then lcp := uvarptr
	  else
	    if field in fidcls then lcp := ufldptr
	    else
	      if konst in fidcls then lcp := ucstptr
	      else
		if proc in fidcls then lcp := uprcptr
		else lcp := ufctptr;
      end;
1:  fcp := lcp
  end (*searchid*) ;

  procedure getbounds(fsp: stp; var fmin,fmax: integer);
    (*get internal bounds of subrange or scalar type*)
    (*assume fsp<>intptr and fsp<>realptr*)
  begin
    fmin := 0; fmax := 0;
    if fsp <> nil then
    with fsp^ do
      if form = subrange then
	begin fmin := min.ival; fmax := max.ival end
      else
	  if fsp = charptr then
	    begin fmin := ordminchar; fmax := ordmaxchar
	    end
	  else
	    if fconst <> nil then
	      fmax := fconst^.values.ival
  end (*getbounds*) ;

  function alignquot(fsp: stp): integer;
  begin
    alignquot := 1;
    if fsp <> nil then
      with fsp^ do
	case form of
	  scalar:   if fsp=intptr then alignquot := intal
		    else if fsp=boolptr then alignquot := boolal
		    else if scalkind=declared then alignquot := intal
		    else if fsp=charptr then alignquot := charal
		    else if fsp=realptr then alignquot := realal
		    else (*parmptr*) alignquot := parmal;
	  subrange: alignquot := alignquot(rangetype);
	  pointer:  alignquot := adral;
	  power:    alignquot := setal;
	  files:    alignquot := fileal;
	  arrays:   alignquot := alignquot(aeltype);
	  records:  alignquot := recal;
	  variant,tagfld: error(501)
	end
  end (*alignquot*);

  procedure align(fsp: stp; var flc: addrrange);
    var k,l: integer;
  begin
    k := alignquot(fsp);
    l := flc-1;
    flc := l + k  -  (k+l) mod k
  end (*align*);

  procedure printtables(fb: boolean);
    (*print data structure and name table*)
    var i, lim: disprange;

    procedure marker;
      (*mark data structure entries to avoid multiple printout*)
      var i: integer;

      procedure markctp(fp: ctp); forward;

      procedure markstp(fp: stp);
	(*mark data structures, prevent cycles*)
      begin
	if fp <> nil then
	  with fp^ do
	    begin marked := true;
	      case form of
	      scalar:   ;
	      subrange: markstp(rangetype);
	      pointer:  (*don't mark eltype: cycle possible; will be marked
			anyway, if fp = true*) ;
	      power:    markstp(elset) ;
	      arrays:   begin markstp(aeltype); markstp(inxtype) end;
	      records:  begin markctp(fstfld); markstp(recvar) end;
	      files:    markstp(filtype);
	      tagfld:   markstp(fstvar);
	      variant:  begin markstp(nxtvar); markstp(subvar) end
	      end (*case*)
	    end (*with*)
      end (*markstp*);

      procedure markctp;
      begin
	if fp <> nil then
	  with fp^ do
	    begin markctp(llink); markctp(rlink);
	      markstp(idtype)
	    end
      end (*markctp*);

    begin (*marker*)
      for i := top downto lim do
	markctp(display[i].fname)
    end (*marker*);

    procedure followctp(fp: ctp); forward;

    procedure followstp(fp: stp);
    begin
      if fp <> nil then
	with fp^ do
	  if marked then
	    begin marked := false; write(output,' ':4,ord(fp):6,size:10);
	      case form of
	      scalar:   begin write(output,'scalar':10);
			  if scalkind = standard then
			    write(output,'standard':10)
			  else write(output,'declared':10,' ':4,ord(fconst):6);
			  writeln(output)
			end;
	      subrange: begin
			  write(output,'subrange':10,' ':4,ord(rangetype):6);
			  if rangetype <> realptr then
			    write(output,min.ival,max.ival)
			  else
			    if (min.valp <> nil) and (max.valp <> nil) then
			      write(output,' ',min.valp^.rval:9,
				    ' ',max.valp^.rval:9);
			  writeln(output); followstp(rangetype);
			end;
	      pointer:  writeln(output,'pointer':10,' ':4,ord(eltype):6);
	      power:    begin writeln(output,'set':10,' ':4,ord(elset):6);
			  followstp(elset)
			end;
	      arrays:   begin
			  writeln(output,'array':10,' ':4,ord(aeltype):6,' ':4,
			    ord(inxtype):6);
			  followstp(aeltype); followstp(inxtype)
			end;
	      records:  begin
			  writeln(output,'record':10,' ':4,ord(fstfld):6,' ':4,
			    ord(recvar):6); followctp(fstfld);
			  followstp(recvar)
			end;
	      files:    begin write(output,'file':10,' ':4,ord(filtype):6);
			  followstp(filtype)
			end;
	      tagfld:   begin writeln(output,'tagfld':10,' ':4,ord(tagfieldp):6,
			    ' ':4,ord(fstvar):6);
			  followstp(fstvar)
			end;
	      variant:  begin writeln(output,'variant':10,' ':4,ord(nxtvar):6,
			    ' ':4,ord(subvar):6,varval.ival);
			  followstp(nxtvar); followstp(subvar)
			end
	      end (*case*)
	    end (*if marked*)
    end (*followstp*);

    procedure followctp;
      var i: integer;
    begin
      if fp <> nil then
	with fp^ do
	  begin write(output,' ':4,ord(fp):6,' ',name:9,' ':4,ord(llink):6,
	    ' ':4,ord(rlink):6,' ':4,ord(idtype):6);
	    case klass of
	      types: write(output,'type':10);
	      konst: begin write(output,'constant':10,' ':4,ord(next):6);
		       if idtype <> nil then
			 if idtype = realptr then
			   begin
			     if values.valp <> nil then
			       write(output,' ',values.valp^.rval:9)
			   end
			 else
			   if idtype^.form = arrays then  (*stringconst*)
			     begin
			       if values.valp <> nil then
				 begin write(output,' ');
				   with values.valp^ do
				     for i := 1 to slgth do
				       write(output,sval[i])
				 end
			     end
			   else write(output,values.ival)
		     end;
	      vars:  begin write(output,'variable':10);
		       if vkind = actual then write(output,'actual':10)
		       else write(output,'formal':10);
		       write(output,' ':4,ord(next):6,vlev,' ':4,vaddr:6 );
		     end;
	      field: write(output,'field':10,' ':4,ord(next):6,' ':4,fldaddr:6);
	      proc,
	      func:  begin
		       if klass = proc then write(output,'procedure':10)
		       else write(output,'function':10);
		       if pfdeckind = standard then
			 write(output,'standard':10, key:10)
		       else
			 begin write(output,'declared':10,' ':4,ord(next):6);
			   write(output,pflev,' ':4,pfname:6);
			   if pfkind = actual then
			     begin write(output,'actual':10);
			       if forwdecl then write(output,'forward':10)
			       else write(output,'notforward':10);
			       if externl then write(output,'extern':10)
			       else write(output,'not extern':10);
			     end
			   else write(output,'formal':10)
			 end
		     end
	    end (*case*);
	    writeln(output);
	    followctp(llink); followctp(rlink);
	    followstp(idtype)
	  end (*with*)
    end (*followctp*);

  begin (*printtables*)
    writeln(output); writeln(output); writeln(output);
    if fb then lim := 0
    else begin lim := top; write(output,' local') end;
    writeln(output,' tables '); writeln(output);
    marker;
    for i := top downto lim do
      followctp(display[i].fname);
    writeln(output);
    if not eol then write(output,' ':chcnt+16)
  end (*printtables*);

  procedure genlabel(var nxtlab: integer);
  begin intlabel := intlabel + 1;
    nxtlab := intlabel
  end (*genlabel*);

  procedure block(fsys: setofsys; fsy: symbol; fprocp: ctp);
    var lsy: symbol; test: boolean;

    procedure skip(fsys: setofsys);
      (*skip input string until relevant symbol found*)
    begin
      if not eof(input) then
	begin while not(sy in fsys) and (not eof(input)) do insymbol;
	  if not (sy in fsys) then insymbol
	end
    end (*skip*) ;

    procedure constant(fsys: setofsys; var fsp: stp; var fvalu: valu);
      var lsp: stp; lcp: ctp; sign: (none,pos,neg);
	  lvp: csp; i: 2..strglgth;
    begin lsp := nil; fvalu.ival := 0;
      if not(sy in constbegsys) then
	begin error(50); skip(fsys+constbegsys) end;
      if sy in constbegsys then
	begin
	  if sy = stringconst then
	    begin
	      if lgth = 1 then lsp := charptr
	      else
		begin
		  new(lsp,arrays);
		  with lsp^ do
		    begin aeltype := charptr; inxtype := nil;
		       size := lgth*charsize; form := arrays
		    end
		end;
	      fvalu := val; insymbol
	    end
	  else
	    begin
	      sign := none;
	      if (sy = addop) and (op in [plus,minus]) then
		begin if op = plus then sign := pos else sign := neg;
		  insymbol
		end;
	      if sy = ident then
		begin searchid([konst],lcp);
		  with lcp^ do
		    begin lsp := idtype; fvalu := values end;
		  if sign <> none then
		    if lsp = intptr then
		      begin if sign = neg then fvalu.ival := -fvalu.ival end
		    else
		      if lsp = realptr then
			begin
			  if sign = neg then
			    begin new(lvp,reel);
			      if fvalu.valp^.rval[1] = '-' then
				lvp^.rval[1] := '+'
			      else lvp^.rval[1] := '-';
			      for i := 2 to strglgth do
				lvp^.rval[i] := fvalu.valp^.rval[i];
			      fvalu.valp := lvp;
			    end
			  end
			else error(105);
		  insymbol;
		end
	      else
		if sy = intconst then
		  begin if sign = neg then val.ival := -val.ival;
		    lsp := intptr; fvalu := val; insymbol
		  end
		else
		  if sy = realconst then
		    begin if sign = neg then val.valp^.rval[1] := '-';
		      lsp := realptr; fvalu := val; insymbol
		    end
		  else
		    begin error(106); skip(fsys) end
	    end;
	  if not (sy in fsys) then
	    begin error(6); skip(fsys) end
	  end;
      fsp := lsp
    end (*constant*) ;

    function equalbounds(fsp1,fsp2: stp): boolean;
      var lmin1,lmin2,lmax1,lmax2: integer;
    begin
      if (fsp1=nil) or (fsp2=nil) then equalbounds := true
      else
	begin
	  getbounds(fsp1,lmin1,lmax1);
	  getbounds(fsp2,lmin2,lmax2);
	  equalbounds := (lmin1=lmin2) and (lmax1=lmax2)
	end
    end (*equalbounds*) ;

    function comptypes(fsp1,fsp2: stp) : boolean;
      (*decide whether structures pointed at by fsp1 and fsp2 are compatible*)
      var nxt1,nxt2: ctp; comp: boolean;
	ltestp1,ltestp2 : testp;
    begin
      if fsp1 = fsp2 then comptypes := true
      else
	if (fsp1 <> nil) and (fsp2 <> nil) then
	  if fsp1^.form = fsp2^.form then
	    case fsp1^.form of
	      scalar:
		comptypes := false;
		(* identical scalars declared on different levels are
		 not recognized to be compatible*)
	      subrange:
		comptypes := comptypes(fsp1^.rangetype,fsp2^.rangetype);
	      pointer:
		  begin
		    comp := false; ltestp1 := globtestp;
		    ltestp2 := globtestp;
		    while ltestp1 <> nil do
		      with ltestp1^ do
			begin
			  if (elt1 = fsp1^.eltype) and
			     (elt2 = fsp2^.eltype) then comp := true;
			  ltestp1 := lasttestp
			end;
		    if not comp then
		      begin new(ltestp1);
			with ltestp1^ do
			  begin elt1 := fsp1^.eltype;
			    elt2 := fsp2^.eltype;
			    lasttestp := globtestp
			  end;
			globtestp := ltestp1;
			comp := comptypes(fsp1^.eltype,fsp2^.eltype)
		      end;
		    comptypes := comp; globtestp := ltestp2
		  end;
	      power:
		comptypes := comptypes(fsp1^.elset,fsp2^.elset);
	      arrays:
		begin
		  comp := comptypes(fsp1^.aeltype,fsp2^.aeltype)
		      and comptypes(fsp1^.inxtype,fsp2^.inxtype);
		  comptypes := comp and (fsp1^.size = fsp2^.size) and
		      equalbounds(fsp1^.inxtype,fsp2^.inxtype)
		end;
	      records:
		begin nxt1 := fsp1^.fstfld; nxt2 := fsp2^.fstfld; comp:=true;
		  while (nxt1 <> nil) and (nxt2 <> nil) do
		    begin comp:=comp and comptypes(nxt1^.idtype,nxt2^.idtype);
		      nxt1 := nxt1^.next; nxt2 := nxt2^.next
		    end;
		  comptypes := comp and (nxt1 = nil) and (nxt2 = nil)
			      and(fsp1^.recvar = nil)and(fsp2^.recvar = nil)
		end;
		(*identical records are recognized to be compatible
		 iff no variants occur*)
	      files:
		comptypes := comptypes(fsp1^.filtype,fsp2^.filtype)
	    end (*case*)
	  else (*fsp1^.form <> fsp2^.form*)
	    if fsp1^.form = subrange then
	      comptypes := comptypes(fsp1^.rangetype,fsp2)
	    else
	      if fsp2^.form = subrange then
		comptypes := comptypes(fsp1,fsp2^.rangetype)
	      else comptypes := false
	else comptypes := true
    end (*comptypes*) ;

    function string(fsp: stp) : boolean;
    begin string := false;
      if fsp <> nil then
	if fsp^.form = arrays then
	  if comptypes(fsp^.aeltype,charptr) then string := true
    end (*string*) ;

    procedure typ(fsys: setofsys; var fsp: stp; var fsize: addrrange);
      var lsp,lsp1,lsp2: stp; oldtop: disprange; lcp: ctp;
	  lsize,displ: addrrange; lmin,lmax: integer;

      procedure simpletype(fsys:setofsys; var fsp:stp; var fsize:addrrange);
	var lsp,lsp1: stp; lcp,lcp1: ctp; ttop: disprange;
	    lcnt: integer; lvalu: valu;
      begin fsize := 1;
	if not (sy in simptypebegsys) then
	  begin error(1); skip(fsys + simptypebegsys) end;
	if sy in simptypebegsys then
	  begin
	    if sy = lparent then
	      begin ttop := top;   (*decl. consts local to innermost block*)
		while display[top].occur <> blck do top := top - 1;
		new(lsp,scalar,declared);
		with lsp^ do
		  begin size := intsize; form := scalar;
		    scalkind := declared
		  end;
		lcp1 := nil; lcnt := 0;
		repeat insymbol;
		  if sy = ident then
		    begin new(lcp,konst);
		      with lcp^ do
			begin name := id; idtype := lsp; next := lcp1;
			  values.ival := lcnt; klass := konst
			end;
		      enterid(lcp);
		      lcnt := lcnt + 1;
		      lcp1 := lcp; insymbol
		    end
		  else error(2);
		  if not (sy in fsys + [comma,rparent]) then
		    begin error(6); skip(fsys + [comma,rparent]) end
		until sy <> comma;
		lsp^.fconst := lcp1; top := ttop;
		if sy = rparent then insymbol else error(4)
	      end
	    else
	      begin
		if sy = ident then
		  begin searchid([types,konst],lcp);
		    insymbol;
		    if lcp^.klass = konst then
		      begin new(lsp,subrange);
			with lsp^, lcp^ do
			  begin rangetype := idtype; form := subrange;
			    if string(rangetype) then
			      begin error(148); rangetype := nil end;
			    min := values; size := intsize
			  end;
			if sy = colon then insymbol else error(5);
			constant(fsys,lsp1,lvalu);
			lsp^.max := lvalu;
			if lsp^.rangetype <> lsp1 then error(107)
		      end
		    else
		      begin lsp := lcp^.idtype;
			if lsp <> nil then fsize := lsp^.size
		      end
		  end (*sy = ident*)
		else
		  begin new(lsp,subrange); lsp^.form := subrange;
		    constant(fsys + [colon],lsp1,lvalu);
		    if string(lsp1) then
		      begin error(148); lsp1 := nil end;
		    with lsp^ do
		      begin rangetype:=lsp1; min:=lvalu; size:=intsize end;
		    if sy = colon then insymbol else error(5);
		    constant(fsys,lsp1,lvalu);
		    lsp^.max := lvalu;
		    if lsp^.rangetype <> lsp1 then error(107)
		  end;
		if lsp <> nil then
		  with lsp^ do
		    if form = subrange then
		      if rangetype <> nil then
			if rangetype = realptr then error(399)
			else
			  if min.ival > max.ival then error(102)
	      end;
	    fsp := lsp;
	    if not (sy in fsys) then
	      begin error(6); skip(fsys) end
	  end
	    else fsp := nil
      end (*simpletype*) ;

      procedure fieldlist(fsys: setofsys; var frecvar: stp);
	var lcp,lcp1,nxt,nxt1: ctp; lsp,lsp1,lsp2,lsp3,lsp4: stp;
	    minsize,maxsize,lsize: addrrange; lvalu: valu;
      begin nxt1 := nil; lsp := nil;
	if not (sy in (fsys+[ident,casesy])) then
	  begin error(19); skip(fsys + [ident,casesy]) end;
	while sy = ident do
	  begin nxt := nxt1;
	    repeat
	      if sy = ident then
		begin new(lcp,field);
		  with lcp^ do
		    begin name := id; idtype := nil; next := nxt;
		      klass := field
		    end;
		  nxt := lcp;
		  enterid(lcp);
		  insymbol
		end
	      else error(2);
	      if not (sy in [comma,colon]) then
		begin error(6); skip(fsys + [comma,colon,semicolon,casesy])
		end;
	      test := sy <> comma;
	      if not test  then insymbol
	    until test;
	    if sy = colon then insymbol else error(5);
	    typ(fsys + [casesy,semicolon],lsp,lsize);
	    while nxt <> nxt1 do
	      with nxt^ do
		begin align(lsp,displ);
		  idtype := lsp; fldaddr := displ;
		  nxt := next; displ := displ + lsize
		end;
	    nxt1 := lcp;
	    while sy = semicolon do
	      begin insymbol;
		if not (sy in fsys + [ident,casesy,semicolon]) then
		  begin error(19); skip(fsys + [ident,casesy]) end
	      end
	  end (*while*);
	nxt := nil;
	while nxt1 <> nil do
	  with nxt1^ do
	    begin lcp := next; next := nxt; nxt := nxt1; nxt1 := lcp end;
	if sy = casesy then
	  begin new(lsp,tagfld);
	    with lsp^ do
	      begin tagfieldp := nil; fstvar := nil; form:=tagfld end;
	    frecvar := lsp;
	    insymbol;
	    if sy = ident then
	      begin new(lcp,field);
		with lcp^ do
		  begin name := id; idtype := nil; klass:=field;
		    next := nil; fldaddr := displ
		  end;
		enterid(lcp);
		insymbol;
		if sy = colon then insymbol else error(5);
		if sy = ident then
		  begin searchid([types],lcp1);
		    lsp1 := lcp1^.idtype;
		    if lsp1 <> nil then
		      begin align(lsp1,displ);
			lcp^.fldaddr := displ;
			displ := displ+lsp1^.size;
			if (lsp1^.form <= subrange) or string(lsp1) then
			  begin if comptypes(realptr,lsp1) then error(109)
			    else if string(lsp1) then error(399);
			    lcp^.idtype := lsp1; lsp^.tagfieldp := lcp;
			  end
			else error(110);
		      end;
		    insymbol;
		  end
		else begin error(2); skip(fsys + [ofsy,lparent]) end
	      end
	    else begin error(2); skip(fsys + [ofsy,lparent]) end;
	    lsp^.size := displ;
	    if sy = ofsy then insymbol else error(8);
	    lsp1 := nil; minsize := displ; maxsize := displ;
	    repeat lsp2 := nil;
	      if not (sy in fsys + [semicolon]) then
	      begin
		repeat constant(fsys + [comma,colon,lparent],lsp3,lvalu);
		  if lsp^.tagfieldp <> nil then
		   if not comptypes(lsp^.tagfieldp^.idtype,lsp3)then error(111);
		  new(lsp3,variant);
		  with lsp3^ do
		    begin nxtvar := lsp1; subvar := lsp2; varval := lvalu;
		      form := variant
		    end;
		  lsp4 := lsp1;
		  while lsp4 <> nil do
		    with lsp4^ do
		      begin
			if varval.ival = lvalu.ival then error(178);
			lsp4 := nxtvar
		      end;
		  lsp1 := lsp3; lsp2 := lsp3;
		  test := sy <> comma;
		  if not test then insymbol
		until test;
		if sy = colon then insymbol else error(5);
		if sy = lparent then insymbol else error(9);
		fieldlist(fsys + [rparent,semicolon],lsp2);
		if displ > maxsize then maxsize := displ;
		while lsp3 <> nil do
		  begin lsp4 := lsp3^.subvar; lsp3^.subvar := lsp2;
		    lsp3^.size := displ;
		    lsp3 := lsp4
		  end;
		if sy = rparent then
		  begin insymbol;
		    if not (sy in fsys + [semicolon]) then
		      begin error(6); skip(fsys + [semicolon]) end
		  end
		else error(4);
	      end;
	      test := sy <> semicolon;
	      if not test then
		begin displ := minsize;
		      insymbol
		end
	    until test;
	    displ := maxsize;
	    lsp^.fstvar := lsp1;
	  end
	else frecvar := nil
      end (*fieldlist*) ;

    begin (*typ*)
      if not (sy in typebegsys) then
	 begin error(10); skip(fsys + typebegsys) end;
      if sy in typebegsys then
	begin
	  if sy in simptypebegsys then simpletype(fsys,fsp,fsize)
	  else
    (*^*)     if sy = arrow then
	      begin new(lsp,pointer); fsp := lsp;
		with lsp^ do
		  begin eltype := nil; size := ptrsize; form:=pointer end;
		insymbol;
		if sy = ident then
		  begin prterr := false; (*no error if search not successful*)
		    searchid([types],lcp); prterr := true;
		    if lcp = nil then   (*forward referenced type id*)
		      begin new(lcp,types);
			with lcp^ do
			  begin name := id; idtype := lsp;
			    next := fwptr; klass := types
			  end;
			fwptr := lcp
		      end
		    else
		      begin
			if lcp^.idtype <> nil then
			  if lcp^.idtype^.form = files then error(108)
			  else lsp^.eltype := lcp^.idtype
		      end;
		    insymbol;
		  end
		else error(2);
	      end
	    else
	      begin
		if sy = packedsy then
		  begin insymbol;
		    if not (sy in typedels) then
		      begin
			error(10); skip(fsys + typedels)
		      end
		  end;
    (*array*)     if sy = arraysy then
		  begin insymbol;
		    if sy = lbrack then insymbol else error(11);
		    lsp1 := nil;
		    repeat new(lsp,arrays);
		      with lsp^ do
			begin aeltype := lsp1; inxtype := nil; form:=arrays end;
		      lsp1 := lsp;
		      simpletype(fsys + [comma,rbrack,ofsy],lsp2,lsize);
		      lsp1^.size := lsize;
		      if lsp2 <> nil then
			if lsp2^.form <= subrange then
			  begin
			    if lsp2 = realptr then
			      begin error(109); lsp2 := nil end
			    else
			      if lsp2 = intptr then
				begin error(149); lsp2 := nil end;
			    lsp^.inxtype := lsp2
			  end
			else begin error(113); lsp2 := nil end;
		      test := sy <> comma;
		      if not test then insymbol
		    until test;
		    if sy = rbrack then insymbol else error(12);
		    if sy = ofsy then insymbol else error(8);
		    typ(fsys,lsp,lsize);
		    repeat
		      with lsp1^ do
			begin lsp2 := aeltype; aeltype := lsp;
			  if inxtype <> nil then
			    begin getbounds(inxtype,lmin,lmax);
			      align(lsp,lsize);
			      lsize := lsize*(lmax - lmin + 1);
			      size := lsize
			    end
			end;
		      lsp := lsp1; lsp1 := lsp2
		    until lsp1 = nil
		  end
		else
    (*record*)      if sy = recordsy then
		    begin insymbol;
		      oldtop := top;
		      if top < displimit then
			begin top := top + 1;
			  with display[top] do
			    begin fname := nil;
				  flabel := nil;
				  occur := rec
			    end
			end
		      else error(250);
		      displ := 0;
		      fieldlist(fsys-[semicolon]+[endsy],lsp1);
		      new(lsp,records);
		      with lsp^ do
			begin fstfld := display[top].fname;
			  recvar := lsp1; size := displ; form := records
			end;
		      top := oldtop;
		      if sy = endsy then insymbol else error(13)
		    end
		  else
    (*set*)	   if sy = setsy then
		      begin insymbol;
			if sy = ofsy then insymbol else error(8);
			simpletype(fsys,lsp1,lsize);
			if lsp1 <> nil then
			  if lsp1^.form > subrange then
			    begin error(115); lsp1 := nil end
			  else
			    if lsp1 = realptr then
			      begin error(114); lsp1 := nil end
			    else if lsp1 = intptr then
			      begin error(169); lsp1 := nil end
			    else
			      begin getbounds(lsp1,lmin,lmax);
				if (lmin < setlow) or (lmax > sethigh)
				  then error(169);
			      end;
			new(lsp,power);
			with lsp^ do
			  begin elset:=lsp1; size:=setsize; form:=power end;
		      end
		    else
    (*file*)	    if sy = filesy then
			  begin insymbol;
			    error(399); skip(fsys); lsp := nil
			  end;
		fsp := lsp
	      end;
	  if not (sy in fsys) then
	    begin error(6); skip(fsys) end
	end
      else fsp := nil;
      if fsp = nil then fsize := 1 else fsize := fsp^.size
    end (*typ*) ;

    procedure labeldeclaration;
      var llp: lbp; redef: boolean; lbname: integer;
    begin
      repeat
	if sy = intconst then
	  with display[top] do
	    begin llp := flabel; redef := false;
	      while (llp <> nil) and not redef do
		if llp^.labval <> val.ival then
		  llp := llp^.nextlab
		else begin redef := true; error(166) end;
	      if not redef then
		begin new(llp);
		  with llp^ do
		    begin labval := val.ival; genlabel(lbname);
		      defined := false; nextlab := flabel; labname := lbname
		    end;
		  flabel := llp
		end;
	      insymbol
	    end
	else error(15);
	if not ( sy in fsys + [comma, semicolon] ) then
	  begin error(6); skip(fsys+[comma,semicolon]) end;
	test := sy <> comma;
	if not test then insymbol
      until test;
      if sy = semicolon then insymbol else error(14)
    end (* labeldeclaration *) ;

    procedure constdeclaration;
      var lcp: ctp; lsp: stp; lvalu: valu;
    begin
      if sy <> ident then
	begin error(2); skip(fsys + [ident]) end;
      while sy = ident do
	begin new(lcp,konst);
	  with lcp^ do
	    begin name := id; idtype := nil; next := nil; klass:=konst end;
	  insymbol;
	  if (sy = relop) and (op = eqop) then insymbol else error(16);
	  constant(fsys + [semicolon],lsp,lvalu);
	  enterid(lcp);
	  lcp^.idtype := lsp; lcp^.values := lvalu;
	  if sy = semicolon then
	    begin insymbol;
	      if not (sy in fsys + [ident]) then
		begin error(6); skip(fsys + [ident]) end
	    end
	  else error(14)
	end
    end (*constdeclaration*) ;

    procedure typedeclaration;
      var lcp,lcp1,lcp2: ctp; lsp: stp; lsize: addrrange;
    begin
      if sy <> ident then
	begin error(2); skip(fsys + [ident]) end;
      while sy = ident do
	begin new(lcp,types);
	  with lcp^ do
	    begin name := id; idtype := nil; klass := types end;
	  insymbol;
	  if (sy = relop) and (op = eqop) then insymbol else error(16);
	  typ(fsys + [semicolon],lsp,lsize);
	  enterid(lcp);
	  lcp^.idtype := lsp;
	  (*has any forward reference been satisfied:*)
	  lcp1 := fwptr;
	  while lcp1 <> nil do
	    begin
	      if lcp1^.name = lcp^.name then
		begin lcp1^.idtype^.eltype := lcp^.idtype;
		  if lcp1 <> fwptr then
		    lcp2^.next := lcp1^.next
		  else fwptr := lcp1^.next;
		end
	      else lcp2 := lcp1;
	      lcp1 := lcp1^.next
	    end;
	  if sy = semicolon then
	    begin insymbol;
	      if not (sy in fsys + [ident]) then
		begin error(6); skip(fsys + [ident]) end
	    end
	  else error(14)
	end;
      if fwptr <> nil then
	begin error(117); writeln(output);
	  repeat writeln(output,' type-id ',fwptr^.name);
	    fwptr := fwptr^.next
	  until fwptr = nil;
	  if not eol then write(output,' ': chcnt+16)
	end
    end (*typedeclaration*) ;

    procedure vardeclaration;
      var lcp,nxt: ctp; lsp: stp; lsize: addrrange;
    begin nxt := nil;
      repeat
	repeat
	  if sy = ident then
	    begin new(lcp,vars);
	      with lcp^ do
	       begin name := id; next := nxt; klass := vars;
		  idtype := nil; vkind := actual; vlev := level
		end;
	      enterid(lcp);
	      nxt := lcp;
	      insymbol;
	    end
	  else error(2);
	  if not (sy in fsys + [comma,colon] + typedels) then
	    begin error(6); skip(fsys+[comma,colon,semicolon]+typedels) end;
	  test := sy <> comma;
	  if not test then insymbol
	until test;
	if sy = colon then insymbol else error(5);
	typ(fsys + [semicolon] + typedels,lsp,lsize);
	while nxt <> nil do
	  with  nxt^ do
	    begin align(lsp,lc);
	      idtype := lsp; vaddr := lc;
	      lc := lc + lsize; nxt := next
	    end;
	if sy = semicolon then
	  begin insymbol;
	    if not (sy in fsys + [ident]) then
	      begin error(6); skip(fsys + [ident]) end
	  end
	else error(14)
      until (sy <> ident) and not (sy in typedels);
      if fwptr <> nil then
	begin error(117); writeln(output);
	  repeat writeln(output,' type-id ',fwptr^.name);
	    fwptr := fwptr^.next
	  until fwptr = nil;
	  if not eol then write(output,' ': chcnt+16)
	end
    end (*vardeclaration*) ;

    procedure procdeclaration(fsy: symbol);
      var oldlev: 0..maxlevel; lcp,lcp1: ctp; lsp: stp;
	  forw: boolean; oldtop: disprange;
	  llc,lcm: addrrange; lbname: integer; markp: marktype;

      procedure parameterlist(fsy: setofsys; var fpar: ctp);
	var lcp,lcp1,lcp2,lcp3: ctp; lsp: stp; lkind: idkind;
	  llc,lsize: addrrange; count: integer;
      begin lcp1 := nil;
	if not (sy in fsy + [lparent]) then
	  begin error(7); skip(fsys + fsy + [lparent]) end;
	if sy = lparent then
	  begin if forw then error(119);
	    insymbol;
	    if not (sy in [ident,varsy,procsy,funcsy]) then
	      begin error(7); skip(fsys + [ident,rparent]) end;
	    while sy in [ident,varsy,procsy,funcsy] do
	      begin
		if sy = procsy then
		  begin error(399);
		    repeat insymbol;
		      if sy = ident then
			begin new(lcp,proc,declared,formal);
			  with lcp^ do
			    begin name := id; idtype := nil; next := lcp1;
			      pflev := level (*beware of parameter procedures*);
			      klass:=proc;pfdeckind:=declared;pfkind:=formal
			    end;
			  enterid(lcp);
			  lcp1 := lcp;
			  align(parmptr,lc);
			  (*lc := lc + some size *)
			  insymbol
			end
		      else error(2);
		      if not (sy in fsys + [comma,semicolon,rparent]) then
			begin error(7);skip(fsys+[comma,semicolon,rparent])end
		    until sy <> comma
		  end
		else
		  begin
		    if sy = funcsy then
		      begin error(399); lcp2 := nil;
			repeat insymbol;
			  if sy = ident then
			    begin new(lcp,func,declared,formal);
			      with lcp^ do
				begin name := id; idtype := nil; next := lcp2;
				  pflev := level (*beware param funcs*);
				  klass:=func;pfdeckind:=declared;
				  pfkind:=formal
				end;
			      enterid(lcp);
			     lcp2 := lcp;
			     align(parmptr,lc);
			     (*lc := lc + some size*)
			      insymbol;
			    end;
			  if not (sy in [comma,colon] + fsys) then
			    begin error(7);skip(fsys+[comma,semicolon,rparent])
			    end
			until sy <> comma;
			if sy = colon then
			  begin insymbol;
			    if sy = ident then
			      begin searchid([types],lcp);
				lsp := lcp^.idtype;
				if lsp <> nil then
				 if not(lsp^.form in[scalar,subrange,pointer])
				    then begin error(120); lsp := nil end;
				lcp3 := lcp2;
				while lcp2 <> nil do
				  begin lcp2^.idtype := lsp; lcp := lcp2;
				    lcp2 := lcp2^.next
				  end;
				lcp^.next := lcp1; lcp1 := lcp3;
				insymbol
			      end
			    else error(2);
			    if not (sy in fsys + [semicolon,rparent]) then
			      begin error(7);skip(fsys+[semicolon,rparent])end
			  end
			else error(5)
		      end
		    else
		      begin
			if sy = varsy then
			  begin lkind := formal; insymbol end
			else lkind := actual;
			lcp2 := nil;
			count := 0;
			repeat
			  if sy = ident then
			    begin new(lcp,vars);
			      with lcp^ do
				begin name:=id; idtype:=nil; klass:=vars;
				  vkind := lkind; next := lcp2; vlev := level;
				end;
			      enterid(lcp);
			      lcp2 := lcp; count := count+1;
			      insymbol;
			    end;
			  if not (sy in [comma,colon] + fsys) then
			    begin error(7);skip(fsys+[comma,semicolon,rparent])
			    end;
			  test := sy <> comma;
			  if not test then insymbol
			until test;
			if sy = colon then
			  begin insymbol;
			    if sy = ident then
			      begin searchid([types],lcp);
				lsp := lcp^.idtype;
				lsize := ptrsize;
				if lsp <> nil then
				  if lkind=actual then
				    if lsp^.form<=power then lsize := lsp^.size
				    else if lsp^.form=files then error(121);
				align(parmptr,lsize);
				lcp3 := lcp2;
				align(parmptr,lc);
				lc := lc+count*lsize;
				llc := lc;
				while lcp2 <> nil do
				  begin lcp := lcp2;
				    with lcp2^ do
				      begin idtype := lsp;
					llc := llc-lsize;
					vaddr := llc;
				      end;
				    lcp2 := lcp2^.next
				  end;
				lcp^.next := lcp1; lcp1 := lcp3;
				insymbol
			      end
			    else error(2);
			    if not (sy in fsys + [semicolon,rparent]) then
			      begin error(7);skip(fsys+[semicolon,rparent])end
			  end
			else error(5);
		      end;
		  end;
		if sy = semicolon then
		  begin insymbol;
		    if not (sy in fsys + [ident,varsy,procsy,funcsy]) then
		      begin error(7); skip(fsys + [ident,rparent]) end
		  end
	      end (*while*) ;
	    if sy = rparent then
	      begin insymbol;
		if not (sy in fsy + fsys) then
		  begin error(6); skip(fsy + fsys) end
	      end
	    else error(4);
	    lcp3 := nil;
	    (*reverse pointers and reserve local cells for copies of multiple
	     values*)
	    while lcp1 <> nil do
	      with lcp1^ do
		begin lcp2 := next; next := lcp3;
		  if klass = vars then
		    if idtype <> nil then
		      if (vkind=actual)and(idtype^.form>power) then
			begin align(idtype,lc);
			  vaddr := lc;
			  lc := lc+idtype^.size;
			end;
		  lcp3 := lcp1; lcp1 := lcp2
		end;
	    fpar := lcp3
	  end
	    else fpar := nil
    end (*parameterlist*) ;

    begin (*procdeclaration*)
      llc := lc; lc := lcaftermarkstack; forw := false;
      if sy = ident then
	begin searchsection(display[top].fname,lcp); (*decide whether forw.*)
	  if lcp <> nil then
	    begin
	      if lcp^.klass = proc then
		forw := lcp^.forwdecl and(fsy=procsy)and(lcp^.pfkind=actual)
	      else
		if lcp^.klass = func then
		  forw:=lcp^.forwdecl and(fsy=funcsy)and(lcp^.pfkind=actual)
		else forw := false;
	      if not forw then error(160)
	    end;
	  if not forw then
	    begin
	      if fsy = procsy then new(lcp,proc,declared,actual)
	      else new(lcp,func,declared,actual);
	      with lcp^ do
		begin name := id; idtype := nil;
		  externl := false; pflev := level; genlabel(lbname);
		  pfdeckind := declared; pfkind := actual; pfname := lbname;
		  if fsy = procsy then klass := proc
		  else klass := func
		end;
	      enterid(lcp)
	    end
	  else
	    begin lcp1 := lcp^.next;
	      while lcp1 <> nil do
		begin
		  with lcp1^ do
		    if klass = vars then
		      if idtype <> nil then
			begin lcm := vaddr + idtype^.size;
			  if lcm > lc then lc := lcm
			end;
		  lcp1 := lcp1^.next
		end
	    end;
	  insymbol
	end
      else
	begin error(2); lcp := ufctptr end;
      oldlev := level; oldtop := top;
      if level < maxlevel then level := level + 1 else error(251);
      if top < displimit then
	begin top := top + 1;
	  with display[top] do
	    begin
	      if forw then fname := lcp^.next
	      else fname := nil;
	      flabel := nil;
	      occur := blck
	    end
	end
      else error(250);
      if fsy = procsy then
	begin parameterlist([semicolon],lcp1);
	  if not forw then lcp^.next := lcp1
	end
      else
	begin parameterlist([semicolon,colon],lcp1);
	  if not forw then lcp^.next := lcp1;
	  if sy = colon then
	    begin insymbol;
	      if sy = ident then
		begin if forw then error(122);
		  searchid([types],lcp1);
		  lsp := lcp1^.idtype;
		  lcp^.idtype := lsp;
		  if lsp <> nil then
		    if not (lsp^.form in [scalar,subrange,pointer]) then
		      begin error(120); lcp^.idtype := nil end;
		  insymbol
		end
	      else begin error(2); skip(fsys + [semicolon]) end
	    end
	  else
	    if not forw then error(123)
	end;
      if sy = semicolon then insymbol else error(14);
      if sy = forwardsy then
	begin
	  if forw then error(161)
	  else lcp^.forwdecl := true;
	  insymbol;
	  if sy = semicolon then insymbol else error(14);
	  if not (sy in fsys) then
	    begin error(6); skip(fsys) end
	end
      else
	begin lcp^.forwdecl := false; mark(markp);
	  repeat block(fsys,semicolon,lcp);
	    if sy = semicolon then
	      begin if prtables then printtables(false); insymbol;
		if not (sy in [beginsy,procsy,funcsy]) then
		  begin error(6); skip(fsys) end
	      end
	    else error(14)
	  until (sy in [beginsy,procsy,funcsy]) or eof(input);
	  release(markp); (* return local entries on runtime heap *)
	end;
      level := oldlev; top := oldtop; lc := llc;
    end (*procdeclaration*) ;

    procedure body(fsys: setofsys);
      const cstoccmax=65; cixmax=1000;
      type oprange = 0..63;
      var
	  llcp:ctp; saveid:alpha;
	  cstptr: array [1..cstoccmax] of csp;
	  cstptrix: 0..cstoccmax;
	  (*allows referencing of noninteger constants by an index
	   (instead of a pointer), which can be stored in the p2-field
	   of the instruction record until writeout.
	   --> procedure load, procedure writeout*)
	  entname, segsize: integer;
	  stacktop, topnew, topmax: integer;
	  lcmax,llc1: addrrange; lcp: ctp;
	  llp: lbp;


      procedure mes(i: integer);
      begin topnew := topnew + cdx[i]*maxstack;
	if topnew > topmax then topmax := topnew
      end;

      procedure putic;
      begin if ic mod 10 = 0 then writeln(prr,'i',ic:5) end;

      procedure gen0(fop: oprange);
      begin
	if prcode then begin putic; writeln(prr,mn[fop]:4) end;
	ic := ic + 1; mes(fop)
      end (*gen0*) ;

      procedure gen1(fop: oprange; fp2: integer);
	var k: integer;
      begin
	if prcode then
	  begin putic; write(prr,mn[fop]:4);
	    if fop = 30 then
	      begin writeln(prr,sna[fp2]:12);
		topnew := topnew + pdx[fp2]*maxstack;
		if topnew > topmax then topmax := topnew
	      end
	    else
	      begin
		if fop = 38 then
		   begin write(prr,'''');
		     with cstptr[fp2]^ do
		     begin
		       for k := 1 to slgth do write(prr,sval[k]:1);
		       for k := slgth+1 to strglgth do write(prr,' ');
		     end;
		     writeln(prr,'''')
		   end
		else if fop = 42 then writeln(prr,chr(fp2))
		     else writeln(prr,fp2:12);
		mes(fop)
	      end
	  end;
	ic := ic + 1
      end (*gen1*) ;

      procedure gen2(fop: oprange; fp1,fp2: integer);
	var k : integer;
      begin
	if prcode then
	  begin putic; write(prr,mn[fop]:4);
	    case fop of
	      45,50,54,56:
		writeln(prr,' ',fp1:3,fp2:8);
	      47,48,49,52,53,55:
		begin write(prr,chr(fp1));
		  if chr(fp1) = 'm' then write(prr,fp2:11);
		  writeln(prr)
		end;
	      51:
		case fp1 of
		  1: writeln(prr,'i ',fp2);
		  2: begin write(prr,'r ');
		       with cstptr[fp2]^ do
			 for k := 1 to strglgth do write(prr,rval[k]);
		       writeln(prr)
		     end;
		  3: writeln(prr,'b ',fp2);
		  4: writeln(prr,'n');
		  6: writeln(prr,'c ''':3,chr(fp2),'''');
		  5: begin write(prr,'(');
		       with cstptr[fp2]^ do
			 for k := setlow to sethigh do
			   if k in pval then write(prr,k:3);
		       writeln(prr,')')
		     end
		end
	    end;
	  end;
	ic := ic + 1; mes(fop)
      end (*gen2*) ;

      procedure gentypindicator(fsp: stp);
      begin
	if fsp<>nil then
	  with fsp^ do
	    case form of
	     scalar: if fsp=intptr then write(prr,'i')
		     else
		       if fsp=boolptr then write(prr,'b')
		       else
			 if fsp=charptr then write(prr,'c')
			 else
			   if scalkind = declared then write(prr,'i')
			   else write(prr,'r');
	     subrange: gentypindicator(rangetype);
	     pointer:  write(prr,'a');
	     power:    write(prr,'s');
	     records,arrays: write(prr,'m');
	     files,tagfld,variant: error(500)
	    end
      end (*typindicator*);

      procedure gen0t(fop: oprange; fsp: stp);
      begin
	if prcode then
	  begin putic;
	    write(prr,mn[fop]:4);
	    gentypindicator(fsp);
	    writeln(prr);
	  end;
	ic := ic + 1; mes(fop)
      end (*gen0t*);

      procedure gen1t(fop: oprange; fp2: integer; fsp: stp);
      begin
	if prcode then
	  begin putic;
	    write(prr,mn[fop]:4);
	    gentypindicator(fsp);
	    writeln(prr,fp2:11)
	  end;
	ic := ic + 1; mes(fop)
      end (*gen1t*);

      procedure gen2t(fop: oprange; fp1,fp2: integer; fsp: stp);
      begin
	if prcode then
	  begin putic;
	    write(prr,mn[fop]: 4);
	    gentypindicator(fsp);
	    writeln(prr,fp1:3+5*ord(abs(fp1)>99),fp2:8);
	  end;
	ic := ic + 1; mes(fop)
      end (*gen2t*);

      procedure load;
      begin
	with gattr do
	  if typtr <> nil then
	    begin
	      case kind of
		cst:   if (typtr^.form = scalar) and (typtr <> realptr) then
			 if typtr = boolptr then gen2(51(*ldc*),3,cval.ival)
			 else
			   if typtr=charptr then
			     gen2(51(*ldc*),6,cval.ival)
			   else gen2(51(*ldc*),1,cval.ival)
		       else
			 if typtr = nilptr then gen2(51(*ldc*),4,0)
			 else
			   if cstptrix >= cstoccmax then error(254)
			   else
			     begin cstptrix := cstptrix + 1;
			       cstptr[cstptrix] := cval.valp;
			       if typtr = realptr then
				 gen2(51(*ldc*),2,cstptrix)
			       else
				 gen2(51(*ldc*),5,cstptrix)
			     end;
		varbl: case access of
			 drct:   if vlevel<=1 then
				   gen1t(39(*ldo*),dplmt,typtr)
				 else gen2t(54(*lod*),level-vlevel,dplmt,typtr);
			 indrct: gen1t(35(*ind*),idplmt,typtr);
			 inxd:   error(400)
		       end;
		expr:
	      end;
	      kind := expr
	    end
      end (*load*) ;

      procedure store(var fattr: attr);
      begin
	with fattr do
	  if typtr <> nil then
	    case access of
	      drct:   if vlevel <= 1 then gen1t(43(*sro*),dplmt,typtr)
		      else gen2t(56(*str*),level-vlevel,dplmt,typtr);
	      indrct: if idplmt <> 0 then error(400)
		      else gen0t(26(*sto*),typtr);
	      inxd:   error(400)
	    end
      end (*store*) ;

      procedure loadaddress;
      begin
	with gattr do
	  if typtr <> nil then
	    begin
	      case kind of
		cst:   if string(typtr) then
			 if cstptrix >= cstoccmax then error(254)
			 else
			   begin cstptrix := cstptrix + 1;
			     cstptr[cstptrix] := cval.valp;
			     gen1(38(*lca*),cstptrix)
			   end
		       else error(400);
		varbl: case access of
			 drct:   if vlevel <= 1 then gen1(37(*lao*),dplmt)
				 else gen2(50(*lda*),level-vlevel,dplmt);
			 indrct: if idplmt <> 0 then
				   gen1t(34(*inc*),idplmt,nilptr);
			 inxd:   error(400)
		       end;
		expr:  error(400)
	      end;
	      kind := varbl; access := indrct; idplmt := 0
	    end
      end (*loadaddress*) ;


      procedure genfjp(faddr: integer);
      begin load;
	if gattr.typtr <> nil then
	  if gattr.typtr <> boolptr then error(144);
	if prcode then begin putic; writeln(prr,mn[33]:4,' l':8,faddr:4) end;
	ic := ic + 1; mes(33)
      end (*genfjp*) ;

      procedure genujpxjp(fop: oprange; fp2: integer);
      begin
       if prcode then
	  begin putic; writeln(prr, mn[fop]:4, ' l':8,fp2:4) end;
	ic := ic + 1; mes(fop)
      end (*genujpxjp*);


      procedure gencupent(fop: oprange; fp1,fp2: integer);
      begin
	if prcode then
	  begin putic;
	    writeln(prr,mn[fop]:4,fp1:4,'l':4,fp2:4)
	  end;
	ic := ic + 1; mes(fop)
      end;


      procedure checkbnds(fsp: stp);
	var lmin,lmax: integer;
      begin
	if fsp <> nil then
	  if fsp <> intptr then
	    if fsp <> realptr then
	      if fsp^.form <= subrange then
		begin
		  getbounds(fsp,lmin,lmax);
		  gen2t(45(*chk*),lmin,lmax,fsp)
		end
      end (*checkbnds*);


      procedure putlabel(labname: integer);
      begin if prcode then writeln(prr, 'l', labname:4)
      end (*putlabel*);

      procedure statement(fsys: setofsys);
	label 1;
	var lcp: ctp; llp: lbp;

	procedure expression(fsys: setofsys); forward;

	procedure selector(fsys: setofsys; fcp: ctp);
	var lattr: attr; lcp: ctp; lsize: addrrange; lmin,lmax: integer;
	begin
	  with fcp^, gattr do
	    begin typtr := idtype; kind := varbl;
	      case klass of
		vars:
		  if vkind = actual then
		    begin access := drct; vlevel := vlev;
		      dplmt := vaddr
		    end
		  else
		    begin gen2t(54(*lod*),level-vlev,vaddr,nilptr);
		      access := indrct; idplmt := 0
		    end;
		field:
		  with display[disx] do
		    if occur = crec then
		      begin access := drct; vlevel := clev;
			dplmt := cdspl + fldaddr
		      end
		    else
		      begin
			if level = 1 then gen1t(39(*ldo*),vdspl,nilptr)
			else gen2t(54(*lod*),0,vdspl,nilptr);
			access := indrct; idplmt := fldaddr
		      end;
		func:
		  if pfdeckind = standard then
		    begin error(150); typtr := nil end
		  else
		    begin
		      if pfkind = formal then error(151)
		      else
			if (pflev+1<>level)or(fprocp<>fcp) then error(177);
			begin access := drct; vlevel := pflev + 1;
			  dplmt := 0   (*impl. relat. addr. of fct. result*)
			end
		    end
	      end (*case*)
	    end (*with*);
	  if not (sy in selectsys + fsys) then
	    begin error(59); skip(selectsys + fsys) end;
	  while sy in selectsys do
	    begin
	(*[*) if sy = lbrack then
		begin
		  repeat lattr := gattr;
		    with lattr do
		      if typtr <> nil then
			if typtr^.form <> arrays then
			  begin error(138); typtr := nil end;
		    loadaddress;
		    insymbol; expression(fsys + [comma,rbrack]);
		    load;
		    if gattr.typtr <> nil then
		      if gattr.typtr^.form<>scalar then error(113)
		      else if not comptypes(gattr.typtr,intptr) then
			     gen0t(58(*ord*),gattr.typtr);
		    if lattr.typtr <> nil then
		      with lattr.typtr^ do
			begin
			  if comptypes(inxtype,gattr.typtr) then
			    begin
			      if inxtype <> nil then
				begin getbounds(inxtype,lmin,lmax);
				  if debug then
				    gen2t(45(*chk*),lmin,lmax,intptr);
				  if lmin>0 then gen1t(31(*dec*),lmin,intptr)
				  else if lmin<0 then
				    gen1t(34(*inc*),-lmin,intptr);
				  (*or simply gen1(31,lmin)*)
				end
			    end
			  else error(139);
			  with gattr do
			    begin typtr := aeltype; kind := varbl;
			      access := indrct; idplmt := 0
			    end;
			  if gattr.typtr <> nil then
			    begin
			      lsize := gattr.typtr^.size;
			      align(gattr.typtr,lsize);
			      gen1(36(*ixa*),lsize)
			    end
			end
		  until sy <> comma;
		  if sy = rbrack then insymbol else error(12)
		end (*if sy = lbrack*)
	      else
	(*.*)   if sy = period then
		  begin
		    with gattr do
		      begin
			if typtr <> nil then
			  if typtr^.form <> records then
			    begin error(140); typtr := nil end;
			insymbol;
			if sy = ident then
			  begin
			    if typtr <> nil then
			      begin searchsection(typtr^.fstfld,lcp);
				if lcp = nil then
				  begin error(152); typtr := nil end
				else
				  with lcp^ do
				    begin typtr := idtype;
				      case access of
					drct:   dplmt := dplmt + fldaddr;
					indrct: idplmt := idplmt + fldaddr;
					inxd:   error(400)
				      end
				    end
			      end;
			    insymbol
			  end (*sy = ident*)
			else error(2)
		      end (*with gattr*)
		  end (*if sy = period*)
		else
	(*^*)     begin
		    if gattr.typtr <> nil then
		      with gattr,typtr^ do
			if form = pointer then
			  begin load; typtr := eltype;
			    if debug then gen2t(45(*chk*),1,maxaddr,nilptr);
			    with gattr do
			      begin kind := varbl; access := indrct;
				idplmt := 0
			      end
			  end
			else
			  if form = files then typtr := filtype
			  else error(141);
		    insymbol
		  end;
	      if not (sy in fsys + selectsys) then
		begin error(6); skip(fsys + selectsys) end
	    end (*while*)
	end (*selector*) ;

	procedure call(fsys: setofsys; fcp: ctp);
	  var lkey: 1..15;

	  procedure variable(fsys: setofsys);
	    var lcp: ctp;
	  begin
	    if sy = ident then
	      begin searchid([vars,field],lcp); insymbol end
	    else begin error(2); lcp := uvarptr end;
	    selector(fsys,lcp)
	  end (*variable*) ;

	  procedure getputresetrewrite;
	  begin variable(fsys + [rparent]); loadaddress;
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form <> files then error(116);
	    if lkey <= 2 then gen1(30(*csp*),lkey(*get,put*))
	    else error(399)
	  end (*getputresetrewrite*) ;

	  procedure read;
	    var llev:levrange; laddr:addrrange;
		lsp : stp;
	  begin
	    llev := 1; laddr := lcaftermarkstack;
	    if sy = lparent then
	      begin insymbol;
		variable(fsys + [comma,rparent]);
		lsp := gattr.typtr; test := false;
		if lsp <> nil then
		  if lsp^.form = files then
		    with gattr, lsp^ do
		      begin
			if filtype = charptr then
			  begin llev := vlevel; laddr := dplmt end
			else error(399);
			if sy = rparent then
			  begin if lkey = 5 then error(116);
			    test := true
			  end
			else
			  if sy <> comma then
			    begin error(116); skip(fsys + [comma,rparent]) end;
			if sy = comma then
			  begin insymbol; variable(fsys + [comma,rparent])
			  end
			else test := true
		      end;
	       if not test then
		repeat loadaddress;
		  gen2(50(*lda*),level-llev,laddr);
		  if gattr.typtr <> nil then
		    if gattr.typtr^.form <= subrange then
		      if comptypes(intptr,gattr.typtr) then
			gen1(30(*csp*),3(*rdi*))
		      else
			if comptypes(realptr,gattr.typtr) then
			  gen1(30(*csp*),4(*rdr*))
			else
			  if comptypes(charptr,gattr.typtr) then
			    gen1(30(*csp*),5(*rdc*))
			  else error(399)
		    else error(116);
		  test := sy <> comma;
		  if not test then
		    begin insymbol; variable(fsys + [comma,rparent])
		    end
		until test;
		if sy = rparent then insymbol else error(4)
	      end
	    else if lkey = 5 then error(116);
	    if lkey = 11 then
	      begin gen2(50(*lda*),level-llev,laddr);
		gen1(30(*csp*),21(*rln*))
	      end
	  end (*read*) ;

	  procedure write;
	    var lsp: stp; default : boolean; llkey: 1..15;
		llev:levrange; laddr,len:addrrange;
	  begin llkey := lkey;
	    llev := 1; laddr := lcaftermarkstack + charmax;
	    if sy = lparent then
	    begin insymbol;
	    expression(fsys + [comma,colon,rparent]);
	    lsp := gattr.typtr; test := false;
	    if lsp <> nil then
	      if lsp^.form = files then
		with gattr, lsp^ do
		  begin
		    if filtype = charptr then
		      begin llev := vlevel; laddr := dplmt end
		    else error(399);
		    if sy = rparent then
		      begin if llkey = 6 then error(116);
			test := true
		      end
		    else
		      if sy <> comma then
			begin error(116); skip(fsys+[comma,rparent]) end;
		    if sy = comma then
		      begin insymbol; expression(fsys+[comma,colon,rparent])
		      end
		    else test := true
		  end;
	   if not test then
	    repeat
	      lsp := gattr.typtr;
	      if lsp <> nil then
		if lsp^.form <= subrange then load else loadaddress;
	      if sy = colon then
		begin insymbol; expression(fsys + [comma,colon,rparent]);
		  if gattr.typtr <> nil then
		    if gattr.typtr <> intptr then error(116);
		  load; default := false
		end
	      else default := true;
	      if sy = colon then
		begin insymbol; expression(fsys + [comma,rparent]);
		  if gattr.typtr <> nil then
		    if gattr.typtr <> intptr then error(116);
		  if lsp <> realptr then error(124);
		  load; error(399);
		end
	      else
		if lsp = intptr then
		  begin if default then gen2(51(*ldc*),1,10);
		    gen2(50(*lda*),level-llev,laddr);
		    gen1(30(*csp*),6(*wri*))
		  end
		else
		  if lsp = realptr then
		    begin if default then gen2(51(*ldc*),1,20);
		      gen2(50(*lda*),level-llev,laddr);
		      gen1(30(*csp*),8(*wrr*))
		    end
		  else
		    if lsp = charptr then
		      begin if default then gen2(51(*ldc*),1,1);
			gen2(50(*lda*),level-llev,laddr);
			gen1(30(*csp*),9(*wrc*))
		      end
		    else
		      if lsp <> nil then
			begin
			  if lsp^.form = scalar then error(399)
			  else
			    if string(lsp) then
			      begin len := lsp^.size div charmax;
				if default then
				      gen2(51(*ldc*),1,len);
				gen2(51(*ldc*),1,len);
				gen2(50(*lda*),level-llev,laddr);
				gen1(30(*csp*),10(*wrs*))
			      end
			    else error(116)
			end;
	      test := sy <> comma;
	      if not test then
		begin insymbol; expression(fsys + [comma,colon,rparent])
		end
	    until test;
	    if sy = rparent then insymbol else error(4)
	    end
	      else if lkey = 6 then error(116);
	    if llkey = 12 then (*writeln*)
	      begin gen2(50(*lda*),level-llev,laddr);
		gen1(30(*csp*),22(*wln*))
	      end
	  end (*write*) ;

	  procedure pack;
	    var lsp,lsp1: stp;
	  begin error(399); variable(fsys + [comma,rparent]);
	    lsp := nil; lsp1 := nil;
	    if gattr.typtr <> nil then
	      with gattr.typtr^ do
		if form = arrays then
		  begin lsp := inxtype; lsp1 := aeltype end
		else error(116);
	    if sy = comma then insymbol else error(20);
	    expression(fsys + [comma,rparent]);
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form <> scalar then error(116)
	      else
		if not comptypes(lsp,gattr.typtr) then error(116);
	    if sy = comma then insymbol else error(20);
	    variable(fsys + [rparent]);
	    if gattr.typtr <> nil then
	      with gattr.typtr^ do
		if form = arrays then
		  begin
		    if not comptypes(aeltype,lsp1)
		      or not comptypes(inxtype,lsp) then
		      error(116)
		  end
		else error(116)
	  end (*pack*) ;

	  procedure unpack;
	    var lsp,lsp1: stp;
	  begin error(399); variable(fsys + [comma,rparent]);
	    lsp := nil; lsp1 := nil;
	    if gattr.typtr <> nil then
	      with gattr.typtr^ do
		if form = arrays then
		  begin lsp := inxtype; lsp1 := aeltype end
		else error(116);
	    if sy = comma then insymbol else error(20);
	    variable(fsys + [comma,rparent]);
	    if gattr.typtr <> nil then
	      with gattr.typtr^ do
		if form = arrays then
		  begin
		    if not comptypes(aeltype,lsp1)
		      or not comptypes(inxtype,lsp) then
		      error(116)
		  end
		else error(116);
	    if sy = comma then insymbol else error(20);
	    expression(fsys + [rparent]);
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form <> scalar then error(116)
	      else
		if not comptypes(lsp,gattr.typtr) then error(116);
	  end (*unpack*) ;

	  procedure new;
	    label 1;
	    var lsp,lsp1: stp; varts: integer;
		lsize: addrrange; lval: valu;
	  begin variable(fsys + [comma,rparent]); loadaddress;
	    lsp := nil; varts := 0; lsize := 0;
	    if gattr.typtr <> nil then
	      with gattr.typtr^ do
		if form = pointer then
		  begin
		    if eltype <> nil then
		      begin lsize := eltype^.size;
			if eltype^.form = records then lsp := eltype^.recvar
		      end
		  end
		else error(116);
	    while sy = comma do
	      begin insymbol;constant(fsys + [comma,rparent],lsp1,lval);
		varts := varts + 1;
		(*check to insert here: is constant in tagfieldtype range*)
		if lsp = nil then error(158)
		else
		  if lsp^.form <> tagfld then error(162)
		  else
		    if lsp^.tagfieldp <> nil then
		      if string(lsp1) or (lsp1 = realptr) then error(159)
		      else
			if comptypes(lsp^.tagfieldp^.idtype,lsp1) then
			  begin
			    lsp1 := lsp^.fstvar;
			    while lsp1 <> nil do
			      with lsp1^ do
				if varval.ival = lval.ival then
				  begin lsize := size; lsp := subvar;
				    goto 1
				  end
				else lsp1 := nxtvar;
			    lsize := lsp^.size; lsp := nil;
			  end
			else error(116);
	  1:  end (*while*) ;
	    gen2(51(*ldc*),1,lsize);
	    gen1(30(*csp*),12(*new*));
	  end (*new*) ;

	  procedure mark;
	  begin variable(fsys+[rparent]);
	     if gattr.typtr <> nil then
	       if gattr.typtr^.form = pointer then
		 begin loadaddress; gen1(30(*csp*),23(*sav*)) end
	       else error(116)
	  end(*mark*);

	  procedure release;
	  begin variable(fsys+[rparent]);
		if gattr.typtr <> nil then
		   if gattr.typtr^.form = pointer then
		      begin load; gen1(30(*csp*),13(*rst*)) end
		   else error(116)
	  end (*release*);



	  procedure abs;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr = intptr then gen0(0(*abi*))
	      else
		if gattr.typtr = realptr then gen0(1(*abr*))
		else begin error(125); gattr.typtr := intptr end
	  end (*abs*) ;

	  procedure sqr;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr = intptr then gen0(24(*sqi*))
	      else
		if gattr.typtr = realptr then gen0(25(*sqr*))
		else begin error(125); gattr.typtr := intptr end
	  end (*sqr*) ;

	  procedure trunc;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr <> realptr then error(125);
	    gen0(27(*trc*));
	    gattr.typtr := intptr
	  end (*trunc*) ;

	  procedure odd;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr <> intptr then error(125);
	    gen0(20(*odd*));
	    gattr.typtr := boolptr
	  end (*odd*) ;

	  procedure ord;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form >= power then error(125);
	    gen0t(58(*ord*),gattr.typtr);
	    gattr.typtr := intptr
	  end (*ord*) ;

	  procedure chr;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr <> intptr then error(125);
	    gen0(59(*chr*));
	    gattr.typtr := charptr
	  end (*chr*) ;

	  procedure predsucc;
	  begin
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form <> scalar then error(125);
	    if lkey = 7 then gen1t(31(*dec*),1,gattr.typtr)
	    else gen1t(34(*inc*),1,gattr.typtr)
	  end (*predsucc*) ;

	  procedure eof;
	  begin
	    if sy = lparent then
	      begin insymbol; variable(fsys + [rparent]);
		if sy = rparent then insymbol else error(4)
	      end
	    else
	      with gattr do
		begin typtr := textptr; kind := varbl; access := drct;
		  vlevel := 1; dplmt := lcaftermarkstack
		end;
	    loadaddress;
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form <> files then error(125);
	    if lkey = 9 then gen0(8(*eof*)) else gen1(30(*csp*),14(*eln*));
	      gattr.typtr := boolptr
	  end (*eof*) ;



	  procedure callnonstandard;
	    var nxt,lcp: ctp; lsp: stp; lkind: idkind; lb: boolean;
		locpar, llc: addrrange;
	  begin locpar := 0;
	    with fcp^ do
	      begin nxt := next; lkind := pfkind;
		if not externl then gen1(41(*mst*),level-pflev)
	      end;
	    if sy = lparent then
	      begin llc := lc;
		repeat lb := false; (*decide whether proc/func must be passed*)
		  if lkind = actual then
		    begin
		      if nxt = nil then error(126)
		      else lb := nxt^.klass in [proc,func]
		    end else error(399);
		  (*For formal proc/func, lb is false and expression
		   will be called, which will always interpret a proc/func id
		   at its beginning as a call rather than a parameter passing.
		   In this implementation, parameter procedures/functions
		   are therefore not allowed to have procedure/function
		   parameters*)
		  insymbol;
		  if lb then   (*pass function or procedure*)
		    begin error(399);
		      if sy <> ident then
			begin error(2); skip(fsys + [comma,rparent]) end
		      else
			begin
			  if nxt^.klass = proc then searchid([proc],lcp)
			  else
			    begin searchid([func],lcp);
			      if not comptypes(lcp^.idtype,nxt^.idtype) then
				error(128)
			    end;
			  insymbol;
			  if not (sy in fsys + [comma,rparent]) then
			    begin error(6); skip(fsys + [comma,rparent]) end
			end
		    end (*if lb*)
		  else
		    begin expression(fsys + [comma,rparent]);
		      if gattr.typtr <> nil then
			if lkind = actual then
			  begin
			    if nxt <> nil then
			      begin lsp := nxt^.idtype;
				if lsp <> nil then
				  begin
				    if (nxt^.vkind = actual) then
				      if lsp^.form <= power then
					begin load;
					  if debug then checkbnds(lsp);
					  if comptypes(realptr,lsp)
					     and (gattr.typtr = intptr) then
					    begin gen0(10(*flt*));
					      gattr.typtr := realptr
					    end;
					  locpar := locpar+lsp^.size;
					  align(parmptr,locpar);
					end
				      else
					begin
					  loadaddress;
					  locpar := locpar+ptrsize;
					  align(parmptr,locpar)
					end
				    else
				      if gattr.kind = varbl then
					begin loadaddress;
					  locpar := locpar+ptrsize;
					  align(parmptr,locpar);
					end
				      else error(154);
				    if not comptypes(lsp,gattr.typtr) then
				      error(142)
				  end
			      end
			  end
		      else (*lkind = formal*)
			begin (*pass formal param*)
			end
		    end;
		  if (lkind = actual) and (nxt <> nil) then nxt := nxt^.next
		until sy <> comma;
		lc := llc;
		if sy = rparent then insymbol else error(4)
	      end (*if lparent*);
	    if lkind = actual then
	      begin if nxt <> nil then error(126);
		with fcp^ do
		  begin
		    if externl then gen1(30(*csp*),pfname)
		    else gencupent(46(*cup*),locpar,pfname);
		  end
	      end;
	    gattr.typtr := fcp^.idtype
	  end (*callnonstandard*) ;

	begin (*call*)
	  if fcp^.pfdeckind = standard then
	    begin lkey := fcp^.key;
	      if fcp^.klass = proc then
	       begin
		if not(lkey in [5,6,11,12]) then
		  if sy = lparent then insymbol else error(9);
		case lkey of
		  1,2,
		  3,4:  getputresetrewrite;
		  5,11: read;
		  6,12: write;
		  7:    pack;
		  8:    unpack;
		  9:    new;
		  10:   release;
		  13:   mark
		end;
		if not(lkey in [5,6,11,12]) then
		  if sy = rparent then insymbol else error(4)
	       end
	      else
		begin
		  if lkey <= 8 then
		    begin
		      if sy = lparent then insymbol else error(9);
		      expression(fsys+[rparent]); load
		    end;
		  case lkey of
		    1:    abs;
		    2:    sqr;
		    3:    trunc;
		    4:    odd;
		    5:    ord;
		    6:    chr;
		    7,8:  predsucc;
		    9,10: eof
		  end;
		  if lkey <= 8 then
		    if sy = rparent then insymbol else error(4)
		end;
	    end (*standard procedures and functions*)
	  else callnonstandard
	end (*call*) ;

	procedure expression;
	  var lattr: attr; lop: operator; typind: char; lsize: addrrange;

	  procedure simpleexpression(fsys: setofsys);
	    var lattr: attr; lop: operator; signed: boolean;

	    procedure term(fsys: setofsys);
	      var lattr: attr; lop: operator;

	      procedure factor(fsys: setofsys);
		var lcp: ctp; lvp: csp; varpart: boolean;
		    cstpart: setty; lsp: stp;
	      begin
		if not (sy in facbegsys) then
		  begin error(58); skip(fsys + facbegsys);
		    gattr.typtr := nil
		  end;
		while sy in facbegsys do
		  begin
		    case sy of
	      (*id*)    ident:
			begin searchid([konst,vars,field,func],lcp);
			  insymbol;
			  if lcp^.klass = func then
			    begin call(fsys,lcp);
			      with gattr do
				begin kind := expr;
				  if typtr <> nil then
				    if typtr^.form=subrange then
				      typtr := typtr^.rangetype
				end
			    end
			  else
			    if lcp^.klass = konst then
			      with gattr, lcp^ do
				begin typtr := idtype; kind := cst;
				  cval := values
				end
			    else
			      begin selector(fsys,lcp);
				if gattr.typtr<>nil then(*elim.subr.types to*)
				  with gattr,typtr^ do(*simplify later tests*)
				    if form = subrange then
				      typtr := rangetype
			      end
			end;
	      (*cst*)   intconst:
			begin
			  with gattr do
			    begin typtr := intptr; kind := cst;
			      cval := val
			    end;
			  insymbol
			end;
		      realconst:
			begin
			  with gattr do
			    begin typtr := realptr; kind := cst;
			      cval := val
			    end;
			  insymbol
			end;
		      stringconst:
			begin
			  with gattr do
			    begin
			      if lgth = 1 then typtr := charptr
			      else
				begin new(lsp,arrays);
				  with lsp^ do
				    begin aeltype := charptr; form:=arrays;
				      inxtype := nil; size := lgth*charsize
				    end;
				  typtr := lsp
				end;
			      kind := cst; cval := val
			    end;
			  insymbol
			end;
	      (* ( *)   lparent:
			begin insymbol; expression(fsys + [rparent]);
			  if sy = rparent then insymbol else error(4)
			end;
	      (*not*)   notsy:
			begin insymbol; factor(fsys);
			  load; gen0(19(*not*));
			  if gattr.typtr <> nil then
			    if gattr.typtr <> boolptr then
			      begin error(135); gattr.typtr := nil end;
			end;
	      (*[*)     lbrack:
			begin insymbol; cstpart := [ ]; varpart := false;
			  new(lsp,power);
			  with lsp^ do
			    begin elset:=nil;size:=setsize;form:=power end;
			  if sy = rbrack then
			    begin
			      with gattr do
				begin typtr := lsp; kind := cst end;
			      insymbol
			    end
			  else
			    begin
			      repeat expression(fsys + [comma,rbrack]);
				if gattr.typtr <> nil then
				  if gattr.typtr^.form <> scalar then
				    begin error(136); gattr.typtr := nil end
				  else
				    if comptypes(lsp^.elset,gattr.typtr) then
				      begin
					if gattr.kind = cst then
					  if (gattr.cval.ival < setlow) or
					    (gattr.cval.ival > sethigh) then
					    error(304)
					  else
					    cstpart := cstpart+[gattr.cval.ival]
					else
					  begin load;
					    if not comptypes(gattr.typtr,intptr)
					    then gen0t(58(*ord*),gattr.typtr);
					    gen0(23(*sgs*));
					    if varpart then gen0(28(*uni*))
					    else varpart := true
					  end;
					lsp^.elset := gattr.typtr;
					gattr.typtr := lsp
				      end
				    else error(137);
				test := sy <> comma;
				if not test then insymbol
			      until test;
			      if sy = rbrack then insymbol else error(12)
			    end;
			  if varpart then
			    begin
			      if cstpart <> [ ] then
				begin new(lvp,pset); lvp^.pval := cstpart;
				  lvp^.cclass := pset;
				  if cstptrix = cstoccmax then error(254)
				  else
				    begin cstptrix := cstptrix + 1;
				      cstptr[cstptrix] := lvp;
				      gen2(51(*ldc*),5,cstptrix);
				      gen0(28(*uni*)); gattr.kind := expr
				    end
				end
			    end
			  else
			    begin new(lvp,pset); lvp^.pval := cstpart;
			      lvp^.cclass := pset;
			      gattr.cval.valp := lvp
			    end
			end
		    end (*case*) ;
		    if not (sy in fsys) then
		      begin error(6); skip(fsys + facbegsys) end
		  end (*while*)
	      end (*factor*) ;

	    begin (*term*)
	      factor(fsys + [mulop]);
	      while sy = mulop do
		begin load; lattr := gattr; lop := op;
		  insymbol; factor(fsys + [mulop]); load;
		  if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
		    case lop of
	    (***)     mul:  if (lattr.typtr=intptr)and(gattr.typtr=intptr)
			    then gen0(15(*mpi*))
			    else
			      begin
				if lattr.typtr = intptr then
				  begin gen0(9(*flo*));
				    lattr.typtr := realptr
				  end
				else
				  if gattr.typtr = intptr then
				    begin gen0(10(*flt*));
				      gattr.typtr := realptr
				    end;
				if (lattr.typtr = realptr)
				  and(gattr.typtr=realptr)then gen0(16(*mpr*))
				else
				  if(lattr.typtr^.form=power)
				    and comptypes(lattr.typtr,gattr.typtr)then
				    gen0(12(*int*))
				  else begin error(134); gattr.typtr:=nil end
			      end;
	    (* / *)   rdiv: begin
			      if gattr.typtr = intptr then
				begin gen0(10(*flt*));
				  gattr.typtr := realptr
				end;
			      if lattr.typtr = intptr then
				begin gen0(9(*flo*));
				  lattr.typtr := realptr
				end;
			      if (lattr.typtr = realptr)
				and (gattr.typtr=realptr)then gen0(7(*dvr*))
			      else begin error(134); gattr.typtr := nil end
			    end;
	    (*div*)   idiv: if (lattr.typtr = intptr)
			      and (gattr.typtr = intptr) then gen0(6(*dvi*))
			    else begin error(134); gattr.typtr := nil end;
	    (*mod*)   imod: if (lattr.typtr = intptr)
			      and (gattr.typtr = intptr) then gen0(14(*mod*))
			    else begin error(134); gattr.typtr := nil end;
	    (*and*)   andop:if (lattr.typtr = boolptr)
			      and (gattr.typtr = boolptr) then gen0(4(*and*))
			    else begin error(134); gattr.typtr := nil end
		    end (*case*)
		  else gattr.typtr := nil
		end (*while*)
	    end (*term*) ;

	  begin (*simpleexpression*)
	    signed := false;
	    if (sy = addop) and (op in [plus,minus]) then
	      begin signed := op = minus; insymbol end;
	    term(fsys + [addop]);
	    if signed then
	      begin load;
		if gattr.typtr = intptr then gen0(17(*ngi*))
		else
		  if gattr.typtr = realptr then gen0(18(*ngr*))
		  else begin error(134); gattr.typtr := nil end
	      end;
	    while sy = addop do
	      begin load; lattr := gattr; lop := op;
		insymbol; term(fsys + [addop]); load;
		if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
		  case lop of
	  (*+*)       plus:
		      if (lattr.typtr = intptr)and(gattr.typtr = intptr) then
			gen0(2(*adi*))
		      else
			begin
			  if lattr.typtr = intptr then
			    begin gen0(9(*flo*));
			      lattr.typtr := realptr
			    end
			  else
			    if gattr.typtr = intptr then
			      begin gen0(10(*flt*));
				gattr.typtr := realptr
			      end;
			  if (lattr.typtr = realptr)and(gattr.typtr = realptr)
			    then gen0(3(*adr*))
			  else if(lattr.typtr^.form=power)
				 and comptypes(lattr.typtr,gattr.typtr) then
				 gen0(28(*uni*))
			       else begin error(134); gattr.typtr:=nil end
			end;
	  (*-*)       minus:
		      if (lattr.typtr = intptr)and(gattr.typtr = intptr) then
			gen0(21(*sbi*))
		      else
			begin
			  if lattr.typtr = intptr then
			    begin gen0(9(*flo*));
			      lattr.typtr := realptr
			    end
			  else
			    if gattr.typtr = intptr then
			      begin gen0(10(*flt*));
				gattr.typtr := realptr
			      end;
			  if (lattr.typtr = realptr)and(gattr.typtr = realptr)
			    then gen0(22(*sbr*))
			  else
			    if (lattr.typtr^.form = power)
			      and comptypes(lattr.typtr,gattr.typtr) then
			      gen0(5(*dif*))
			    else begin error(134); gattr.typtr := nil end
			end;
	  (*or*)      orop:
		      if(lattr.typtr=boolptr)and(gattr.typtr=boolptr)then
			gen0(13(*ior*))
		      else begin error(134); gattr.typtr := nil end
		  end (*case*)
		else gattr.typtr := nil
	      end (*while*)
	  end (*simpleexpression*) ;

	begin (*expression*)
	  simpleexpression(fsys + [relop]);
	  if sy = relop then
	    begin
	      if gattr.typtr <> nil then
		if gattr.typtr^.form <= power then load
		else loadaddress;
	      lattr := gattr; lop := op;
	      if lop = inop then
		if not comptypes(gattr.typtr,intptr) then
		  gen0t(58(*ord*),gattr.typtr);
	      insymbol; simpleexpression(fsys);
	      if gattr.typtr <> nil then
		if gattr.typtr^.form <= power then load
		else loadaddress;
	      if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
		if lop = inop then
		  if gattr.typtr^.form = power then
		    if comptypes(lattr.typtr,gattr.typtr^.elset) then
		      gen0(11(*inn*))
		    else begin error(129); gattr.typtr := nil end
		  else begin error(130); gattr.typtr := nil end
		else
		  begin
		    if lattr.typtr <> gattr.typtr then
		      if lattr.typtr = intptr then
			begin gen0(9(*flo*));
			  lattr.typtr := realptr
			end
		      else
			if gattr.typtr = intptr then
			  begin gen0(10(*flt*));
			    gattr.typtr := realptr
			  end;
		    if comptypes(lattr.typtr,gattr.typtr) then
		      begin lsize := lattr.typtr^.size;
			case lattr.typtr^.form of
			  scalar:
			    if lattr.typtr = realptr then typind := 'r'
			    else
			      if lattr.typtr = boolptr then typind := 'b'
			      else
				if lattr.typtr = charptr then typind := 'c'
				else typind := 'i';
			  pointer:
			    begin
			      if lop in [ltop,leop,gtop,geop] then error(131);
			      typind := 'a'
			    end;
			  power:
			    begin if lop in [ltop,gtop] then error(132);
			      typind := 's'
			    end;
			  arrays:
			    begin
			      if not string(lattr.typtr)
				then error(134);
			      typind := 'm'
			    end;
			  records:
			    begin
			      error(134);
			      typind := 'm'
			    end;
			  files:
			    begin error(133); typind := 'f' end
			end;
			case lop of
			  ltop: gen2(53(*les*),ord(typind),lsize);
			  leop: gen2(52(*leq*),ord(typind),lsize);
			  gtop: gen2(49(*grt*),ord(typind),lsize);
			  geop: gen2(48(*geq*),ord(typind),lsize);
			  neop: gen2(55(*neq*),ord(typind),lsize);
			  eqop: gen2(47(*equ*),ord(typind),lsize)
			end
		      end
		    else error(129)
		  end;
	      gattr.typtr := boolptr; gattr.kind := expr
	    end (*sy = relop*)
	end (*expression*) ;

	procedure assignment(fcp: ctp);
	  var lattr: attr;
	begin selector(fsys + [becomes],fcp);
	  if sy = becomes then
	    begin
	      if gattr.typtr <> nil then
		if (gattr.access<>drct) or (gattr.typtr^.form>power) then
		  loadaddress;
	      lattr := gattr;
	      insymbol; expression(fsys);
	      if gattr.typtr <> nil then
		if gattr.typtr^.form <= power then load
		else loadaddress;
	      if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
		begin
		  if comptypes(realptr,lattr.typtr)and(gattr.typtr=intptr)then
		    begin gen0(10(*flt*));
		      gattr.typtr := realptr
		    end;
		  if comptypes(lattr.typtr,gattr.typtr) then
		    case lattr.typtr^.form of
		      scalar,
		      subrange: begin
				  if debug then checkbnds(lattr.typtr);
				  store(lattr)
				end;
		      pointer: begin
				 if debug then
				   gen2t(45(*chk*),0,maxaddr,nilptr);
				 store(lattr)
			       end;
		      power:   store(lattr);
		      arrays,
		      records: gen1(40(*mov*),lattr.typtr^.size);
		      files: error(146)
		    end
		  else error(129)
		end
	    end (*sy = becomes*)
	  else error(51)
	end (*assignment*) ;

	procedure gotostatement;
	  var llp: lbp; found: boolean; ttop,ttop1: disprange;
	begin
	  if sy = intconst then
	    begin
	      found := false;
	      ttop := top;
	      while display[ttop].occur <> blck do ttop := ttop - 1;
	      ttop1 := ttop;
	      repeat
		llp := display[ttop].flabel;
		while (llp <> nil) and not found do
		  with llp^ do
		    if labval = val.ival then
		      begin found := true;
			if ttop = ttop1 then
			  genujpxjp(57(*ujp*),labname)
			else (*goto leads out of procedure*) error(399)
		      end
		    else llp := nextlab;
		ttop := ttop - 1
	      until found or (ttop = 0);
	      if not found then error(167);
	      insymbol
	    end
	  else error(15)
	end (*gotostatement*) ;

	procedure compoundstatement;
	begin
	  repeat
	    repeat statement(fsys + [semicolon,endsy])
	    until not (sy in statbegsys);
	    test := sy <> semicolon;
	    if not test then insymbol
	  until test;
	  if sy = endsy then insymbol else error(13)
	end (*compoundstatemenet*) ;

	procedure ifstatement;
	  var lcix1,lcix2: integer;
	begin expression(fsys + [thensy]);
	  genlabel(lcix1); genfjp(lcix1);
	  if sy = thensy then insymbol else error(52);
	  statement(fsys + [elsesy]);
	  if sy = elsesy then
	    begin genlabel(lcix2); genujpxjp(57(*ujp*),lcix2);
	      putlabel(lcix1);
	      insymbol; statement(fsys);
	      putlabel(lcix2)
	    end
	  else putlabel(lcix1)
	end (*ifstatement*) ;

	procedure casestatement;
	  label 1;
	  type cip = ^caseinfo;
	       caseinfo = packed
			  record next: cip;
			    csstart: integer;
			    cslab: integer
			  end;
	  var lsp,lsp1: stp; fstptr,lpt1,lpt2,lpt3: cip; lval: valu;
	      laddr, lcix, lcix1, lmin, lmax: integer;
	begin expression(fsys + [ofsy,comma,colon]);
	  load; genlabel(lcix);
	  lsp := gattr.typtr;
	  if lsp <> nil then
	    if (lsp^.form <> scalar) or (lsp = realptr) then
	      begin error(144); lsp := nil end
	    else if not comptypes(lsp,intptr) then gen0t(58(*ord*),lsp);
	  genujpxjp(57(*ujp*),lcix);
	  if sy = ofsy then insymbol else error(8);
	  fstptr := nil; genlabel(laddr);
	  repeat
	    lpt3 := nil; genlabel(lcix1);
	    if not(sy in [semicolon,endsy]) then
	      begin
		repeat constant(fsys + [comma,colon],lsp1,lval);
		  if lsp <> nil then
		    if comptypes(lsp,lsp1) then
		      begin lpt1 := fstptr; lpt2 := nil;
			while lpt1 <> nil do
			  with lpt1^ do
			    begin
			      if cslab <= lval.ival then
				begin if cslab = lval.ival then error(156);
				  goto 1
				end;
			      lpt2 := lpt1; lpt1 := next
			    end;
	    1:	  new(lpt3);
			with lpt3^ do
			  begin next := lpt1; cslab := lval.ival;
			    csstart := lcix1
			  end;
			if lpt2 = nil then fstptr := lpt3
			else lpt2^.next := lpt3
		      end
		    else error(147);
		  test := sy <> comma;
		  if not test then insymbol
		until test;
		if sy = colon then insymbol else error(5);
		putlabel(lcix1);
		repeat statement(fsys + [semicolon])
		until not (sy in statbegsys);
		if lpt3 <> nil then
		  genujpxjp(57(*ujp*),laddr);
	      end;
	    test := sy <> semicolon;
	    if not test then insymbol
	  until test;
	  putlabel(lcix);
	  if fstptr <> nil then
	    begin lmax := fstptr^.cslab;
	      (*reverse pointers*)
	      lpt1 := fstptr; fstptr := nil;
	      repeat lpt2 := lpt1^.next; lpt1^.next := fstptr;
		fstptr := lpt1; lpt1 := lpt2
	      until lpt1 = nil;
	      lmin := fstptr^.cslab;
	      if lmax - lmin < cixmax then
		begin
		  gen2t(45(*chk*),lmin,lmax,intptr);
		  gen2(51(*ldc*),1,lmin); gen0(21(*sbi*)); genlabel(lcix);
		  genujpxjp(44(*xjp*),lcix); putlabel(lcix);
		  repeat
		    with fstptr^ do
		      begin
			while cslab > lmin do
			   begin gen0(60(*ujc error*));
			     lmin := lmin+1
			   end;
			genujpxjp(57(*ujp*),csstart);
			fstptr := next; lmin := lmin + 1
		      end
		  until fstptr = nil;
		  putlabel(laddr)
		end
	      else error(157)
	    end;
	    if sy = endsy then insymbol else error(13)
	end (*casestatement*) ;

	procedure repeatstatement;
	  var laddr: integer;
	begin genlabel(laddr); putlabel(laddr);
	  repeat statement(fsys + [semicolon,untilsy]);
	    if sy in statbegsys then error(14)
	  until not(sy in statbegsys);
	  while sy = semicolon do
	    begin insymbol;
	      repeat statement(fsys + [semicolon,untilsy]);
		if sy in statbegsys then error(14)
	      until not (sy in statbegsys);
	    end;
	  if sy = untilsy then
	    begin insymbol; expression(fsys); genfjp(laddr)
	    end
	  else error(53)
	end (*repeatstatement*) ;

	procedure whilestatement;
	  var laddr, lcix: integer;
	begin genlabel(laddr); putlabel(laddr);
	  expression(fsys + [dosy]); genlabel(lcix); genfjp(lcix);
	  if sy = dosy then insymbol else error(54);
	  statement(fsys); genujpxjp(57(*ujp*),laddr); putlabel(lcix)
	end (*whilestatement*) ;

	procedure forstatement;
	  var lattr: attr;  lsy: symbol;
	      lcix, laddr: integer;
		    llc: addrrange;
	begin llc := lc;
	  with lattr do
	    begin typtr := nil; kind := varbl;
	      access := drct; vlevel := level; dplmt := 0
	    end;
	  if sy = ident then
	    begin searchid([vars],lcp);
	      with lcp^, lattr do
		begin typtr := idtype; kind := varbl;
		  if vkind = actual then
		    begin access := drct; vlevel := vlev;
		      dplmt := vaddr
		    end
		  else begin error(155); typtr := nil end
		end;
	      if lattr.typtr <> nil then
		if (lattr.typtr^.form > subrange)
		   or comptypes(realptr,lattr.typtr) then
		  begin error(143); lattr.typtr := nil end;
	      insymbol
	    end
	  else
	    begin error(2); skip(fsys + [becomes,tosy,downtosy,dosy]) end;
	  if sy = becomes then
	    begin insymbol; expression(fsys + [tosy,downtosy,dosy]);
	      if gattr.typtr <> nil then
		  if gattr.typtr^.form <> scalar then error(144)
		  else
		    if comptypes(lattr.typtr,gattr.typtr) then
		      begin load; store(lattr) end
		    else error(145)
	    end
	  else
	    begin error(51); skip(fsys + [tosy,downtosy,dosy]) end;
	  if sy in [tosy,downtosy] then
	    begin lsy := sy; insymbol; expression(fsys + [dosy]);
	      if gattr.typtr <> nil then
	      if gattr.typtr^.form <> scalar then error(144)
		else
		  if comptypes(lattr.typtr,gattr.typtr) then
		    begin load;
		      if not comptypes(lattr.typtr,intptr) then
			gen0t(58(*ord*),gattr.typtr);
		      align(intptr,lc);
		      gen2t(56(*str*),0,lc,intptr);
		      genlabel(laddr); putlabel(laddr);
		      gattr := lattr; load;
		      if not comptypes(gattr.typtr,intptr) then
			gen0t(58(*ord*),gattr.typtr);
		      gen2t(54(*lod*),0,lc,intptr);
		      lc := lc + intsize;
		      if lc > lcmax then lcmax := lc;
		      if lsy = tosy then gen2(52(*leq*),ord('i'),1)
		      else gen2(48(*geq*),ord('i'),1);
		    end
		  else error(145)
	    end
	  else begin error(55); skip(fsys + [dosy]) end;
	  genlabel(lcix); genujpxjp(33(*fjp*),lcix);
	  if sy = dosy then insymbol else error(54);
	  statement(fsys);
	  gattr := lattr; load;
	  if lsy=tosy then gen1t(34(*inc*),1,gattr.typtr)
	  else  gen1t(31(*dec*),1,gattr.typtr);
	  store(lattr); genujpxjp(57(*ujp*),laddr); putlabel(lcix);
	  lc := llc;
	end (*forstatement*) ;


	procedure withstatement;
	  var lcp: ctp; lcnt1: disprange; llc: addrrange;
	begin lcnt1 := 0; llc := lc;
	  repeat
	    if sy = ident then
	      begin searchid([vars,field],lcp); insymbol end
	    else begin error(2); lcp := uvarptr end;
	    selector(fsys + [comma,dosy],lcp);
	    if gattr.typtr <> nil then
	      if gattr.typtr^.form = records then
		if top < displimit then
		  begin top := top + 1; lcnt1 := lcnt1 + 1;
		    with display[top] do
		      begin fname := gattr.typtr^.fstfld;
			flabel := nil
		      end;
		    if gattr.access = drct then
		      with display[top] do
			begin occur := crec; clev := gattr.vlevel;
			  cdspl := gattr.dplmt
			end
		    else
		      begin loadaddress;
			align(nilptr,lc);
			gen2t(56(*str*),0,lc,nilptr);
			with display[top] do
			  begin occur := vrec; vdspl := lc end;
			lc := lc+ptrsize;
			if lc > lcmax then lcmax := lc
		      end
		  end
		else error(250)
	      else error(140);
	    test := sy <> comma;
	    if not test then insymbol
	  until test;
	  if sy = dosy then insymbol else error(54);
	  statement(fsys);
	  top := top-lcnt1; lc := llc;
	end (*withstatement*) ;

      begin (*statement*)
	if sy = intconst then (*label*)
	  begin llp := display[level].flabel;
	    while llp <> nil do
	      with llp^ do
		if labval = val.ival then
		  begin if defined then error(165);
		    putlabel(labname); defined := true;
		    goto 1
		  end
		else llp := nextlab;
	    error(167);
      1:    insymbol;
	    if sy = colon then insymbol else error(5)
	  end;
	if not (sy in fsys + [ident]) then
	  begin error(6); skip(fsys) end;
	if sy in statbegsys + [ident] then
	  begin
	    case sy of
	      ident:    begin searchid([vars,field,func,proc],lcp); insymbol;
			  if lcp^.klass = proc then call(fsys,lcp)
			  else assignment(lcp)
			end;
	      beginsy:  begin insymbol; compoundstatement end;
	      gotosy:   begin insymbol; gotostatement end;
	      ifsy:     begin insymbol; ifstatement end;
	      casesy:   begin insymbol; casestatement end;
	      whilesy:  begin insymbol; whilestatement end;
	      repeatsy: begin insymbol; repeatstatement end;
	      forsy:    begin insymbol; forstatement end;
	      withsy:   begin insymbol; withstatement end
	    end;
	    if not (sy in [semicolon,endsy,elsesy,untilsy]) then
	      begin error(6); skip(fsys) end
	  end
      end (*statement*) ;

    begin (*body*)
      if fprocp <> nil then entname := fprocp^.pfname
      else genlabel(entname);
      cstptrix := 0; topnew := lcaftermarkstack; topmax := lcaftermarkstack;
      putlabel(entname); genlabel(segsize); genlabel(stacktop);
      gencupent(32(*ent1*),1,segsize); gencupent(32(*ent2*),2,stacktop);
      if fprocp <> nil then (*copy multiple values into local cells*)
	begin llc1 := lcaftermarkstack;
	  lcp := fprocp^.next;
	  while lcp <> nil do
	    with lcp^ do
	      begin
		align(parmptr,llc1);
		if klass = vars then
		  if idtype <> nil then
		    if idtype^.form > power then
		      begin
			if vkind = actual then
			  begin
			    gen2(50(*lda*),0,vaddr);
			    gen2t(54(*lod*),0,llc1,nilptr);
			    gen1(40(*mov*),idtype^.size);
			  end;
			llc1 := llc1 + ptrsize
		      end
		    else llc1 := llc1 + idtype^.size;
		lcp := lcp^.next;
	      end;
	end;
      lcmax := lc;
      repeat
	repeat statement(fsys + [semicolon,endsy])
	until not (sy in statbegsys);
	test := sy <> semicolon;
	if not test then insymbol
      until test;
      if sy = endsy then insymbol else error(13);
      llp := display[top].flabel; (*test for undefined labels*)
      while llp <> nil do
	with llp^ do
	  begin
	    if not defined then
	      begin error(168);
		writeln(output); writeln(output,' label ',labval);
		write(output,' ':chcnt+16)
	      end;
	    llp := nextlab
	  end;
      if fprocp <> nil then
	begin
	  if fprocp^.idtype = nil then gen1(42(*ret*),ord('p'))
	  else gen0t(42(*ret*),fprocp^.idtype);
	  align(parmptr,lcmax);
	  if prcode then
	    begin writeln(prr,'l',segsize:4,'=',lcmax);
	      writeln(prr,'l',stacktop:4,'=',topmax)
	    end
	end
      else
	begin gen1(42(*ret*),ord('p'));
	  align(parmptr,lcmax);
	  if prcode then
	    begin writeln(prr,'l',segsize:4,'=',lcmax);
	      writeln(prr,'l',stacktop:4,'=',topmax);
	      writeln(prr,'q')
	    end;
	  ic := 0;
	  (*generate call of main program; note that this call must be loaded
	    at absolute address zero*)
	  gen1(41(*mst*),0); gencupent(46(*cup*),0,entname); gen0(29(*stp*));
	  if prcode then
	    writeln(prr,'q');
	  saveid := id;
	  while fextfilep <> nil do
	    begin
	      with fextfilep^ do
		if not ((filename = 'input   ') or (filename = 'output  ') or
			(filename = 'prd     ') or (filename = 'prr     '))
		then begin id := filename;
		       searchid([vars],llcp);
		       if llcp^.idtype<>nil then
			 if llcp^.idtype^.form<>files then
			   begin writeln(output);
			     writeln(output,' ':8,'undeclared ','external ',
				   'file',fextfilep^.filename:8);
			     write(output,' ':chcnt+16)
			   end
		     end;
		fextfilep := fextfilep^.nextfile
	    end;
	  id := saveid;
	  if prtables then
	    begin writeln(output); printtables(true)
	    end
	end;
    end (*body*) ;

  begin (*block*)
    dp := true;
    repeat
      if sy = labelsy then
	begin insymbol; labeldeclaration end;
      if sy = constsy then
	begin insymbol; constdeclaration end;
      if sy = typesy then
	begin insymbol; typedeclaration end;
      if sy = varsy then
	begin insymbol; vardeclaration end;
      while sy in [procsy,funcsy] do
	begin lsy := sy; insymbol; procdeclaration(lsy) end;
      if sy <> beginsy then
	begin error(18); skip(fsys) end
    until (sy in statbegsys) or eof(input);
    dp := false;
    if sy = beginsy then insymbol else error(17);
    repeat body(fsys + [casesy]);
      if sy <> fsy then
	begin error(6); skip(fsys) end
    until ((sy = fsy) or (sy in blockbegsys)) or eof(input);
  end (*block*) ;

  procedure programme(fsys:setofsys);
    var extfp:extfilep;
  begin
    if sy = progsy then
      begin insymbol; if sy <> ident then error(2); insymbol;
	if not (sy in [lparent,semicolon]) then error(14);
	if sy = lparent  then
	  begin
	    repeat insymbol;
	      if sy = ident then
		begin new(extfp);
		  with extfp^ do
		    begin filename := id; nextfile := fextfilep end;
		  fextfilep := extfp;
		  insymbol;
		  if not ( sy in [comma,rparent] ) then error(20)
		end
	      else error(2)
	    until sy <> comma;
	    if sy <> rparent then error(4);
	    insymbol
	  end;
	if sy <> semicolon then error(14)
	else insymbol;
      end;
    repeat block(fsys,period,nil);
      if sy <> period then error(21)
    until (sy = period) or eof(input);
    if list then writeln(output);
    if errinx <> 0 then
      begin list := false; endofline end
  end (*programme*) ;


  procedure stdnames;
  begin
    na[ 1] := 'false   '; na[ 2] := 'true    '; na[ 3] := 'input   ';
    na[ 4] := 'output  '; na[ 5] := 'get     '; na[ 6] := 'put     ';
    na[ 7] := 'reset   '; na[ 8] := 'rewrite '; na[ 9] := 'read    ';
    na[10] := 'write   '; na[11] := 'pack    '; na[12] := 'unpack  ';
    na[13] := 'new     '; na[14] := 'release '; na[15] := 'readln  ';
    na[16] := 'writeln ';
    na[17] := 'abs     '; na[18] := 'sqr     '; na[19] := 'trunc   ';
    na[20] := 'odd     '; na[21] := 'ord     '; na[22] := 'chr     ';
    na[23] := 'pred    '; na[24] := 'succ    '; na[25] := 'eof     ';
    na[26] := 'eoln    ';
    na[27] := 'sin     '; na[28] := 'cos     '; na[29] := 'exp     ';
    na[30] := 'sqrt    '; na[31] := 'ln      '; na[32] := 'arctan  ';
    na[33] := 'prd     '; na[34] := 'prr     '; na[35] := 'mark    ';
  end (*stdnames*) ;

  procedure enterstdtypes;

  begin						 (*type underlying:*)
							(******************)

    new(intptr,scalar,standard);			      (*integer*)
    with intptr^ do
      begin size := intsize; form := scalar; scalkind := standard end;
    new(realptr,scalar,standard);			     (*real*)
    with realptr^ do
      begin size := realsize; form := scalar; scalkind := standard end;
    new(charptr,scalar,standard);			     (*char*)
    with charptr^ do
      begin size := charsize; form := scalar; scalkind := standard end;
    new(boolptr,scalar,declared);			     (*boolean*)
    with boolptr^ do
      begin size := boolsize; form := scalar; scalkind := declared end;
    new(nilptr,pointer);				      (*nil*)
    with nilptr^ do
      begin eltype := nil; size := ptrsize; form := pointer end;
    new(parmptr,scalar,standard); (*for alignment of parameters*)
    with parmptr^ do
      begin size := parmsize; form := scalar; scalkind := standard end ;
    new(textptr,files);				       (*text*)
    with textptr^ do
      begin filtype := charptr; size := charsize; form := files end
  end (*enterstdtypes*) ;

  procedure entstdnames;
    var cp,cp1: ctp; i: integer;
  begin						       (*name:*)
							      (*******)

    new(cp,types);					    (*integer*)
    with cp^ do
      begin name := 'integer '; idtype := intptr; klass := types end;
    enterid(cp);
    new(cp,types);					    (*real*)
    with cp^ do
      begin name := 'real    '; idtype := realptr; klass := types end;
    enterid(cp);
    new(cp,types);					    (*char*)
    with cp^ do
      begin name := 'char    '; idtype := charptr; klass := types end;
    enterid(cp);
    new(cp,types);					    (*boolean*)
    with cp^ do
      begin name := 'boolean '; idtype := boolptr; klass := types end;
    enterid(cp);
    cp1 := nil;
    for i := 1 to 2 do
      begin new(cp,konst);				    (*false,true*)
	with cp^ do
	  begin name := na[i]; idtype := boolptr;
	    next := cp1; values.ival := i - 1; klass := konst
	  end;
	enterid(cp); cp1 := cp
      end;
    boolptr^.fconst := cp;
    new(cp,konst);					    (*nil*)
    with cp^ do
      begin name := 'nil     '; idtype := nilptr;
	next := nil; values.ival := 0; klass := konst
      end;
    enterid(cp);
    for i := 3 to 4 do
      begin new(cp,vars);				     (*input,output*)
	with cp^ do
	  begin name := na[i]; idtype := textptr; klass := vars;
	    vkind := actual; next := nil; vlev := 1;
	    vaddr := lcaftermarkstack+(i-3)*charmax;
	  end;
	enterid(cp)
      end;
    for i:=33 to 34 do
      begin new(cp,vars);				     (*prd,prr files*)
	 with cp^ do
	   begin name := na[i]; idtype := textptr; klass := vars;
	      vkind := actual; next := nil; vlev := 1;
	      vaddr := lcaftermarkstack+(i-31)*charmax;
	   end;
	 enterid(cp)
      end;
    for i := 5 to 16 do
      begin new(cp,proc,standard);			    (*get,put,reset*)
	with cp^ do					   (*rewrite,read*)
	  begin name := na[i]; idtype := nil;		 (*write,pack*)
	    next := nil; key := i - 4;			(*unpack,pack*)
	    klass := proc; pfdeckind := standard
	  end;
	enterid(cp)
      end;
    new(cp,proc,standard);
    with cp^ do
      begin name:=na[35]; idtype:=nil;
	    next:= nil; key:=13;
	    klass:=proc; pfdeckind:= standard
      end; enterid(cp);
    for i := 17 to 26 do
      begin new(cp,func,standard);			    (*abs,sqr,trunc*)
	with cp^ do					   (*odd,ord,chr*)
	  begin name := na[i]; idtype := nil;		 (*pred,succ,eof*)
	    next := nil; key := i - 16;
	    klass := func; pfdeckind := standard
	  end;
	enterid(cp)
      end;
    new(cp,vars);		      (*parameter of predeclared functions*)
    with cp^ do
      begin name := '        '; idtype := realptr; klass := vars;
	vkind := actual; next := nil; vlev := 1; vaddr := 0
      end;
    for i := 27 to 32 do
      begin new(cp1,func,declared,actual);		    (*sin,cos,exp*)
	with cp1^ do					  (*sqrt,ln,arctan*)
	  begin name := na[i]; idtype := realptr; next := cp;
	    forwdecl := false; externl := true; pflev := 0; pfname := i - 12;
	    klass := func; pfdeckind := declared; pfkind := actual
	  end;
	enterid(cp1)
      end
  end (*entstdnames*) ;

  procedure enterundecl;
  begin
    new(utypptr,types);
    with utypptr^ do
      begin name := '        '; idtype := nil; klass := types end;
    new(ucstptr,konst);
    with ucstptr^ do
      begin name := '        '; idtype := nil; next := nil;
	values.ival := 0; klass := konst
      end;
    new(uvarptr,vars);
    with uvarptr^ do
      begin name := '        '; idtype := nil; vkind := actual;
	next := nil; vlev := 0; vaddr := 0; klass := vars
      end;
    new(ufldptr,field);
    with ufldptr^ do
      begin name := '        '; idtype := nil; next := nil; fldaddr := 0;
	klass := field
      end;
    new(uprcptr,proc,declared,actual);
    with uprcptr^ do
      begin name := '        '; idtype := nil; forwdecl := false;
	next := nil; externl := false; pflev := 0; genlabel(pfname);
	klass := proc; pfdeckind := declared; pfkind := actual
      end;
    new(ufctptr,func,declared,actual);
    with ufctptr^ do
      begin name := '        '; idtype := nil; next := nil;
	forwdecl := false; externl := false; pflev := 0; genlabel(pfname);
	klass := func; pfdeckind := declared; pfkind := actual
      end
  end (*enterundecl*) ;

  procedure initscalars;
  begin fwptr := nil;
    prtables := false; list := true; prcode := true; debug := true;
    dp := true; prterr := true; errinx := 0;
    intlabel := 0; kk := 8; fextfilep := nil;
    lc := lcaftermarkstack+filebuffer*charmax;
    (* note in the above reservation of buffer store for 2 text files *)
    ic := 3; eol := true; linecount := 0;
    ch := ' '; chcnt := 0;
    globtestp := nil;
    mxint10 := maxint div 10; digmax := strglgth - 1;
  end (*initscalars*) ;

  procedure initsets;
  begin
    constbegsys := [addop,intconst,realconst,stringconst,ident];
    simptypebegsys := [lparent] + constbegsys;
    typebegsys:=[arrow,packedsy,arraysy,recordsy,setsy,filesy]+simptypebegsys;
    typedels := [arraysy,recordsy,setsy,filesy];
    blockbegsys := [labelsy,constsy,typesy,varsy,procsy,funcsy,beginsy];
    selectsys := [arrow,period,lbrack];
    facbegsys := [intconst,realconst,stringconst,ident,lparent,lbrack,notsy];
    statbegsys := [beginsy,gotosy,ifsy,whilesy,repeatsy,forsy,withsy,casesy];
  end (*initsets*) ;

  procedure inittables;
    procedure reswords;
    begin
      rw[ 1] := 'if      '; rw[ 2] := 'do      '; rw[ 3] := 'of      ';
      rw[ 4] := 'to      '; rw[ 5] := 'in      '; rw[ 6] := 'or      ';
      rw[ 7] := 'end     '; rw[ 8] := 'for     '; rw[ 9] := 'var     ';
      rw[10] := 'div     '; rw[11] := 'mod     '; rw[12] := 'set     ';
      rw[13] := 'and     '; rw[14] := 'not     '; rw[15] := 'then    ';
      rw[16] := 'else    '; rw[17] := 'with    '; rw[18] := 'goto    ';
      rw[19] := 'case    '; rw[20] := 'type    ';
      rw[21] := 'file    '; rw[22] := 'begin   ';
      rw[23] := 'until   '; rw[24] := 'while   '; rw[25] := 'array   ';
      rw[26] := 'const   '; rw[27] := 'label   ';
      rw[28] := 'repeat  '; rw[29] := 'record  '; rw[30] := 'downto  ';
      rw[31] := 'packed  '; rw[32] := 'forward '; rw[33] := 'program ';
      rw[34] := 'function'; rw[35] := 'procedur';
      frw[1] :=  1; frw[2] :=  1; frw[3] :=  7; frw[4] := 15; frw[5] := 22;
      frw[6] := 28; frw[7] := 32; frw[8] := 34; frw[9] := 36;
    end (*reswords*) ;

    procedure symbols;
    begin
      rsy[ 1] := ifsy;      rsy[ 2] := dosy;      rsy[ 3] := ofsy;
      rsy[ 4] := tosy;      rsy[ 5] := relop;     rsy[ 6] := addop;
      rsy[ 7] := endsy;     rsy[ 8] := forsy;     rsy[ 9] := varsy;
      rsy[10] := mulop;     rsy[11] := mulop;     rsy[12] := setsy;
      rsy[13] := mulop;     rsy[14] := notsy;     rsy[15] := thensy;
      rsy[16] := elsesy;    rsy[17] := withsy;    rsy[18] := gotosy;
      rsy[19] := casesy;    rsy[20] := typesy;
      rsy[21] := filesy;    rsy[22] := beginsy;
      rsy[23] := untilsy;   rsy[24] := whilesy;   rsy[25] := arraysy;
      rsy[26] := constsy;   rsy[27] := labelsy;
      rsy[28] := repeatsy;  rsy[29] := recordsy;  rsy[30] := downtosy;
      rsy[31] := packedsy;  rsy[32] := forwardsy; rsy[33] := progsy;
      rsy[34] := funcsy;    rsy[35] := procsy;
      ssy['+'] := addop ;   ssy['-'] := addop;    ssy['*'] := mulop;
      ssy['/'] := mulop ;   ssy['('] := lparent;  ssy[')'] := rparent;
      ssy['$'] := othersy ; ssy['='] := relop;    ssy[' '] := othersy;
      ssy[','] := comma ;   ssy['.'] := period;   ssy['''']:= othersy;
      ssy['['] := lbrack ;  ssy[']'] := rbrack;   ssy[':'] := colon;
      ssy['^'] := arrow ;   ssy['<'] := relop;    ssy['>'] := relop;
      ssy[';'] := semicolon;
    end (*symbols*) ;

    procedure rators;
      var i: integer;
    begin
      for i := 1 to 35 (*nr of res words*) do rop[i] := noop;
      rop[5] := inop; rop[10] := idiv; rop[11] := imod;
      rop[6] := orop; rop[13] := andop;
      for i := ordminchar to ordmaxchar do sop[chr(i)] := noop;
      sop['+'] := plus; sop['-'] := minus; sop['*'] := mul; sop['/'] := rdiv;
      sop['='] := eqop; sop['<'] := ltop;  sop['>'] := gtop;
    end (*rators*) ;

    procedure procmnemonics;
    begin
      sna[ 1] :=' get'; sna[ 2] :=' put'; sna[ 3] :=' rdi'; sna[ 4] :=' rdr';
      sna[ 5] :=' rdc'; sna[ 6] :=' wri'; sna[ 7] :=' wro'; sna[ 8] :=' wrr';
      sna[ 9] :=' wrc'; sna[10] :=' wrs'; sna[11] :=' pak'; sna[12] :=' new';
      sna[13] :=' rst'; sna[14] :=' eln'; sna[15] :=' sin'; sna[16] :=' cos';
      sna[17] :=' exp'; sna[18] :=' sqt'; sna[19] :=' log'; sna[20] :=' atn';
      sna[21] :=' rln'; sna[22] :=' wln'; sna[23] :=' sav';
    end (*procmnemonics*) ;

    procedure instrmnemonics;
    begin
      mn[ 0] :=' abi'; mn[ 1] :=' abr'; mn[ 2] :=' adi'; mn[ 3] :=' adr';
      mn[ 4] :=' and'; mn[ 5] :=' dif'; mn[ 6] :=' dvi'; mn[ 7] :=' dvr';
      mn[ 8] :=' eof'; mn[ 9] :=' flo'; mn[10] :=' flt'; mn[11] :=' inn';
      mn[12] :=' int'; mn[13] :=' ior'; mn[14] :=' mod'; mn[15] :=' mpi';
      mn[16] :=' mpr'; mn[17] :=' ngi'; mn[18] :=' ngr'; mn[19] :=' not';
      mn[20] :=' odd'; mn[21] :=' sbi'; mn[22] :=' sbr'; mn[23] :=' sgs';
      mn[24] :=' sqi'; mn[25] :=' sqr'; mn[26] :=' sto'; mn[27] :=' trc';
      mn[28] :=' uni'; mn[29] :=' stp'; mn[30] :=' csp'; mn[31] :=' dec';
      mn[32] :=' ent'; mn[33] :=' fjp'; mn[34] :=' inc'; mn[35] :=' ind';
      mn[36] :=' ixa'; mn[37] :=' lao'; mn[38] :=' lca'; mn[39] :=' ldo';
      mn[40] :=' mov'; mn[41] :=' mst'; mn[42] :=' ret'; mn[43] :=' sro';
      mn[44] :=' xjp'; mn[45] :=' chk'; mn[46] :=' cup'; mn[47] :=' equ';
      mn[48] :=' geq'; mn[49] :=' grt'; mn[50] :=' lda'; mn[51] :=' ldc';
      mn[52] :=' leq'; mn[53] :=' les'; mn[54] :=' lod'; mn[55] :=' neq';
      mn[56] :=' str'; mn[57] :=' ujp'; mn[58] :=' ord'; mn[59] :=' chr';
      mn[60] :=' ujc';
    end (*instrmnemonics*) ;

    procedure chartypes;
    var i : integer;
    begin
      for i := ordminchar to ordmaxchar do chartp[chr(i)] := illegal;
      chartp['a'] := letter  ;
      chartp['b'] := letter  ; chartp['c'] := letter  ;
      chartp['d'] := letter  ; chartp['e'] := letter  ;
      chartp['f'] := letter  ; chartp['g'] := letter  ;
      chartp['h'] := letter  ; chartp['i'] := letter  ;
      chartp['j'] := letter  ; chartp['k'] := letter  ;
      chartp['l'] := letter  ; chartp['m'] := letter  ;
      chartp['n'] := letter  ; chartp['o'] := letter  ;
      chartp['p'] := letter  ; chartp['q'] := letter  ;
      chartp['r'] := letter  ; chartp['s'] := letter  ;
      chartp['t'] := letter  ; chartp['u'] := letter  ;
      chartp['v'] := letter  ; chartp['w'] := letter  ;
      chartp['x'] := letter  ; chartp['y'] := letter  ;
      chartp['z'] := letter  ; chartp['0'] := number  ;
      chartp['1'] := number  ; chartp['2'] := number  ;
      chartp['3'] := number  ; chartp['4'] := number  ;
      chartp['5'] := number  ; chartp['6'] := number  ;
      chartp['7'] := number  ; chartp['8'] := number  ;
      chartp['9'] := number  ; chartp['+'] := special ;
      chartp['-'] := special ; chartp['*'] := special ;
      chartp['/'] := special ; chartp['('] := chlparen;
      chartp[')'] := special ; chartp['$'] := special ;
      chartp['='] := special ; chartp[' '] := chspace ;
      chartp[','] := special ; chartp['.'] := chperiod;
      chartp['''']:= chstrquo; chartp['['] := special ;
      chartp[']'] := special ; chartp[':'] := chcolon ;
      chartp['^'] := special ; chartp[';'] := special ;
      chartp['<'] := chlt    ; chartp['>'] := chgt    ;
      ordint['0'] := 0; ordint['1'] := 1; ordint['2'] := 2;
      ordint['3'] := 3; ordint['4'] := 4; ordint['5'] := 5;
      ordint['6'] := 6; ordint['7'] := 7; ordint['8'] := 8;
      ordint['9'] := 9;
    end;

    procedure initdx;
    begin
      cdx[ 0] :=  0; cdx[ 1] :=  0; cdx[ 2] := -1; cdx[ 3] := -1;
      cdx[ 4] := -1; cdx[ 5] := -1; cdx[ 6] := -1; cdx[ 7] := -1;
      cdx[ 8] :=  0; cdx[ 9] :=  0; cdx[10] :=  0; cdx[11] := -1;
      cdx[12] := -1; cdx[13] := -1; cdx[14] := -1; cdx[15] := -1;
      cdx[16] := -1; cdx[17] :=  0; cdx[18] :=  0; cdx[19] :=  0;
      cdx[20] :=  0; cdx[21] := -1; cdx[22] := -1; cdx[23] :=  0;
      cdx[24] :=  0; cdx[25] :=  0; cdx[26] := -2; cdx[27] :=  0;
      cdx[28] := -1; cdx[29] :=  0; cdx[30] :=  0; cdx[31] :=  0;
      cdx[32] :=  0; cdx[33] := -1; cdx[34] :=  0; cdx[35] :=  0;
      cdx[36] := -1; cdx[37] := +1; cdx[38] := +1; cdx[39] := +1;
      cdx[40] := -2; cdx[41] :=  0; cdx[42] :=  0; cdx[43] := -1;
      cdx[44] := -1; cdx[45] :=  0; cdx[46] :=  0; cdx[47] := -1;
      cdx[48] := -1; cdx[49] := -1; cdx[50] := +1; cdx[51] := +1;
      cdx[52] := -1; cdx[53] := -1; cdx[54] := +1; cdx[55] := -1;
      cdx[56] := -1; cdx[57] :=  0; cdx[58] :=  0; cdx[59] :=  0;
      cdx[60] :=  0;
      pdx[ 1] := -1; pdx[ 2] := -1; pdx[ 3] := -2; pdx[ 4] := -2;
      pdx[ 5] := -2; pdx[ 6] := -3; pdx[ 7] := -3; pdx[ 8] := -3;
      pdx[ 9] := -3; pdx[10] := -4; pdx[11] :=  0; pdx[12] := -2;
      pdx[13] := -1; pdx[14] :=  0; pdx[15] :=  0; pdx[16] :=  0;
      pdx[17] :=  0; pdx[18] :=  0; pdx[19] :=  0; pdx[20] :=  0;
      pdx[21] := -1; pdx[22] := -1; pdx[23] := -1;
    end;

  begin (*inittables*)
    reswords; symbols; rators;
    instrmnemonics; procmnemonics;
    chartypes; initdx;
  end (*inittables*) ;

begin
  (*initialize*)
  (************)
  initscalars; initsets; inittables;


  (*enter standard names and standard types:*)
  (******************************************)
  level := 0; top := 0;
  with display[0] do
    begin fname := nil; flabel := nil; occur := blck end;
  enterstdtypes;   stdnames; entstdnames;   enterundecl;
  top := 1; level := 1;
  with display[1] do
    begin fname := nil; flabel := nil; occur := blck end;


  (*compile:*) rewrite(prr); (*comment this out when compiling with pcom *)
  (**********)
  insymbol;
  programme(blockbegsys+statbegsys-[casesy]);

end.

Added pint.p.



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
84
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
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
161
162
163
164
165
166
167
168
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
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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
349
350
351
352
353
354
355
356
357
358
359
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
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
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
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
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
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
(*Assembler and interpreter of Pascal code*)
(*K. Jensen, N. Wirth, Ch. Jacobi, ETH May 76*)

program pcode(input,output,prd,prr);

(* Note for the implementation.
   ===========================
This interpreter is written for the case where all the fundamental types
take one storage unit.
In an actual implementation, the handling of the sp pointer has to take
into account the fact that the types may have lengths different from one:
in push and pop operations the sp has to be increased and decreased not
by 1, but by a number depending on the type concerned.
However, where the number of units of storage has been computed by the
compiler, the value must not be corrected, since the lengths of the types
involved have already been taken into account.
								 *)


label 1;
const codemax     = 8650;
      pcmax       = 17500;
      maxstk      = 13650; (* size of variable store *)
      overi       = 13655; (* size of integer constant table = 5 *)
      overr       = 13660; (* size of real constant table = 5 *)
      overs       = 13730; (* size of set constant table = 70 *)
      overb       = 13820;
      overm       = 18000;
      maxstr      = 18001;
      largeint    = 26144;
      begincode   = 3;
      inputadr    = 5;
      outputadr   = 6;
      prdadr      = 7;
      prradr      = 8;
      duminst     = 62;

type  bit4	  = 0..15;
      bit6	  = 0..127;
      bit20       = -26143..26143;
      datatype    = (undef,int,reel,bool,sett,adr,mark,car);
      address     = -1..maxstr;
      beta	  = packed array[1..25] of char; (*error message*)
      settype     = set of 0..58;
      alfa        = packed array[1..10] of char;

var   code	  : array[0..codemax] of   (* the program *)
		      packed record  op1    :bit6;
				     p1     :bit4;
				     q1     :bit20;
				     op2    :bit6;
				     p2     :bit4;
				     q2     :bit20
			     end;
      pc	   : 0..pcmax;	 (*program address register*)
      op : bit6; p : bit4; q : bit20;  (*instruction register*)

      store	   : array [0..overm] of
		       record case datatype of
				int	:(vi :integer);
				reel       :(vr :real);
				bool       :(vb :boolean);
				sett       :(vs :settype);
				car	:(vc :char);
				adr	:(va :address);
					     (*address in store*)
				mark       :(vm :integer)
			end;
       mp,sp,np,ep : address;  (* address registers *)
       (*mp  points to beginning of a data segment
	 sp  points to top of the stack
	 ep  points to the maximum extent of the stack
	 np  points to top of the dynamically allocated area*)

       interpreting: boolean;
       prd,prr     : text;(*prd for read only, prr for write only *)

       instr       : array[bit6] of alfa; (* mnemonic instruction codes *)
       cop	 : array[bit6] of integer;
       sptable     : array[0..20] of alfa; (*standard functions and procedures*)

      (*locally used for interpreting one instruction*)
       ad,ad1      : address;
       b	   : boolean;
       i,j,i1,i2   : integer;
       c	   : char;

(*--------------------------------------------------------------------*)

procedure load;
   const maxlabel = 1850;
   type  labelst  = (entered,defined); (*label situation*)
	 labelrg  = 0..maxlabel;       (*label range*)
	 labelrec = record
			  val: address;
			   st: labelst
		    end;
   var  icp,rcp,scp,bcp,mcp  : address;  (*pointers to next free position*)
	word : array[1..10] of char; i  : integer;  ch  : char;
	labeltab: array[labelrg] of labelrec;
	labelvalue: address;

   procedure init;
      var i: integer;
   begin instr[ 0]:='lod       ';       instr[ 1]:='ldo       ';
	 instr[ 2]:='str       ';       instr[ 3]:='sro       ';
	 instr[ 4]:='lda       ';       instr[ 5]:='lao       ';
	 instr[ 6]:='sto       ';       instr[ 7]:='ldc       ';
	 instr[ 8]:='...       ';       instr[ 9]:='ind       ';
	 instr[10]:='inc       ';       instr[11]:='mst       ';
	 instr[12]:='cup       ';       instr[13]:='ent       ';
	 instr[14]:='ret       ';       instr[15]:='csp       ';
	 instr[16]:='ixa       ';       instr[17]:='equ       ';
	 instr[18]:='neq       ';       instr[19]:='geq       ';
	 instr[20]:='grt       ';       instr[21]:='leq       ';
	 instr[22]:='les       ';       instr[23]:='ujp       ';
	 instr[24]:='fjp       ';       instr[25]:='xjp       ';
	 instr[26]:='chk       ';       instr[27]:='eof       ';
	 instr[28]:='adi       ';       instr[29]:='adr       ';
	 instr[30]:='sbi       ';       instr[31]:='sbr       ';
	 instr[32]:='sgs       ';       instr[33]:='flt       ';
	 instr[34]:='flo       ';       instr[35]:='trc       ';
	 instr[36]:='ngi       ';       instr[37]:='ngr       ';
	 instr[38]:='sqi       ';       instr[39]:='sqr       ';
	 instr[40]:='abi       ';       instr[41]:='abr       ';
	 instr[42]:='not       ';       instr[43]:='and       ';
	 instr[44]:='ior       ';       instr[45]:='dif       ';
	 instr[46]:='int       ';       instr[47]:='uni       ';
	 instr[48]:='inn       ';       instr[49]:='mod       ';
	 instr[50]:='odd       ';       instr[51]:='mpi       ';
	 instr[52]:='mpr       ';       instr[53]:='dvi       ';
	 instr[54]:='dvr       ';       instr[55]:='mov       ';
	 instr[56]:='lca       ';       instr[57]:='dec       ';
	 instr[58]:='stp       ';       instr[59]:='ord       ';
	 instr[60]:='chr       ';       instr[61]:='ujc       ';

	 sptable[ 0]:='get       ';     sptable[ 1]:='put       ';
	 sptable[ 2]:='rst       ';     sptable[ 3]:='rln       ';
	 sptable[ 4]:='new       ';     sptable[ 5]:='wln       ';
	 sptable[ 6]:='wrs       ';     sptable[ 7]:='eln       ';
	 sptable[ 8]:='wri       ';     sptable[ 9]:='wrr       ';
	 sptable[10]:='wrc       ';     sptable[11]:='rdi       ';
	 sptable[12]:='rdr       ';     sptable[13]:='rdc       ';
	 sptable[14]:='sin       ';     sptable[15]:='cos       ';
	 sptable[16]:='exp       ';     sptable[17]:='log       ';
	 sptable[18]:='sqt       ';     sptable[19]:='atn       ';
	 sptable[20]:='sav       ';

	 cop[ 0] := 105;  cop[ 1] :=  65;
	 cop[ 2] :=  70;  cop[ 3] :=  75;
	 cop[ 6] :=  80;  cop[ 9] :=  85;
	 cop[10] :=  90;  cop[26] :=  95;
	 cop[57] := 100;

	 pc  := begincode;
	 icp := maxstk + 1;
	 rcp := overi + 1;
	 scp := overr + 1;
	 bcp := overs + 2;
	 mcp := overb + 1;
	 for i:= 1 to 10 do word[i]:= ' ';
	 for i:= 0 to maxlabel do
	     with labeltab[i] do begin val:=-1; st:= entered end;
	 reset(prd);
   end;(*init*)

   procedure errorl(string: beta); (*error in loading*)
   begin writeln;
      write(string);
      halt
   end; (*errorl*)

   procedure update(x: labelrg); (*when a label definition lx is found*)
      var curr,succ: -1..pcmax;  (*resp. current element and successor element
				   of a list of future references*)
	  endlist: boolean;
   begin
      if labeltab[x].st=defined then errorl(' duplicated label	')
      else begin
	     if labeltab[x].val<>-1 then (*forward reference(s)*)
	     begin curr:= labeltab[x].val; endlist:= false;
		while not endlist do
		      with code[curr div 2] do
		      begin
			 if odd(curr) then begin succ:= q2;
						 q2:= labelvalue
					   end
				      else begin succ:= q1;
						 q1:= labelvalue
					   end;
			 if succ=-1 then endlist:= true
				    else curr:= succ
		      end;
	      end;
	      labeltab[x].st := defined;
	      labeltab[x].val:= labelvalue;
	   end
   end;(*update*)

   procedure assemble; forward;

   procedure generate;(*generate segment of code*)
      var x: integer; (* label number *)
	  again: boolean;
   begin
      again := true;
      while again do
	    begin read(prd,ch);(* first character of line*)
		  case ch of
		       'i': readln(prd);
		       'l': begin read(prd,x);
				  if not eoln(prd) then read(prd,ch);
				  if ch='=' then read(prd,labelvalue)
					    else labelvalue:= pc;
				  update(x); readln(prd);
			    end;
		       'q': begin again := false; readln(prd) end;
		       ' ': begin read(prd,ch); assemble end
		  end;
	    end
   end; (*generate*)

   procedure assemble; (*translate symbolic code into machine code and store*)
      label 1;	 (*goto 1 for instructions without code generation*)
      var name :alfa;  b :boolean;  r :real;  s :settype;
	  c1 :char;  i,s1,lb,ub :integer;

      procedure lookup(x: labelrg); (* search in label table*)
      begin case labeltab[x].st of
		entered: begin q := labeltab[x].val;
			   labeltab[x].val := pc
			 end;
		defined: q:= labeltab[x].val
	    end(*case label..*)
      end;(*lookup*)

      procedure labelsearch;
	 var x: labelrg;
      begin while (ch<>'l') and not eoln(prd) do read(prd,ch);
	    read(prd,x); lookup(x)
      end;(*labelsearch*)

      procedure getname;
      begin  word[1] := ch;
	 read(prd,word[2],word[3]);
	 if not eoln(prd) then read(prd,ch) (*next character*);
	 pack(word,1,name)
      end; (*getname*)

      procedure typesymbol;
	var i: integer;
      begin
	if ch <> 'i' then
	  begin
	    case ch of
	      'a': i := 0;
	      'r': i := 1;
	      's': i := 2;
	      'b': i := 3;
	      'c': i := 4;
	    end;
	    op := cop[op]+i;
	  end;
      end (*typesymbol*) ;

   begin  p := 0;  q := 0;  op := 0;
      getname;
      instr[duminst] := name;
      while instr[op]<>name do op := op+1;
      if op = duminst then errorl(' illegal instruction     ');

      case op of  (* get parameters p,q *)

	  (*equ,neq,geq,grt,leq,les*)
	  17,18,19,
	  20,21,22: begin case ch of
			      'a': ; (*p = 0*)
			      'i': p := 1;
			      'r': p := 2;
			      'b': p := 3;
			      's': p := 4;
			      'c': p := 6;
			      'm': begin p := 5;
				     read(prd,q)
				   end
			  end
		    end;

	  (*lod,str*)
	  0,2: begin typesymbol; read(prd,p,q)
	       end;

	  4  (*lda*): read(prd,p,q);

	  12 (*cup*): begin read(prd,p); labelsearch end;

	  11 (*mst*): read(prd,p);

	  14 (*ret*): case ch of
			    'p': p:=0;
			    'i': p:=1;
			    'r': p:=2;
			    'c': p:=3;
			    'b': p:=4;
			    'a': p:=5
		      end;

	  (*lao,ixa,mov*)
	  5,16,55: read(prd,q);

	  (*ldo,sro,ind,inc,dec*)
	  1,3,9,10,57: begin typesymbol; read(prd,q)
		       end;

	  (*ujp,fjp,xjp*)
	  23,24,25: labelsearch;

	  13 (*ent*): begin read(prd,p); labelsearch end;

	  15 (*csp*): begin for i:=1 to 9 do read(prd,ch); getname;
			   while name<>sptable[q] do  q := q+1
		      end;

	  7 (*ldc*): begin case ch of  (*get q*)
			   'i': begin  p := 1;  read(prd,i);
				   if abs(i)>=largeint then
				   begin  op := 8;
				      store[icp].vi := i;  q := maxstk;
				      repeat  q := q+1  until store[q].vi=i;
				      if q=icp then
				      begin  icp := icp+1;
					if icp=overi then
					  errorl(' integer table overflow  ');
				      end
				   end  else q := i
				end;

			   'r': begin  op := 8; p := 2;
				   read(prd,r);
				   store[rcp].vr := r;  q := overi;
				   repeat  q := q+1  until store[q].vr=r;
				   if q=rcp then
				   begin  rcp := rcp+1;
				     if rcp = overr then
				       errorl(' real table overflow     ');
				   end
				end;

			   'n': ; (*p,q = 0*)

			   'b': begin p := 3;  read(prd,q)  end;

			   'c': begin p := 6;
				  repeat read(prd,ch); until ch <> ' ';
				  if ch <> '''' then
				    errorl(' illegal character       ');
				  read(prd,ch);  q := ord(ch);
				  read(prd,ch);
				  if ch <> '''' then
				    errorl(' illegal character       ');
				end;
			   '(': begin  op := 8;  p := 4;
				   s := [ ];  read(prd,ch);
				   while ch<>')' do
				   begin read(prd,s1,ch); s := s + [s1]
				   end;
				   store[scp].vs := s;  q := overr;
				   repeat  q := q+1  until store[q].vs=s;
				   if q=scp then
				   begin  scp := scp+1;
				      if scp=overs then
					errorl(' set table overflow      ');
				   end
				end
			   end (*case*)
		     end;

	   26 (*chk*): begin typesymbol;
			 read(prd,lb,ub);
			 if op = 95 then q := lb
			 else
			 begin
			   store[bcp-1].vi := lb; store[bcp].vi := ub;
			   q := overs;
			   repeat  q := q+2
			   until (store[q-1].vi=lb)and (store[q].vi=ub);
			   if q=bcp then
			   begin  bcp := bcp+2;
			      if bcp=overb then
				errorl(' boundary table overflow ');
			   end
			 end
		       end;

	   56 (*lca*): begin
			 if mcp + 16 >= overm then
			   errorl(' multiple table overflow ');
			 mcp := mcp+16;
			 q := mcp;
			 for i := 0 to 15 (*stringlgth*) do
			 begin read(prd,ch);
			   store[q+i].vc := ch
			 end;
		       end;

	  6 (*sto*): typesymbol;

	  27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
	  48,49,50,51,52,53,54,58:  ;

	  (*ord,chr*)
	  59,60: goto 1;

	  61 (*ujc*): ; (*must have same length as ujp*)

      end; (*case*)

      (* store instruction *)
      with code[pc div 2] do
	 if odd(pc) then
	 begin  op2 := op; p2 := p; q2 := q
	 end  else
	 begin  op1 := op; p1 := p; q1 := q
	 end;
      pc := pc+1;
      1: readln(prd);
   end; (*assemble*)

begin (*load*)
   init;
   generate;
   pc := 0;
   generate;
end; (*load*)

(*------------------------------------------------------------------------*)

procedure pmd;
   var s :integer; i: integer;

   procedure pt;
   begin  write(s:6);
      if abs(store[s].vi) < maxint then write(store[s].vi)
      else write('too big ');
      s := s - 1;
      i := i + 1;
      if i = 4 then
	 begin writeln(output); i := 0 end;
   end; (*pt*)

begin
   write(' pc =',pc-1:5,' op =',op:3,'  sp =',sp:5,'  mp =',mp:5,
	'  np =',np:5);
   writeln; writeln('--------------------------------------');

   s := sp; i := 0;
   while s>=0 do pt;
   s := maxstk;
   while s>=np do pt;
end; (*pmd*)

procedure errori(string: beta);
begin writeln; writeln(string);
      pmd; goto 1
end;(*errori*)

function base(ld :integer):address;
   var ad :address;
begin  ad := mp;
   while ld>0 do
   begin  ad := store[ad+1].vm;  ld := ld-1
   end;
   base := ad
end; (*base*)

procedure compare;
(*comparing is only correct if result by comparing integers will be*)
begin
  i1 := store[sp].va;
  i2 := store[sp+1].va;
  i := 0; b := true;
  while b and (i<>q) do
    if store[i1+i].vi = store[i2+i].vi then i := i+1
    else b := false
end; (*compare*)

procedure callsp;
   var line: boolean; adptr,adelnt: address;
       i: integer;

   procedure readi(var f:text);
      var ad: address;
   begin ad:= store[sp-1].va;
	 read(f,store[ad].vi);
	 store[store[sp].va].vc := f^;
	 sp:= sp-2
   end;(*readi*)

   procedure readr(var f: text);
      var ad: address;
   begin ad:= store[sp-1].va;
	 read(f,store[ad].vr);
	 store[store[sp].va].vc := f^;
	 sp:= sp-2
   end;(*readr*)

   procedure readc(var f: text);
      var c: char; ad: address;
   begin read(f,c);
	 ad:= store[sp-1].va;
	 store[ad].vc := c;
	 store[store[sp].va].vc := f^;
	 store[store[sp].va].vi := ord(f^);
	 sp:= sp-2
   end;(*readc*)

   procedure writestr(var f: text);
      var i,j,k: integer;
	  ad: address;
   begin ad:= store[sp-3].va;
	 k := store[sp-2].vi; j := store[sp-1].vi;
	 (* j and k are numbers of characters *)
	 if k>j then for i:=1 to k-j do write(f,' ')
		else j:= k;
	 for i := 0 to j-1 do write(f,store[ad+i].vc);
	 sp:= sp-4
   end;(*writestr*)

   procedure getfile(var f: text);
      var ad: address;
   begin ad:=store[sp].va;
	 get(f); store[ad].vc := f^;
	 sp:=sp-1
   end;(*getfile*)

   procedure putfile(var f: text);
      var ad: address;
   begin ad:= store[sp].va;
	 f^:= store[ad].vc; put(f);
	 sp:= sp-1;
   end;(*putfile*)

begin (*callsp*)
      case q of
	   0 (*get*): case store[sp].va of
			   5: getfile(input);
			   6: errori(' get on output file      ');
			   7: getfile(prd);
			   8: errori(' get on prr file	 ')
		      end;
	   1 (*put*): case store[sp].va of
			   5: errori(' put on read file	');
			   6: putfile(output);
			   7: errori(' put on prd file	 ');
			   8: putfile(prr)
		      end;
	   2 (*rst*): begin
			(*for testphase*)
			np := store[sp].va; sp := sp-1
		      end;
	   3 (*rln*): begin case store[sp].va of
				 5: begin readln(input);
				      store[inputadr].vc := input^
				    end;
				 6: errori(' readln on output file   ');
				 7: begin readln(input);
				      store[inputadr].vc := input^
				    end;
				 8: errori(' readln on prr file      ')
			    end;
			    sp:= sp-1
		      end;
	   4 (*new*): begin ad:= np-store[sp].va;
		      (*top of stack gives the length in units of storage *)
			    if ad <= ep then
			      errori(' store overflow	  ');
			    np:= ad; ad:= store[sp-1].va;
			    store[ad].va := np;
			    sp:=sp-2
		      end;
	   5 (*wln*): begin case store[sp].va of
				 5: errori(' writeln on input file   ');
				 6: writeln(output);
				 7: errori(' writeln on prd file     ');
				 8: writeln(prr)
			    end;
			    sp:= sp-1
		      end;
	   6 (*wrs*): case store[sp].va of
			   5: errori(' write on input file     ');
			   6: writestr(output);
			   7: errori(' write on prd file       ');
			   8: writestr(prr)
		      end;
	   7 (*eln*): begin case store[sp].va of
				 5: line:= eoln(input);
				 6: errori(' eoln output file	');
				 7: line:=eoln(prd);
				 8: errori(' eoln on prr file	')
			    end;
			    store[sp].vb := line
		      end;
	   8 (*wri*): begin case store[sp].va of
				 5: errori(' write on input file     ');
				 6: write(output,
				      store[sp-2].vi: store[sp-1].vi);
				 7: errori(' write on prd file       ');
				 8: write(prr,
				      store[sp-2].vi: store[sp-1].vi)
			    end;
			    sp:=sp-3
		      end;
	   9 (*wrr*): begin case store[sp].va of
				 5: errori(' write on input file     ');
				 6: write(output,
				      store[sp-2].vr: store[sp-1].vi);
				 7: errori(' write on prd file       ');
				 8: write(prr,
				      store[sp-2].vr: store[sp-1].vi)
			    end;
			    sp:=sp-3
		      end;
	   10(*wrc*): begin case store[sp].va of
				 5: errori(' write on input file     ');
				 6: write(output,store[sp-2].vc:
				      store[sp-1].vi);
				 7: errori(' write on prd file       ');
				 8: write(prr,chr(store[sp-2].vi):
				      store[sp-1].vi);
			    end;
			    sp:=sp-3
		      end;
	   11(*rdi*): case store[sp].va of
			   5: readi(input);
			   6: errori(' read on output file     ');
			   7: readi(prd);
			   8: errori(' read on prr file	')
		      end;
	   12(*rdr*): case store[sp].va of
			   5: readr(input);
			   6: errori(' read on output file     ');
			   7: readr(prd);
			   8: errori(' read on prr file	')
		      end;
	   13(*rdc*): case store[sp].va of
			   5: readc(input);
			   6: errori(' read on output file     ');
			   7: readc(prd);
			   8: errori(' read on prr file	')
		      end;
	   14(*sin*): store[sp].vr:= sin(store[sp].vr);
	   15(*cos*): store[sp].vr:= cos(store[sp].vr);
	   16(*exp*): store[sp].vr:= exp(store[sp].vr);
	   17(*log*): store[sp].vr:= ln(store[sp].vr);
	   18(*sqt*): store[sp].vr:= sqrt(store[sp].vr);
	   19(*atn*): store[sp].vr:= arctan(store[sp].vr);
	   20(*sav*): begin ad:=store[sp].va;
			 store[ad].va := np;
			 sp:= sp-1
		      end;
      end;(*case q*)
end;(*callsp*)

begin (* main *)
  rewrite(prr);
  load; (* assembles and stores code *)
  (* writeln(output); for testing *)
  pc := 0; sp := -1; mp := 0; np := maxstk+1; ep := 5;
  store[inputadr].vc := input^;
  store[prdadr].vc := prd^;
  interpreting := true;

  while interpreting do
  begin
    (*fetch*)
    with code[pc div 2] do
      if odd(pc) then
      begin op := op2; p := p2; q := q2
      end else
      begin op := op1; p := p1; q := q1
      end;
    pc := pc+1;

    (*execute*)
    case op of

	  105,106,107,108,109,
	  0 (*lod*): begin  ad := base(p) + q;
		      sp := sp+1;
		      store[sp] := store[ad]
		     end;

	  65,66,67,68,69,
	  1 (*ldo*): begin
		      sp := sp+1;
		      store[sp] := store[q]
		     end;

	  70,71,72,73,74,
	  2 (*str*): begin  store[base(p)+q] := store[sp];
		      sp := sp-1
		     end;

	  75,76,77,78,79,
	  3 (*sro*): begin  store[q] := store[sp];
		      sp := sp-1
		     end;

	  4 (*lda*): begin sp := sp+1;
		      store[sp].va := base(p) + q
		     end;

	  5 (*lao*): begin sp := sp+1;
		      store[sp].va := q
		     end;

	  80,81,82,83,84,
	  6 (*sto*): begin
		      store[store[sp-1].va] := store[sp];
		      sp := sp-2;
		     end;

	  7 (*ldc*): begin sp := sp+1;
		      if p=1 then
		      begin store[sp].vi := q;
		      end else
			  if p = 6 then store[sp].vc := chr(q)
			  else
			    if p = 3 then store[sp].vb := q = 1
			    else (* load nil *) store[sp].va := maxstr
		     end;

	  8 (*lci*): begin sp := sp+1;
		      store[sp] := store[q]
		     end;

	  85,86,87,88,89,
	  9 (*ind*): begin ad := store[sp].va + q;
		      (* q is a number of storage units *)
		      store[sp] := store[ad]
		     end;

	  90,91,92,93,94,
	  10 (*inc*): store[sp].vi := store[sp].vi+q;

	  11 (*mst*): begin (*p=level of calling procedure minus level of called
			      procedure + 1;  set dl and sl, increment sp*)
		       (* then length of this element is
			  max(intsize,realsize,boolsize,charsize,ptrsize *)
		       store[sp+2].vm := base(p);
		       (* the length of this element is ptrsize *)
		       store[sp+3].vm := mp;
		       (* idem *)
		       store[sp+4].vm := ep;
		       (* idem *)
		       sp := sp+5
		      end;

	  12 (*cup*): begin (*p=no of locations for parameters, q=entry point*)
		       mp := sp-(p+4);
		       store[mp+4].vm := pc;
		       pc := q
		      end;

	  13 (*ent*): if p = 1 then
			begin sp := mp + q; (*q = length of dataseg*)
			  if sp > np then errori(' store overflow	  ');
			end
		      else
			begin ep := sp+q;
			  if ep > np then errori(' store overflow	  ');
			end;
			(*q = max space required on stack*)

	  14 (*ret*): begin case p of
				 0: sp:= mp-1;
				 1,2,3,4,5: sp:= mp
			    end;
			    pc := store[mp+4].vm;
			    ep := store[mp+3].vm;
			    mp:= store[mp+2].vm;
		      end;

	  15 (*csp*): callsp;

	  16 (*ixa*): begin
		       i := store[sp].vi;
		       sp := sp-1;
		       store[sp].va := q*i+store[sp].va;
		      end;

	  17 (*equ*): begin  sp := sp-1;
		       case p of
			 1: store[sp].vb := store[sp].vi = store[sp+1].vi;
			 0: store[sp].vb := store[sp].va = store[sp+1].va;
			 6: store[sp].vb := store[sp].vc = store[sp+1].vc;
			 2: store[sp].vb := store[sp].vr = store[sp+1].vr;
			 3: store[sp].vb := store[sp].vb = store[sp+1].vb;
			 4: store[sp].vb := store[sp].vs = store[sp+1].vs;
			 5: begin  compare;
			       store[sp].vb := b;
			    end;
		       end; (*case p*)
		      end;

	  18 (*neq*): begin  sp := sp-1;
		       case p of
			 0: store[sp].vb := store[sp].va <> store[sp+1].va;
			 1: store[sp].vb := store[sp].vi <> store[sp+1].vi;
			 6: store[sp].vb := store[sp].vc <> store[sp+1].vc;
			 2: store[sp].vb := store[sp].vr <> store[sp+1].vr;
			 3: store[sp].vb := store[sp].vb <> store[sp+1].vb;
			 4: store[sp].vb := store[sp].vs <> store[sp+1].vs;
			 5: begin  compare;
			       store[sp].vb := not b;
			    end
		       end; (*case p*)
		      end;

	  19 (*geq*): begin  sp := sp-1;
		       case p of
			 0: errori(' <,<=,>,>= for address   ');
			 1: store[sp].vb := store[sp].vi >= store[sp+1].vi;
			 6: store[sp].vb := store[sp].vc >= store[sp+1].vc;
			 2: store[sp].vb := store[sp].vr >= store[sp+1].vr;
			 3: store[sp].vb := store[sp].vb >= store[sp+1].vb;
			 4: store[sp].vb := store[sp].vs >= store[sp+1].vs;
			 5: begin compare;
			      store[sp].vb := b or
				(store[i1+i].vi >= store[i2+i].vi)
			    end
		       end; (*case p*)
		      end;

	  20 (*grt*): begin  sp := sp-1;
		       case p of
			 0: errori(' <,<=,>,>= for address   ');
			 1: store[sp].vb := store[sp].vi > store[sp+1].vi;
			 6: store[sp].vb := store[sp].vc > store[sp+1].vc;
			 2: store[sp].vb := store[sp].vr > store[sp+1].vr;
			 3: store[sp].vb := store[sp].vb > store[sp+1].vb;
			 4: errori(' set inclusion	   ');
			 5: begin  compare;
			      store[sp].vb := not b and
				(store[i1+i].vi > store[i2+i].vi)
			    end
		       end; (*case p*)
		      end;

	  21 (*leq*): begin  sp := sp-1;
		       case p of
			 0: errori(' <,<=,>,>= for address   ');
			 1: store[sp].vb := store[sp].vi <= store[sp+1].vi;
			 6: store[sp].vb := store[sp].vc <= store[sp+1].vc;
			 2: store[sp].vb := store[sp].vr <= store[sp+1].vr;
			 3: store[sp].vb := store[sp].vb <= store[sp+1].vb;
			 4: store[sp].vb := store[sp].vs <= store[sp+1].vs;
			 5: begin  compare;
			      store[sp].vb := b or
				(store[i1+i].vi <= store[i2+i].vi)
			    end;
		       end; (*case p*)
		      end;

	  22 (*les*): begin  sp := sp-1;
		       case p of
			 0: errori(' <,<=,>,>= for address   ');
			 1: store[sp].vb := store[sp].vi < store[sp+1].vi;
			 6: store[sp].vb := store[sp].vc < store[sp+1].vc;
			 2: store[sp].vb := store[sp].vr < store[sp+1].vr;
			 3: store[sp].vb := store[sp].vb < store[sp+1].vb;
			 5: begin  compare;
			      store[sp].vb := not b and
				(store[i1+i].vi < store[i2+i].vi)
			    end
		       end; (*case p*)
		      end;

	  23 (*ujp*): pc := q;

	  24 (*fjp*): begin  if not store[sp].vb then pc := q;
		       sp := sp-1
		      end;

	  25 (*xjp*): begin
		       pc := store[sp].vi + q;
		       sp := sp-1
		      end;

	  95 (*chka*): if (store[sp].va < np) or
			  (store[sp].va > (maxstr-q)) then
			 errori(' bad pointer value       ');

	  96,97,98,99,
	  26 (*chk*): if (store[sp].vi < store[q-1].vi) or
			 (store[sp].vi > store[q].vi) then
			errori(' value out of range      ');

	  27 (*eof*): begin  i := store[sp].vi;
		       if i=inputadr then
		       begin store[sp].vb := eof(input);
		       end else errori(' code in error	   ')
		      end;

	  28 (*adi*): begin  sp := sp-1;
		       store[sp].vi := store[sp].vi + store[sp+1].vi
		      end;

	  29 (*adr*): begin  sp := sp-1;
		       store[sp].vr := store[sp].vr + store[sp+1].vr
		      end;

	  30 (*sbi*): begin sp := sp-1;
		       store[sp].vi := store[sp].vi - store[sp+1].vi
		      end;

	  31 (*sbr*): begin  sp := sp-1;
		       store[sp].vr := store[sp].vr - store[sp+1].vr
		      end;

	  32 (*sgs*): store[sp].vs := [store[sp].vi];

	  33 (*flt*): store[sp].vr := store[sp].vi;

	  34 (*flo*): store[sp-1].vr := store[sp-1].vi;

	  35 (*trc*): store[sp].vi := trunc(store[sp].vr);

	  36 (*ngi*): store[sp].vi := -store[sp].vi;

	  37 (*ngr*): store[sp].vr := -store[sp].vr;

	  38 (*sqi*): store[sp].vi := sqr(store[sp].vi);

	  39 (*sqr*): store[sp].vr := sqr(store[sp].vr);

	  40 (*abi*): store[sp].vi := abs(store[sp].vi);

	  41 (*abr*): store[sp].vr := abs(store[sp].vr);

	  42 (*not*): store[sp].vb := not store[sp].vb;

	  43 (*and*): begin  sp := sp-1;
		       store[sp].vb := store[sp].vb and store[sp+1].vb
		      end;

	  44 (*ior*): begin  sp := sp-1;
		       store[sp].vb := store[sp].vb or store[sp+1].vb
		      end;

	  45 (*dif*): begin  sp := sp-1;
		       store[sp].vs := store[sp].vs - store[sp+1].vs
		      end;

	  46 (*int*): begin  sp := sp-1;
		       store[sp].vs := store[sp].vs * store[sp+1].vs
		      end;

	  47 (*uni*): begin  sp := sp-1;
		       store[sp].vs := store[sp].vs + store[sp+1].vs
		      end;

	  48 (*inn*): begin
		       sp := sp - 1; i := store[sp].vi;
		       store[sp].vb := i in store[sp+1].vs;
		      end;

	  49 (*mod*): begin  sp := sp-1;
		       store[sp].vi := store[sp].vi mod store[sp+1].vi
		      end;

	  50 (*odd*): store[sp].vb := odd(store[sp].vi);

	  51 (*mpi*): begin  sp := sp-1;
		       store[sp].vi := store[sp].vi * store[sp+1].vi
		      end;

	  52 (*mpr*): begin  sp := sp-1;
		       store[sp].vr := store[sp].vr * store[sp+1].vr
		      end;

	  53 (*dvi*): begin  sp := sp-1;
		       store[sp].vi := store[sp].vi div store[sp+1].vi
		      end;

	  54 (*dvr*): begin  sp := sp-1;
		       store[sp].vr := store[sp].vr / store[sp+1].vr
		      end;

	  55 (*mov*): begin i1 := store[sp-1].va;
		       i2 := store[sp].va; sp := sp-2;
		       for i := 0 to q-1 do store[i1+i] := store[i2+i]
		       (* q is a number of storage units *)
		      end;

	  56 (*lca*): begin  sp := sp+1;
		       store[sp].va := q;
		      end;

	  100,101,102,103,104,
	  57 (*dec*): store[sp].vi := store[sp].vi-q;

	  58 (*stp*): interpreting := false;

	  59 (*ord*): (*only used to change the tagfield*)
		      begin
		      end;

	  60 (*chr*): begin
		      end;

	  61 (*ujc*): errori(' case - error	    ');
    end
  end; (*while interpreting*)

1 :
end.