Back to Compiler main page
Compiler version: 08.2017
The improvement on Pascal sets took longer as expected. In fact I tried far too many changes in one sprint, and so the new version did not run at all. I had to fall back to the previous version and restart work from there, and I had to restructure first some parts of the internal set representation ... and some of the goals have to be moved to a later completion date.
The new version has the following extensions:
- Pascal sets now may have up to 2000 elements (previous 256)
- the internal origin of the set type is still zero
- that is: sets have to be in the range 0 .. 1999
- they may be of char type, integer subrange type, or scalar (aka enum)
- all integer subrange set types are compatible
- no negative integers in sets
- some errors removed and some performance enhancements
- characters and integers inside of set constants may be written in hex and binary notation
(example: 0x0a for integers, x'0a' and B'1111_0000' for characters)
- the PCINT debugger has been improved (type ? for online help)
Further improvements will be done in the next releases (preparations have been done already):
- min and max value of set types not limited to 0 .. 1999
- the origin may be in the range -16.000.000 to +16.000.000 (for integer subranges);
negative integers in sets are possible
- warning on portability issues with hex and binary constants in sets
- run time errors, when assigning out-of-range constants to sets (or sets of other subrange types)
- simpler P-Code instructions for sets
- new release of the P-Code documentation with the reworked set instructions (and other changed P-Code instructions)
The new version of the compiler uses the new feature already;
for example: at the end the compiler shows a listing of
all error messages issued (by error message type).
Because the maximum error message code is 999 (was 401 before), is it now possible to build a "set of errcode", where errcode is a subrange "1 .. maxerrnr".
The following example shows, how a boolean expression involving IN and a char based set constant is implemented. First you see the (portable) P-Code, and then the resulting machine instructions from the Mainframe variant (generated by the P-Code to 370 translator PASCAL2.PAS).
The generated P-Code looks like this (only the IF part is shown, not the WRITELN) - including some comments on the right side:
The copy to workarea could be omitted in future releases, room for improvement.
The P-Code translator builds the following 370-code from this (you may notice that no code is produced for the SLD instruction, which copies the set):
Of course, this only works, because the characters in the set constant are within a codepage range of size 32. If the set range is larger, there are other implementations. But anyway: the original implementors of PASCAL2 did a great job, and I tried not to compromise this, although the maximum size of sets has been extended.
The new version will be available in the next few days from the New Stanford Pascal compiler website.
Back to Compiler main page