View Issue Details

IDProjectCategoryView StatusLast Update
0030970FPCFCLpublic2016-11-29 13:37
ReporterwpAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0030970: [Feature Request & Patch] Add symbol ^ to fpexpressionparser (power)
DescriptionThe FpExpressionParser is lacking a symbol for calculation of power expressions. The attached patch introduces the symbol ^ for this purpose.

Example
parser.Exression := '2^3'; // ---> power(2, 3)
Additional InformationI am not familiar with the fpc test suite. So, I just added a simple demo checking the important cases which come to my mind.
TagsNo tags attached.
Fixed in Revision34967
FPCOldBugId
FPCTarget
Attached Files
  • fpexprpars.pp.patch (4,586 bytes)
    Index: fcl-base/src/fpexprpars.pp
    ===================================================================
    --- fcl-base/src/fpexprpars.pp	(revision 34914)
    +++ fcl-base/src/fpexprpars.pp	(working copy)
    @@ -28,7 +28,7 @@
                     ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
                     ttunequal, ttNumber, ttString, ttIdentifier,
                     ttComma, ttand, ttOr,ttXor,ttTrue,ttFalse,ttnot,ttif,
    -                ttCase,ttEOF);
    +                ttCase,ttEOF, ttPower);
     
       TExprFloat = Double;
     
    @@ -35,7 +35,7 @@
     Const
       ttDelimiters = [ttPlus, ttMinus, ttLessThan, ttLargerThan, ttEqual, ttDiv,
                       ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
    -                  ttunequal];
    +                  ttunequal, ttPower];
       ttComparisons = [ttLargerThan,ttLessthan,
                        ttLargerThanEqual,ttLessthanEqual,
                        ttEqual,ttUnequal];
    @@ -329,6 +329,16 @@
         Procedure GetNodeValue(var Result : TFPExpressionResult); override;
       end;
     
    +  { TFPPowerOperation }
    +  TFPPowerOperation = class(TMathOperation)
    +  public
    +    Procedure Check; override;
    +    Function AsString : string ; override;
    +    Function NodeType : TResultType; override;
    +    Procedure GetNodeValue(var Result : TFPExpressionResult); override;
    +  end;
    +
    +
       { TFPUnaryOperator }
     
       TFPUnaryOperator = Class(TFPExprNode)
    @@ -673,6 +683,7 @@
         Function Level4 : TFPExprNode;
         Function Level5 : TFPExprNode;
         Function Level6 : TFPExprNode;
    +    Function Level7 : TFPExprNode;
         Function Primitive : TFPExprNode;
         function GetToken: TTokenType;
         Function TokenType : TTokenType;
    @@ -759,9 +770,9 @@
     
       Digits        = ['0'..'9','.'];
       WhiteSpace    = [' ',#13,#10,#9];
    -  Operators     = ['+','-','<','>','=','/','*'];
    +  Operators     = ['+','-','<','>','=','/','*','^'];
       Delimiters    = Operators+[',','(',')'];
    -  Symbols       = ['%','^']+Delimiters;
    +  Symbols       = ['%']+Delimiters;
       WordDelimiters = WhiteSpace + Symbols;
     
     Resourcestring
    @@ -1107,6 +1118,7 @@
           '(' : Result := ttLeft;
           ')' : Result := ttRight;
           ',' : Result := ttComma;
    +      '^' : Result := ttPower;
         else
           ScanError(Format(SUnknownDelimiter,[D]));
         end;
    @@ -1376,8 +1388,6 @@
     end;
     
     function TFPExpressionParser.ConvertNode(Todo : TFPExprNode; ToType : TResultType): TFPExprNode;
    -
    -
     begin
       Result:=ToDo;
       Case ToDo.NodeType of
    @@ -1646,8 +1656,28 @@
     end;
     
     function TFPExpressionParser.Level6: TFPExprNode;
    +var
    +  right: TFPExprNode;
     begin
    -{$ifdef debugexpr}  Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
    +{$ifdef debugexpr} Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
    +  Result := Level7;
    +  try
    +    while (TokenType = ttPower) do
    +    begin
    +      GetToken;
    +      right := Level5;           // Accept '(', unary '+', '-' as next tokens
    +      CheckNodes(Result, right);
    +      Result := TFPPowerOperation.Create(Result, right);
    +    end;
    +  except
    +    Result.Free;
    +    Raise;
    +  end;
    +end;
    +
    +function TFPExpressionParser.Level7: TFPExprNode;
    +begin
    +{$ifdef debugexpr}  Writeln('Level 7 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
       if (TokenType=ttLeft) then
         begin
         GetToken;
    @@ -3192,6 +3222,49 @@
       Result.ResultType:=rtFloat;
     end;
     
    +{ TFPPowerOperation }
    +
    +procedure TFPPowerOperation.Check;
    +const
    +  AllowedTypes = [rtInteger, rtFloat];
    +begin
    +  CheckNodeType(Left, AllowedTypes);
    +  CheckNodeType(Right, AllowedTypes);
    +end;
    +
    +function TFPPowerOperation.AsString: String;
    +begin
    +  Result := Left.AsString + '^' + Right.AsString;
    +end;
    +
    +function TFPPowerOperation.NodeType: TResultType;
    +begin
    +  Result := rtFloat;
    +end;
    +
    +function power(base,exponent: TExprFloat): TExprFloat;
    +// Adapted from unit "math"
    +begin
    +  if Exponent = 0.0 then
    +    result := 1.0
    +  else if (base = 0.0) and (exponent > 0.0) then
    +    result := 0.0
    +  else if (base < 0.0) and (frac(exponent) = 0.0) then
    +    result := -exp( exponent * ln(-base) )
    +  else
    +    result := exp( exponent * ln(base) );
    +end;
    +
    +procedure TFPPowerOperation.GetNodeValue(var Result: TFPExpressionResult);
    +var
    +  RRes: TFPExpressionResult;
    +begin
    +  Left.GetNodeValue(Result);    // BASE
    +  Right.GetNodeValue(RRes);     // EXPONENT
    +  Result.ResFloat := power(ArgToFloat(Result), ArgToFloat(RRes)); //exp(ArgToFloat(RRes) * ln(ArgToFloat(LRes)));  // exp( EXPONENT * ln(BASE) )
    +  Result.ResultType := rtFloat;
    +end;
    +
     { TFPConvertNode }
     
     function TFPConvertNode.AsString: String;
    
    fpexprpars.pp.patch (4,586 bytes)
  • fpexprpars_PowerOp_test.zip (1,591 bytes)
  • fpexprpars-v2.patch (4,584 bytes)
    Index: fcl-base/src/fpexprpars.pp
    ===================================================================
    --- fcl-base/src/fpexprpars.pp	(revision 34914)
    +++ fcl-base/src/fpexprpars.pp	(working copy)
    @@ -28,7 +28,7 @@
                     ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
                     ttunequal, ttNumber, ttString, ttIdentifier,
                     ttComma, ttand, ttOr,ttXor,ttTrue,ttFalse,ttnot,ttif,
    -                ttCase,ttEOF);
    +                ttCase,ttEOF, ttPower);
     
       TExprFloat = Double;
     
    @@ -35,7 +35,7 @@
     Const
       ttDelimiters = [ttPlus, ttMinus, ttLessThan, ttLargerThan, ttEqual, ttDiv,
                       ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
    -                  ttunequal];
    +                  ttunequal, ttPower];
       ttComparisons = [ttLargerThan,ttLessthan,
                        ttLargerThanEqual,ttLessthanEqual,
                        ttEqual,ttUnequal];
    @@ -329,6 +329,16 @@
         Procedure GetNodeValue(var Result : TFPExpressionResult); override;
       end;
     
    +  { TFPPowerOperation }
    +  TFPPowerOperation = class(TMathOperation)
    +  public
    +    Procedure Check; override;
    +    Function AsString : string ; override;
    +    Function NodeType : TResultType; override;
    +    Procedure GetNodeValue(var Result : TFPExpressionResult); override;
    +  end;
    +
    +
       { TFPUnaryOperator }
     
       TFPUnaryOperator = Class(TFPExprNode)
    @@ -673,6 +683,7 @@
         Function Level4 : TFPExprNode;
         Function Level5 : TFPExprNode;
         Function Level6 : TFPExprNode;
    +    Function Level7 : TFPExprNode;
         Function Primitive : TFPExprNode;
         function GetToken: TTokenType;
         Function TokenType : TTokenType;
    @@ -759,9 +770,9 @@
     
       Digits        = ['0'..'9','.'];
       WhiteSpace    = [' ',#13,#10,#9];
    -  Operators     = ['+','-','<','>','=','/','*'];
    +  Operators     = ['+','-','<','>','=','/','*','^'];
       Delimiters    = Operators+[',','(',')'];
    -  Symbols       = ['%','^']+Delimiters;
    +  Symbols       = ['%']+Delimiters;
       WordDelimiters = WhiteSpace + Symbols;
     
     Resourcestring
    @@ -1107,6 +1118,7 @@
           '(' : Result := ttLeft;
           ')' : Result := ttRight;
           ',' : Result := ttComma;
    +      '^' : Result := ttPower;
         else
           ScanError(Format(SUnknownDelimiter,[D]));
         end;
    @@ -1376,8 +1388,6 @@
     end;
     
     function TFPExpressionParser.ConvertNode(Todo : TFPExprNode; ToType : TResultType): TFPExprNode;
    -
    -
     begin
       Result:=ToDo;
       Case ToDo.NodeType of
    @@ -1646,8 +1656,28 @@
     end;
     
     function TFPExpressionParser.Level6: TFPExprNode;
    +var
    +  right: TFPExprNode;
     begin
    -{$ifdef debugexpr}  Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
    +{$ifdef debugexpr} Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
    +  Result := Level7;
    +  try
    +    while (TokenType = ttPower) do
    +    begin
    +      GetToken;
    +      right := Level5;           // Accept '(', unary '+', '-' as next tokens
    +      CheckNodes(Result, right);
    +      Result := TFPPowerOperation.Create(Result, right);
    +    end;
    +  except
    +    Result.Free;
    +    Raise;
    +  end;
    +end;
    +
    +function TFPExpressionParser.Level7: TFPExprNode;
    +begin
    +{$ifdef debugexpr}  Writeln('Level 7 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
       if (TokenType=ttLeft) then
         begin
         GetToken;
    @@ -3192,6 +3222,55 @@
       Result.ResultType:=rtFloat;
     end;
     
    +{ TFPPowerOperation }
    +
    +procedure TFPPowerOperation.Check;
    +const
    +  AllowedTypes = [rtInteger, rtFloat];
    +begin
    +  CheckNodeType(Left, AllowedTypes);
    +  CheckNodeType(Right, AllowedTypes);
    +end;
    +
    +function TFPPowerOperation.AsString: String;
    +begin
    +  Result := Left.AsString + '^' + Right.AsString;
    +end;
    +
    +function TFPPowerOperation.NodeType: TResultType;
    +begin
    +  Result := rtFloat;
    +end;
    +
    +function power(base,exponent: TExprFloat): TExprFloat;
    +// Adapted from unit "math"
    +var
    +  ex: Integer;
    +begin
    +  if Exponent = 0.0 then
    +    result := 1.0
    +  else if (base = 0.0) and (exponent > 0.0) then
    +    result := 0.0
    +  else if (base < 0.0) and (frac(exponent) = 0.0) then
    +  begin
    +    ex := round(exponent);
    +    result := exp( exponent * ln(-base));
    +    if odd(ex) then result := -result;
    +  end
    +  else
    +    result := exp( exponent * ln(base) );
    +end;
    +
    +procedure TFPPowerOperation.GetNodeValue(var Result: TFPExpressionResult);
    +var
    +  RRes: TFPExpressionResult;
    +begin
    +  Left.GetNodeValue(Result);
    +  Right.GetNodeValue(RRes);
    +  Result.ResFloat := power(ArgToFloat(Result), ArgToFloat(RRes));
    +  Result.ResultType := rtFloat;
    +end;
    +
     { TFPConvertNode }
     
     function TFPConvertNode.AsString: String;
    
    fpexprpars-v2.patch (4,584 bytes)
  • fpexprpars_PowerOp_test_v2.zip (1,797 bytes)

Activities

wp

2016-11-20 22:53

reporter  

fpexprpars.pp.patch (4,586 bytes)
Index: fcl-base/src/fpexprpars.pp
===================================================================
--- fcl-base/src/fpexprpars.pp	(revision 34914)
+++ fcl-base/src/fpexprpars.pp	(working copy)
@@ -28,7 +28,7 @@
                 ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
                 ttunequal, ttNumber, ttString, ttIdentifier,
                 ttComma, ttand, ttOr,ttXor,ttTrue,ttFalse,ttnot,ttif,
-                ttCase,ttEOF);
+                ttCase,ttEOF, ttPower);
 
   TExprFloat = Double;
 
