The next extensions that I did - still in 2011 - was to add some new keywords and new instructions for loop control. This was inspired from my C experience, where I found those instructions very useful, and IMO they don't compromise the structured programming style (much).
And: they are very easy to implement, because all work can be done at the P-Code level.
To make things transparent: the Pascal compiler consists of two passes; the first one is considered to be portable across platforms (which is not true in detail), and it builds code for an abstract stack oriented machine. This code is called P-Code. This P-Code is then translated by the second pass (which is a Pascal program, too) to 370 object code (files with CMS filetype TEXT, RECFM fixed, record length 80).
The changes mentioned above are all done to the first pass; there are no extensions to the P-Code, so the second pass needs not to be touched. All three extensions (BREAK, CONTINUE, LEAVE) are in fact some branches (jumps) to some place inside or outside the loop or to a certain place at the end of a procedure or function. If a branch target at the needed position didn't yet exist in the P-Code, a new one had to be built.
These extensions were done within hours, and this gave me some confidence that I will be able to do further - and more ambitioned - extensions - in the future. But anyway it lasted 5 years before I started again to do significant work on this compiler project - until 2016.
Example for the RETURN statement:
|
Example for BREAK and CONTINUE:
|
BREAK and CONTINUE work with all loop types, of course, that is: FOR loops, WHILE loops, and REPEAT ... UNTIL loops.