Recent

Author Topic: JCF formatter bug with global properties  (Read 181 times)

simone

  • Sr. Member
  • ****
  • Posts: 253
JCF formatter bug with global properties
« 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.

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: JCF formatter bug with global properties
« Reply #1 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.

simone

  • Sr. Member
  • ****
  • Posts: 253
Re: JCF formatter bug with global properties
« Reply #2 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?

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: JCF formatter bug with global properties
« Reply #3 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.

Thaddy

  • Hero Member
  • *****
  • Posts: 9156
Re: JCF formatter bug with global properties
« Reply #4 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.
« Last Edit: November 11, 2019, 05:30:25 pm by Thaddy »
also related to equus asinus.

simone

  • Sr. Member
  • ****
  • Posts: 253
Re: JCF formatter bug with global properties
« Reply #5 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.

simone

  • Sr. Member
  • ****
  • Posts: 253
Re: JCF formatter bug with global properties
« Reply #6 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  :))
« Last Edit: November 11, 2019, 07:10:14 pm by simone »