Lazarus

Programming => Packages and Libraries => Topic started by: simone on November 11, 2019, 04:36:59 pm

Title: JCF formatter bug with global properties
Post by: simone on November 11, 2019, 04:36:59 pm
The following code compile without errors:

Code: Pascal  [Select][+][-]
  1. Program property0;
  2. Var
  3.   fProp : integer;
  4.  
  5. function GetProp:integer;
  6. begin
  7.   Result:=fProp;
  8. end;
  9.  
  10. procedure SetProp(VarIn : integer);
  11. begin
  12.   fProp:=VarIn;
  13. end;
  14.  
  15. property Prop : integer Read GetProp Write SetProp;
  16.  
  17. begin
  18. End.

But if I try to format it with JCF formatter, I get the following message error:

project1.lpr(15,1) Error: Exception TEParseError  Unexpected token, expected "BEGIN" Near PROPERTY

Is it a bug of JCF? Thanks.
Title: Re: JCF formatter bug with global properties
Post by: rvk on November 11, 2019, 04:50:54 pm
I don't think the JCF Formatter has any notion of the idea of "local property".

So, as far as the JCF Formatter concerned this is invalid syntax.
Title: Re: JCF formatter bug with global properties
Post by: simone on November 11, 2019, 05:00:02 pm
I think you mean 'global property'. I know FPC allows this feature in ObjFPC mode, whereas in Delphi mode this concept does not exist.

So, does JCF support only Delphi mode syntax?
Title: Re: JCF formatter bug with global properties
Post by: rvk on November 11, 2019, 05:09:50 pm
You code snippet gave a hint:
Quote
Hint: Local property "Prop" is not used
So I assumed this feature was called "Local property".

Anyway, yes, it seems to be some new feature in (obj)FPC and Delphi doesn't support it.
JCF also has more issues with newer features in FPC.

Even de code formatter in Delphi sometimes has hiccups with newer features but at least that one doesn't check syntax. I found the requirement of correct syntax really annoying in JCF Formatter in Lazarus.

You could try to post it as a bug in the bugtracker but I'm not sure the JCF Formatter is actively maintained for new features.
Title: Re: JCF formatter bug with global properties
Post by: Thaddy on November 11, 2019, 05:24:22 pm
The JCF formatter is completely unusable for current objfpc syntax.
I would use ptop instead. Also not perfect. Comes as standard with FreePascal.
Title: Re: JCF formatter bug with global properties
Post by: simone on November 11, 2019, 05:24:41 pm
You are right: the message error is misleading. My code generator uses JCF to format code. I will chek if ptop is able to parse and format code with this peculiar feature. Thanks for the help.
Title: Re: JCF formatter bug with global properties
Post by: simone on November 11, 2019, 05:27:58 pm
Thanks Thaddy, our posts have crossed. In the past I tried to use ptop in my project, but I had some difficulties to interface my code with it. Now I try again (I hope I have improved my skills in the meantime  :))
TinyPortal © 2005-2018