minimum length of subsequent + #69

Open
opened 2021-05-08 14:48:34 +00:00 by benibela · 1 comment
benibela commented 2021-05-08 14:48:34 +00:00 (Migrated from github.com)

Subsequent + imply a minimal length of the string.

These match, but should not:

 writeln(TFLRE.Create('^(?:\d+\d+\d+)$', []).Find('12'));
 writeln(TFLRE.Create('^(?:\d+\d+\p{Nd}\d+)$', []).Find('123'));
Subsequent `+` imply a minimal length of the string. These match, but should not: writeln(TFLRE.Create('^(?:\d+\d+\d+)$', []).Find('12')); writeln(TFLRE.Create('^(?:\d+\d+\p{Nd}\d+)$', []).Find('123'));
benibela commented 2023-07-08 22:21:41 +00:00 (Migrated from github.com)

This is still broken

See also:

program Project1;
uses FLRE;
var
  f: TFLRE;
begin
  f := TFLRE.Create('^(?:\d+\d+\d+\d+)$', []);
writeln(  f.DumpRegularExpression );
  writeln(f.Test('1'));
  writeln(f.Test('12'));
  writeln(f.Test('123'));
  writeln(f.Test('1234'));
  writeln(f.Test('12345'));
end.

My PR #77 had fixed it

Perhaps it should be like this now:

function ConcatEqualPlus(const NodeLeftMightBecomeCat,PlusNodeRight:PFLRENode):PFLRENode;
 begin
  if (NodeLeftMightBecomeCat^.NodeType=ntPLUS)
    // assigned(NodeLeftMightBecomeCat^.Right) and
//     (PlusNodeRight^.NodeType=ntPLUS)
     then begin
   NodeLeftMightBecomeCat^.NodeType:=ntCAT;
   NodeLeftMightBecomeCat^.Right:=PlusNodeRight;
   result:=NodeLeftMightBecomeCat;
  end else begin
   result:=PlusNodeRight;
  end;
 end;       
This is still broken See also: ``` program Project1; uses FLRE; var f: TFLRE; begin f := TFLRE.Create('^(?:\d+\d+\d+\d+)$', []); writeln( f.DumpRegularExpression ); writeln(f.Test('1')); writeln(f.Test('12')); writeln(f.Test('123')); writeln(f.Test('1234')); writeln(f.Test('12345')); end. ``` My PR #77 had fixed it Perhaps it should be like this now: ``` function ConcatEqualPlus(const NodeLeftMightBecomeCat,PlusNodeRight:PFLRENode):PFLRENode; begin if (NodeLeftMightBecomeCat^.NodeType=ntPLUS) // assigned(NodeLeftMightBecomeCat^.Right) and // (PlusNodeRight^.NodeType=ntPLUS) then begin NodeLeftMightBecomeCat^.NodeType:=ntCAT; NodeLeftMightBecomeCat^.Right:=PlusNodeRight; result:=NodeLeftMightBecomeCat; end else begin result:=PlusNodeRight; end; end; ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BeRo1985/flre#69
No description provided.