Thanks to everyone who responded.
I am trying to write a compliant 7185 compiler from 7185 compliant source.
The problem arose because my compiler produced an error on the construct described when it compiled itself.
I think that ( b )^.Field1 is a compliant work around because the expression will be treated as a variable access.
I am using the 7185 spec rather than 10206 because it is much smaller and within a single person's scope. Also the compiler is intended for embedded systems where there is less need for advanced features.
UsingÂ the 7185 spec as a base grammar will allow for grammar additions, such a interrupt directives, to be added to a well specified grammar as small tweaks.
As well, 7185 is specified as a single source file so there is no need for a link editor to stitch together various pieces of object code to produce an executable. Without need for a linker, the complier becomes much more portable. There are many more embedded CPU chips than larger scale CPUs with operating systems.
Paul Isaacs wrote:
: I think that ( b )^.Field1 is a compliant work around because the : expression will be treated as a variable access.
AFAICS it is "less compiliant". Namely, without parentheses it is valid Extended Pascal. With parenthesis it no longer valid Extended Pascal (and clearly not valid ISO 7185).
: I am using the 7185 spec rather than 10206 because it is much smaller : and within a single person's scope. Also the compiler is intended for : embedded systems where there is less need for advanced features.
Already ISO 7185 is demanding. In particular nested functions, conformant arrays, set and file types add extra complexity. OTOH several ISO 7185 restrictions do not simplify implementation (it may get more complex due to extra checks). What you noted is one example, strict order of declarations is another example. For embedded use you almost surely will want more flexible handling of pointes than in ISO 7185.
: As well, 7185 is specified as a single source file so there is no need : for a link editor to stitch together various pieces of object code to : produce an executable.
Let me remark that ISO 10206 also specifies single file (GPC is noncompliant here demanding separate files). OTOH even for quite small programs more structuring is quite useful. ISO 10206 modules may be too much, USCD (and later Turbo Pascal) units are simpler. Still, even ISO modules are not very hard to implement (in GPC this part is hairy because GPC wants to avoid recompiling the same file but also takes source from different files).
In embedded system you will want to have some assembler routines, so linker will be handy. And linkers are not har to write (and widely available, you can use ready one).