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.
Thank you,
Paul Isaacs
Le 22 janv. 2021 à 08:08, Paul Isaacs paul@redpineinstruments.org a écrit :
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.
The expression b^.field1 is not correct, since b^ is not, because b is an expression, not a variable. However, in my opinion, the syntax should allow one to write b^ where b is an expression. It seems to me that the syntax itself is mistaken, while the program meaning is clear.
Baudouin
Thank you,
Paul Isaacs
Gpc mailing list Gpc@gnu.de https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.g-n-u....
On Jan 21, 2021, at 11:08 PM, Paul Isaacs paul@redpineinstruments.org 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 gpaeper@empirenet.com