View Issue Details

IDProjectCategoryView StatusLast Update
0036825LazarusIDEpublic2020-03-29 13:31
ReporterBrunoK Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.0.7 (SVN) 
Summary0036825: jcf fails on >< Symmetric difference of two sets
Descriptiontype
  TSetDisjoin = (sdja,
    sdjb);
  TSetDisjoins = set of TSetDisjoin;
var
  lSetDisjoinA, lSetDisjoinB: TSetDisjoins;
begin
  lSetDisjoinA := lSetDisjoinA >< lSetDisjoinB;
end.
Additional InformationThis patch is a subset of my current version of JCF formatter, some changes in this where made because I find them more understandable for working on the units.

If requested I could also pass other changes re :
special compiler directives :
  - // VarDecl -> IdentList ':' Type [(ABSOLUTE (Ident | ConstExpr)) | '=' ConstExpr]
+ // (* attempted EBNF definition of a variable definition *)
+ // named : 'name' var_name
+ // exppubl : ( 'export' | 'public' ) [named] ';'
+ // external : ( 'external' [[lib_name] [named]] ';'
+ // absolute : 'absolute' var_name
+ // initvalue : '=' ConstExpr
+ // hints : [ 'deprecated'
+ // | 'experimental'
+ // | 'platform'
+ // | 'unimplemented' ]
+ // identlist : var_name { ',' var_name }
+ //
+ // vardef : identlist ':' vartype [ absolute ] ';'
+ // [( exppubl | external )] [ hints ]

compilerproc, alias,
attempted JCF on include files ( not very satisfactory for blind formatting ).
TagsNo tags attached.
Fixed in Revisionr62808, r62809
LazTarget-
Widgetset
Attached Files

Activities

BrunoK

2020-03-25 13:33

reporter  

On_r62805.patch (5,571 bytes)   
Index: components/jcf2/Parse/BuildParseTree.pas
===================================================================
--- components/jcf2/Parse/BuildParseTree.pas	(revision 62806)
+++ components/jcf2/Parse/BuildParseTree.pas	(working copy)
@@ -2397,7 +2397,7 @@
 
   if lc.TokenType = ttAbsolute then
   begin
-    PushNode(nAbsoluteVar);
+    PushNode(nVarAbsolute);
     Recognise(ttAbsolute);
 
     if (fcTokenList.FirstSolidWordType in IdentifierTypes) then
Index: components/jcf2/Parse/BuildTokenList.pas
===================================================================
--- components/jcf2/Parse/BuildTokenList.pas	(revision 62806)
+++ components/jcf2/Parse/BuildTokenList.pas	(working copy)
@@ -113,7 +113,7 @@
   JcfRegistrySettings;
 
 const
-  CurlyLeft = '{'; //widechar(123);
+  CurlyLeft =  '{'; //widechar(123);
   CurlyRight = '}'; //widechar(125);
 
 function CheckMultiByte(const pcChar: char): boolean;
@@ -642,7 +642,7 @@
   Result := True;
 end;
 
-{ ~bk 2014.11.01 - Bin numbers are prefixed with % }
+{ Bin numbers are prefixed with % }
 function TBuildTokenList.TryBinNumber(const pcToken: TSourceToken): boolean;
 begin
   Result := False;
Index: components/jcf2/Parse/ParseTreeNodeType.pas
===================================================================
--- components/jcf2/Parse/ParseTreeNodeType.pas	(revision 62806)
+++ components/jcf2/Parse/ParseTreeNodeType.pas	(working copy)
@@ -77,7 +77,7 @@
     nProcedureType,
     nVarSection,
     nVarDecl,
-    nAbsoluteVar,
+    nVarAbsolute,
     nVariableInit,
     nDesignator,
     nExpression,
@@ -279,7 +279,7 @@
       Result := 'Var section';
     nVarDecl:
       Result := 'Var decl';
-    nAbsoluteVar:
+    nVarAbsolute:
       Result := 'Absolute var';
     nVariableInit:
       Result := 'Variable init';
Index: components/jcf2/Parse/Tokens.pas
===================================================================
--- components/jcf2/Parse/Tokens.pas	(revision 62806)
+++ components/jcf2/Parse/Tokens.pas	(working copy)
@@ -63,9 +63,9 @@
     ttUnknown, // default category used for unrecognised input
 
     // spacing
-    ttReturn, // CR & LF chars
+    ttReturn,     // CR & LF chars
     ttWhiteSpace, // spaces & tabs
-    ttComment, // one of these
+    ttComment,    // one of these
     ttConditionalCompilationRemoved,
 
 
@@ -73,13 +73,13 @@
     ttQuotedLiteralString, // 'This is a string'
     ttSemicolon,     // ;
     ttColon,         // :
-    ttComma,
-    ttOpenBracket,
-    ttCloseBracket,
-    ttOpenSquareBracket,
-    ttCloseSquareBracket,
-    ttDot,
-    ttHash,
+    ttComma,         // ,
+    ttOpenBracket,       // (
+    ttCloseBracket,      // )
+    ttOpenSquareBracket, // [
+    ttCloseSquareBracket,// ]
+    ttDot,       // .
+    ttHash,      // #
     ttDoubleDot, // '..' as in '[1 .. 2]'
     ttAssign,    // :=
     ttAmpersand, // '&' is used in Asm