@@ -35,7 +35,7 @@
 Const
   ttDelimiters = [ttPlus, ttMinus, ttLessThan, ttLargerThan, ttEqual, ttDiv,
                   ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
-                  ttunequal];
+                  ttunequal, ttPower];
   ttComparisons = [ttLargerThan,ttLessthan,
                    ttLargerThanEqual,ttLessthanEqual,
                    ttEqual,ttUnequal];
@@ -329,6 +329,16 @@
     Procedure GetNodeValue(var Result : TFPExpressionResult); override;
   end;
 
+  { TFPPowerOperation }
+  TFPPowerOperation = class(TMathOperation)
+  public
+    Procedure Check; override;
+    Function AsString : string ; override;
+    Function NodeType : TResultType; override;
+    Procedure GetNodeValue(var Result : TFPExpressionResult); override;
+  end;
+
+
   { TFPUnaryOperator }
 
   TFPUnaryOperator = Class(TFPExprNode)
@@ -673,6 +683,7 @@
     Function Level4 : TFPExprNode;
     Function Level5 : TFPExprNode;
     Function Level6 : TFPExprNode;
+    Function Level7 : TFPExprNode;
     Function Primitive : TFPExprNode;
     function GetToken: TTokenType;
     Function TokenType : TTokenType;
@@ -759,9 +770,9 @@
 
   Digits        = ['0'..'9','.'];
   WhiteSpace    = [' ',#13,#10,#9];
-  Operators     = ['+','-','<','>','=','/','*'];
+  Operators     = ['+','-','<','>','=','/','*','^'];
   Delimiters    = Operators+[',','(',')'];
-  Symbols       = ['%','^']+Delimiters;
+  Symbols       = ['%']+Delimiters;
   WordDelimiters = WhiteSpace + Symbols;
 
 Resourcestring
@@ -1107,6 +1118,7 @@
       '(' : Result := ttLeft;
       ')' : Result := ttRight;
       ',' : Result := ttComma;
+      '^' : Result := ttPower;
     else
       ScanError(Format(SUnknownDelimiter,[D]));
     end;
@@ -1376,8 +1388,6 @@
 end;
 
 function TFPExpressionParser.ConvertNode(Todo : TFPExprNode; ToType : TResultType): TFPExprNode;
-
-
 begin
   Result:=ToDo;
   Case ToDo.NodeType of
@@ -1646,8 +1656,28 @@
 end;
 
 function TFPExpressionParser.Level6: TFPExprNode;
+var
+  right: TFPExprNode;
 begin
-{$ifdef debugexpr}  Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
+{$ifdef debugexpr} Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
+  Result := Level7;
+  try
+    while (TokenType = ttPower) do
+    begin
+      GetToken;
+      right := Level5;           // Accept '(', unary '+', '-' as next tokens
+      CheckNodes(Result, right);
+      Result := TFPPowerOperation.Create(Result, right);
+    end;
+  except
+    Result.Free;
+    Raise;
+  end;
+end;
+
+function TFPExpressionParser.Level7: TFPExprNode;
+begin
+{$ifdef debugexpr}  Writeln('Level 7 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
   if (TokenType=ttLeft) then
     begin
     GetToken;
@@ -3192,6 +3222,49 @@
   Result.ResultType:=rtFloat;
 end;
 
+{ TFPPowerOperation }
+
+procedure TFPPowerOperation.Check;
+const
+  AllowedTypes = [rtInteger, rtFloat];
+begin
+  CheckNodeType(Left, AllowedTypes);
+  CheckNodeType(Right, AllowedTypes);
+end;
+
+function TFPPowerOperation.AsString: String;
+begin
+  Result := Left.AsString + '^' + Right.AsString;
+end;
+
+function TFPPowerOperation.NodeType: TResultType;
+begin
+  Result := rtFloat;
+end;
+
+function power(base,exponent: TExprFloat): TExprFloat;
+// Adapted from unit "math"
+begin
+  if Exponent = 0.0 then
+    result := 1.0
+  else if (base = 0.0) and (exponent > 0.0) then
+    result := 0.0
+  else if (base < 0.0) and (frac(exponent) = 0.0) then
+    result := -exp( exponent * ln(-base) )
+  else
+    result := exp( exponent * ln(base) );
+end;
+
+procedure TFPPowerOperation.GetNodeValue(var Result: TFPExpressionResult);
+var
+  RRes: TFPExpressionResult;
+begin
+  Left.GetNodeValue(Result);    // BASE
+  Right.GetNodeValue(RRes);     // EXPONENT
+  Result.ResFloat := power(ArgToFloat(Result), ArgToFloat(RRes)); //exp(ArgToFloat(RRes) * ln(ArgToFloat(LRes)));  // exp( EXPONENT * ln(BASE) )
+  Result.ResultType := rtFloat;
+end;
+
 { TFPConvertNode }
 
 function TFPConvertNode.AsString: String;
fpexprpars.pp.patch (4,586 bytes)

wp

2016-11-20 22:54

reporter  

fpexprpars_PowerOp_test.zip (1,591 bytes)

Anton

2016-11-21 21:45

reporter   ~0096109

if (base < 0.0) and (frac(exponent) = 0.0) then
    result := -exp( exponent * ln(-base) ) ?? (-2.0)^(2.0) < 0?!

wp

2016-11-21 22:54

reporter   ~0096110

Last edited: 2016-11-22 16:37

View 2 revisions

Grrh... I knew I had forgotten some tests...

Please use new patch and new demo with extended tests (v2).

wp

2016-11-21 22:55

reporter  

fpexprpars-v2.patch (4,584 bytes)
Index: fcl-base/src/fpexprpars.pp
===================================================================
--- fcl-base/src/fpexprpars.pp	(revision 34914)
+++ fcl-base/src/fpexprpars.pp	(working copy)
@@ -28,7 +28,7 @@
                 ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
                 ttunequal, ttNumber, ttString, ttIdentifier,
                 ttComma, ttand, ttOr,ttXor,ttTrue,ttFalse,ttnot,ttif,
-                ttCase,ttEOF);
+                ttCase,ttEOF, ttPower);
 
   TExprFloat = Double;
 
@@ -35,7 +35,7 @@
 Const
   ttDelimiters = [ttPlus, ttMinus, ttLessThan, ttLargerThan, ttEqual, ttDiv,
                   ttMul, ttLeft, ttRight, ttLessThanEqual, ttLargerThanEqual,
-                  ttunequal];
+                  ttunequal, ttPower];
   ttComparisons = [ttLargerThan,ttLessthan,
                    ttLargerThanEqual,ttLessthanEqual,
                    ttEqual,ttUnequal];
@@ -329,6 +329,16 @@
     Procedure GetNodeValue(var Result : TFPExpressionResult); override;
   end;
 
+  { TFPPowerOperation }
+  TFPPowerOperation = class(TMathOperation)
+  public
+    Procedure Check; override;
+    Function AsString : string ; override;
+    Function NodeType : TResultType; override;
+    Procedure GetNodeValue(var Result : TFPExpressionResult); override;
+  end;
+
+
   { TFPUnaryOperator }
 
   TFPUnaryOperator = Class(TFPExprNode)
@@ -673,6 +683,7 @@
     Function Level4 : TFPExprNode;
     Function Level5 : TFPExprNode;
     Function Level6 : TFPExprNode;
+    Function Level7 : TFPExprNode;
     Function Primitive : TFPExprNode;
     function GetToken: TTokenType;
     Function TokenType : TTokenType;
