mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 10:00:34 +02:00
FpDebug: PascalParser, optimize check for finding left-side of operator / clarify description
This commit is contained in:
parent
6e648e3c2e
commit
8bb9d6eece
@ -171,6 +171,7 @@ type
|
|||||||
function DebugText(AIndent: String; {%H-}AWithResults: Boolean): String; virtual; // Self desc only
|
function DebugText(AIndent: String; {%H-}AWithResults: Boolean): String; virtual; // Self desc only
|
||||||
function DebugDump(AIndent: String; AWithResults: Boolean): String; virtual;
|
function DebugDump(AIndent: String; AWithResults: Boolean): String; virtual;
|
||||||
protected
|
protected
|
||||||
|
FPrecedence: Integer;
|
||||||
procedure Init; virtual;
|
procedure Init; virtual;
|
||||||
function DoGetIsTypeCast: Boolean; virtual; deprecated;
|
function DoGetIsTypeCast: Boolean; virtual; deprecated;
|
||||||
function DoGetResultValue: TFpValue; virtual;
|
function DoGetResultValue: TFpValue; virtual;
|
||||||
@ -207,6 +208,7 @@ type
|
|||||||
property EndChar: PChar read FEndChar write SetEndChar;
|
property EndChar: PChar read FEndChar write SetEndChar;
|
||||||
property Parent: TFpPascalExpressionPartContainer read FParent write SetParent;
|
property Parent: TFpPascalExpressionPartContainer read FParent write SetParent;
|
||||||
property TopParent: TFpPascalExpressionPart read GetTopParent; // or self
|
property TopParent: TFpPascalExpressionPart read GetTopParent; // or self
|
||||||
|
property Precedence: Integer read FPrecedence;
|
||||||
property SurroundingBracket: TFpPascalExpressionPartBracket read GetSurroundingOpenBracket; // incl self
|
property SurroundingBracket: TFpPascalExpressionPartBracket read GetSurroundingOpenBracket; // incl self
|
||||||
property ResultValue: TFpValue read GetResultValue;
|
property ResultValue: TFpValue read GetResultValue;
|
||||||
property Expression: TFpPascalExpression read FExpression;
|
property Expression: TFpPascalExpression read FExpression;
|
||||||
@ -334,10 +336,7 @@ type
|
|||||||
|
|
||||||
TFpPascalExpressionPartWithPrecedence = class(TFpPascalExpressionPartContainer)
|
TFpPascalExpressionPartWithPrecedence = class(TFpPascalExpressionPartContainer)
|
||||||
protected
|
protected
|
||||||
FPrecedence: Integer;
|
|
||||||
function HasPrecedence: Boolean; override;
|
function HasPrecedence: Boolean; override;
|
||||||
public
|
|
||||||
property Precedence: Integer read FPrecedence;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFpPascalExpressionPartBracket }
|
{ TFpPascalExpressionPartBracket }
|
||||||
@ -4737,13 +4736,21 @@ begin
|
|||||||
|
|
||||||
Result := APrevPart.CanHaveOperatorAsNext;
|
Result := APrevPart.CanHaveOperatorAsNext;
|
||||||
|
|
||||||
// BinaryOperator...
|
(*
|
||||||
// foo
|
BinaryOperator...
|
||||||
// Identifier
|
# (e.g. Self = "+")
|
||||||
// "Identifier" can hane a binary-op next. But it must be applied to the parent.
|
# APrevPart = Identifier
|
||||||
// So it is not valid here.
|
# APrevPart.Parent = "*" or "-"
|
||||||
// If new operator has a higher precedence, it go down to the child again and replace it
|
foo * Identifier +
|
||||||
if (APrevPart.Parent <> nil) and (APrevPart.Parent.HasPrecedence) then
|
foo - Identifier +
|
||||||
|
The binary-op "+" after "Identifier" must be applied to the parent.
|
||||||
|
So, if SELF is the "+", then it is not valid after "Identifier".
|
||||||
|
If new operator has a higher precedence, it go down to the child again and replace it
|
||||||
|
*)
|
||||||
|
// precedence: 1 = highest
|
||||||
|
if (APrevPart.Parent <> nil) and (APrevPart.Parent.HasPrecedence) and
|
||||||
|
(Precedence >= APrevPart.Parent.Precedence)
|
||||||
|
then
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user