Re: ISO7185 compliance

Gale Paeper <[email protected]> Fri, 22 Jan 2021 02:15:00 -0800
Newsgroups gmane.comp.compilers.gpc
Message-ID <[email protected]>

> On Jan 21, 2021, at 11:08 PM, Paul Isaacs <[email protected]> wrote:
> 
> Hello:
> 
> gpc --classic-pascal compiles the following without error:
> 
> procedure test;
> type
>  xHandle             = ^xRecord;
>  xRecord             = record
>                         field1   : integer;
>                        end;
> var
>  a                   : integer;
> 
>  function b          : xHandle;
>  var
>   c                  : xHandle;
>  begin
>   b                  := c;
>  end;
> begin
>  a                   := b^.field1;
> end;
> 
> Is this 7185 compliant?
> 
> The right hand side of the assignment is a 6.7.3 function-designator rule :
> 
>       function-designator = function-identifier [ actual-parameter-list ] .
> 
> followed by "^."
> 
> I can not see how the grammar permits the following pointer and record accesses.

I think you're correct that "b^.field1" is not legal according to ISO 7185 expression grammar rules. (Of course, even if the syntax was legal the program would still be erroneous since it is trying to use an undefined pointer-variable.)

The construct is legal in Extended Pascal, ISO 10206. The grammar definition of variable-access was expanded to include function-identified-variable which in turn adds accessing the function returned pointer identified variable in an expression. Since Extended Pascal also expanded allowing structured types in addition to pointer and simple types for function return types, the expression grammar was also expanded to include allowing function-accesses of the components of structured types in expressions albeit with some restrictions on context of legal usage that is different from variable-access rules.

Gale Paeper
[email protected]