@@ -759,9 +770,9 @@
 
   Digits        = ['0'..'9','.'];
   WhiteSpace    = [' ',#13,#10,#9];
-  Operators     = ['+','-','<','>','=','/','*'];
+  Operators     = ['+','-','<','>','=','/','*','^'];
   Delimiters    = Operators+[',','(',')'];
-  Symbols       = ['%','^']+Delimiters;
+  Symbols       = ['%']+Delimiters;
   WordDelimiters = WhiteSpace + Symbols;
 
 Resourcestring
@@ -1107,6 +1118,7 @@
       '(' : Result := ttLeft;
       ')' : Result := ttRight;
       ',' : Result := ttComma;
+      '^' : Result := ttPower;
     else
       ScanError(Format(SUnknownDelimiter,[D]));
     end;
@@ -1376,8 +1388,6 @@
 end;
 
 function TFPExpressionParser.ConvertNode(Todo : TFPExprNode; ToType : TResultType): TFPExprNode;
-
-
 begin
   Result:=ToDo;
   Case ToDo.NodeType of
@@ -1646,8 +1656,28 @@
 end;
 
 function TFPExpressionParser.Level6: TFPExprNode;
+var
+  right: TFPExprNode;
 begin
-{$ifdef debugexpr}  Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
+{$ifdef debugexpr} Writeln('Level 6 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
+  Result := Level7;
+  try
+    while (TokenType = ttPower) do
+    begin
+      GetToken;
+      right := Level5;           // Accept '(', unary '+', '-' as next tokens
+      CheckNodes(Result, right);
+      Result := TFPPowerOperation.Create(Result, right);
+    end;
+  except
+    Result.Free;
+    Raise;
+  end;
+end;
+
+function TFPExpressionParser.Level7: TFPExprNode;
+begin
+{$ifdef debugexpr}  Writeln('Level 7 ',TokenName(TokenType),': ',CurrentToken);{$endif debugexpr}
   if (TokenType=ttLeft) then
     begin
     GetToken;
@@ -3192,6 +3222,55 @@
   Result.ResultType:=rtFloat;
 end;
 
+{ TFPPowerOperation }
+
+procedure TFPPowerOperation.Check;
+const
+  AllowedTypes = [rtInteger, rtFloat];
+begin
+  CheckNodeType(Left, AllowedTypes);
+  CheckNodeType(Right, AllowedTypes);
+end;
+
+function TFPPowerOperation.AsString: String;
+begin
+  Result := Left.AsString + '^' + Right.AsString;
+end;
+
+function TFPPowerOperation.NodeType: TResultType;
+begin
+  Result := rtFloat;
+end;
+
+function power(base,exponent: TExprFloat): TExprFloat;
+// Adapted from unit "math"
+var
+  ex: Integer;
+begin
+  if Exponent = 0.0 then
+    result := 1.0
+  else if (base = 0.0) and (exponent > 0.0) then
+    result := 0.0
+  else if (base < 0.0) and (frac(exponent) = 0.0) then
+  begin
+    ex := round(exponent);
+    result := exp( exponent * ln(-base));
+    if odd(ex) then result := -result;
+  end
+  else
+    result := exp( exponent * ln(base) );
+end;
+
+procedure TFPPowerOperation.GetNodeValue(var Result: TFPExpressionResult);
+var
+  RRes: TFPExpressionResult;
+begin
+  Left.GetNodeValue(Result);
+  Right.GetNodeValue(RRes);
+  Result.ResFloat := power(ArgToFloat(Result), ArgToFloat(RRes));
+  Result.ResultType := rtFloat;
+end;
+
 { TFPConvertNode }
 
 function TFPConvertNode.AsString: String;
fpexprpars-v2.patch (4,584 bytes)

wp

2016-11-22 00:23

reporter  

fpexprpars_PowerOp_test_v2.zip (1,797 bytes)

Michael Van Canneyt

2016-11-26 17:18

administrator   ~0096258

Patch applied, with minor modification.
I have incorporated your tests in the unit testsuite.
Thank you for the patch.

wp

2016-11-28 13:44

reporter   ~0096345

Sorry, you left a debugging WriteLn in the code which causes RunError 103 for an LCL program under Windows (line 1186)

Michael Van Canneyt

2016-11-28 13:51

administrator   ~0096346

Removed in rev. 35006.

Issue History

Date Modified Username Field Change
2016-11-20 22:53 wp New Issue
2016-11-20 22:53 wp File Added: fpexprpars.pp.patch
2016-11-20 22:54 wp File Added: fpexprpars_PowerOp_test.zip
2016-11-21 01:00 Michael Van Canneyt Assigned To => Michael Van Canneyt
2016-11-21 01:00 Michael Van Canneyt Status new => assigned
2016-11-21 21:45 Anton Note Added: 0096109
2016-11-21 22:54 wp Note Added: 0096110
2016-11-21 22:55 wp File Added: fpexprpars-v2.patch
2016-11-22 00:23 wp File Added: fpexprpars_PowerOp_test_v2.zip
2016-11-22 16:37 wp Note Edited: 0096110 View Revisions
2016-11-26 17:18 Michael Van Canneyt Fixed in Revision => 34967
2016-11-26 17:18 Michael Van Canneyt Note Added: 0096258
2016-11-26 17:18 Michael Van Canneyt Status assigned => resolved
2016-11-26 17:18 Michael Van Canneyt Fixed in Version => 3.1.1
2016-11-26 17:18 Michael Van Canneyt Resolution open => fixed
2016-11-26 17:18 Michael Van Canneyt Target Version => 3.2.0
2016-11-28 13:44 wp Note Added: 0096345
2016-11-28 13:44 wp Status resolved => feedback
2016-11-28 13:44 wp Resolution fixed => reopened
2016-11-28 13:51 Michael Van Canneyt Note Added: 0096346
2016-11-28 13:51 Michael Van Canneyt Status feedback => resolved
2016-11-28 13:51 Michael Van Canneyt Resolution reopened => fixed
2016-11-29 13:37 wp Status resolved => closed