[fpc-pascal] fcl-passrc errors
Michael Van Canneyt
michael at freepascal.org
Sun Oct 13 08:20:33 CEST 2019
On Sat, 12 Oct 2019, Ryan Joseph wrote:
>
>
> On Oct 12, 2019, at 6:43 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>
> 1) class operators for records
>
> EParserError: Expected "procedure" at token "operator" in file
> /Users/ryanjoseph/Developer/Projects/FPC/GLCanvas/GLCanvas.pas at line 115 column 7
>
> class operator TVertex3.= (constref a, b: TVertex3): boolean;
> begin
> result := (@a = @b);
> end;
>
>
> This can be.
>
>
> It’s a bug then? I found another advanced record bug below.
It's a little early to conclude this. The code supports class operators.
But see below.
> 2) For..in loops
>
> EParserError: Expected := or in at token "(" in file
> /Users/ryanjoseph/Developer/Projects/FPC/NewEngine/Sources/Examples/EmptyWindow.pas at line 138 column
> 14
>
>
> For in loops should be supported, but I've never seen this before:
>
> for pointer(entity) in entities do
>
>
> What is for pointer(entity) in entities supposed to do ?
>
> It can be that this syntax is not supported (no surprise, since I don't have
> a clue what this is supposed to do).
>
>
> Just type casting because the array is an array of pointers. I get these errors otherwise "Incompatible types: got "Pointer"
> expected “TEntity"”. I could use a proper type in a generic array but I don’t always do that.
I didn't know you could do this in a for in loop. FPC eats this ?
>
> begin
> entity.Update;
> entity.Draw(renderer);
> renderer.PushBox(entity.GetHitBox, TRGBA.RedColor);
> end;
>
> 3) {$i settings} will not find the file “settings.inc”. This is valid in FPC but the parser seems to
> have other rules.
>
>
> They should be the same.
>
> As said, pas2js uses fcl-passrc, and pas2js handles inifiles just as FPC
> does.
>
>
> Another bug then. Should I make a bug report for these?
Not yet.
I have no idea how you call the parser. Include files most
definitely work: the documentation generator uses fcl-passrc, and the
RTL/FCL is full of include files.
Probably your invocation of the parser is simply wrong or missing some
arguments.
>
> Here’s another one I found. No section headers in records?
>
> Expected "," or ":" at token "Identifier IDSize" in file
> /Users/ryanjoseph/Developer/Projects/FPC/NewEngine/Sources/Base/UImage.pas at line 94 column 4
Again, that works. These constructs can be found in the RTL/FCL and the
documentation generator parses that (and so does pas2js).
Disregarding the typecast in the for..in, concluding that there are bugs is very premature.
All constructs you mention are supported.
So the question is why you are getting errors for constructs that are
supported ?
Did you specify the advanced record modeswitch in the sources ?
Do you specify delphi mode when calling the parser ?
But the parser must be invoked correctly. If you don't invoke it correctly, then
of course you can expect it to report errors. If you use the default 'ParseSource'
function, that definitely does not cover all possible cases as handled by FPC.
It will not observe whatever you have in .fpc.cfg or /etc/fpc.cfg etc.
Also, are you using trunk or 3.0.4 ? There have been a massive amount of
updates to fcl-passrc.
Michael.
More information about the fpc-pascal
mailing list