@@ -285,6 +285,7 @@
     ttGreaterThanOrEqual,
     ttLessThanOrEqual,
     ttNotEqual,
+    ttSetSymDif,
     ttBackSlash, { legal in char literals }
 
     // FreePascal c-style operators
@@ -400,7 +401,7 @@
 
   VariantTypes: TTokenTypeSet = [ttVariant, ttOleVariant];
 
-  Operators: TTokenTypeSet = [ttAnd .. ttNotEqual, ttEnumerator];
+  Operators: TTokenTypeSet = [ttAnd .. ttSetSymDif, ttEnumerator];
 
   { these words are
   - operators
@@ -410,7 +411,8 @@
 
   RelationalOperators: TTokenTypeSet = [
     ttIn, ttIs, ttAs, ttGreaterThan,
-    ttLessThan, ttGreaterThanOrEqual, ttLessThanOrEqual, ttEquals, ttNotEqual];
+    ttLessThan, ttGreaterThanOrEqual, ttLessThanOrEqual, ttEquals,
+    ttNotEqual, ttSetSymDif];
 
   AddOperators: TTokenTypeSet = [ttPlus, ttMinus, ttOr, ttXor];
 
@@ -422,7 +424,7 @@
     // all operators that are always binary
     ttAnd, ttAs, ttDiv, ttIn, ttIs, ttMod, ttOr, ttShl, ttShr, ttXor,
     ttTimes, ttFloatDiv, ttExponent, ttEquals, ttGreaterThan, ttLessThan,
-    ttGreaterThanOrEqual, ttLessThanOrEqual, ttNotEqual];
+    ttGreaterThanOrEqual, ttLessThanOrEqual, ttNotEqual, ttSetSymDif];
 
   StringWords: TTokenTypeSet = [ttString, ttAnsiString, ttWideString];
 
@@ -788,6 +790,7 @@
   AddKeyword('>=', wtOperator, ttGreaterThanOrEqual);
   AddKeyword('<=', wtOperator, ttLessThanOrEqual);
   AddKeyword('<>', wtOperator, ttNotEqual);
+  AddKeyword('><', wtOperator, ttSetSymDif);
   // these must come after the above as they are shorter
   AddKeyword('>', wtOperator, ttGreaterThan);
   AddKeyword('<', wtOperator, ttLessThan);
Index: components/jcf2/Process/Spacing/SingleSpaceAfter.pas
===================================================================
--- components/jcf2/Process/Spacing/SingleSpaceAfter.pas	(revision 62806)
+++ components/jcf2/Process/Spacing/SingleSpaceAfter.pas	(working copy)
@@ -152,7 +152,7 @@
   end;
 
   { 'absolute' as a var directive }
-  if (pt.TokenType = ttAbsolute) and pt.HasParentNode(nAbsoluteVar) then
+  if (pt.TokenType = ttAbsolute) and pt.HasParentNode(nVarAbsolute) then
   begin
     Result := True;
     exit;
Index: components/jcf2/Process/Spacing/SingleSpaceBefore.pas
===================================================================
--- components/jcf2/Process/Spacing/SingleSpaceBefore.pas	(revision 62806)
+++ components/jcf2/Process/Spacing/SingleSpaceBefore.pas	(working copy)
@@ -206,7 +206,7 @@
   end;
 
   { 'absolute' as a var directive }
-  if (pt.TokenType = ttAbsolute) and pt.HasParentNode(nAbsoluteVar) then
+  if (pt.TokenType = ttAbsolute) and pt.HasParentNode(nVarAbsolute) then
   begin
     Result := True;
     exit;
On_r62805.patch (5,571 bytes)   

Juha Manninen

2020-03-25 14:53

developer   ~0121707

I split your patch between the fix and the formatting. I also added the comments from "Additional Information".
Thanks.

BrunoK

2020-03-25 16:52

reporter   ~0121711

@Juha Manninen:
62808 Ok (><)

62809 I think you shouldn't add the EBNF comments in BuildParseTree.pas since it is not implemented in 62808 or 62809.

If you define which one might be useful, I could try to make a proper patches.

After quite a lot of practice with JCF, I use it now with great care. Being able to improve the formatting of some of the FPC code for understanding is good, but what would be ideal is, well, you know, hum, that it would be integrated in the code tools ... and applicable to code selection in the editor.

delfion

2020-03-29 13:31

reporter   ~0121749

1) Reopen the issue so your remark is notified (maybe).
2) Please do not add non related stuff to the issue.

Issue History

Date Modified Username Field Change
2020-03-25 13:33 BrunoK New Issue
2020-03-25 13:33 BrunoK File Added: On_r62805.patch
2020-03-25 14:35 Juha Manninen Assigned To => Juha Manninen
2020-03-25 14:35 Juha Manninen Status new => assigned
2020-03-25 14:53 Juha Manninen Status assigned => resolved
2020-03-25 14:53 Juha Manninen Resolution open => fixed
2020-03-25 14:53 Juha Manninen Fixed in Revision => r62808, r62809
2020-03-25 14:53 Juha Manninen LazTarget => -
2020-03-25 14:53 Juha Manninen Note Added: 0121707
2020-03-25 16:52 BrunoK Note Added: 0121711
2020-03-29 13:31 delfion Note Added: 0121749