procedure TPasSyntaxTreeBuilder.ArrayOfConst;
begin
//do not fill the name attribute. const is a keyword, not a type.
//note that the `anType` attribute is empty.
FStack.Push(ntType).Attribute[anKind]:= AttributeValues[atConst];
try
inherited;
finally
FStack.Pop;
end;
end;
procedure TmwSimplePasPar.ArrayType;
begin
Expected(ptArray);
ArrayBounds;
Expected(ptOf);
ArraySubType;
end;
procedure TmwSimplePasPar.ArrayOfConst;
begin
Expected(ptConst);
end;
procedure TmwSimplePasPar.ArraySubType;
begin
case TokenID of
ptConst: ArrayOfConst;
else TypeKind;
end;
end;
The following code:
Gets parsed as:
The
const
keyword is incorrectly tagged as an identifier. It is not.array of const
is a special construct that should be treated specially.See: http://www.dragonkiller.nl/Delphi/delphi2009.html#ArraySubType
I propose the following changes: