mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
FpDebug: fix PascalParser, handle coma in sub-expression
This commit is contained in:
parent
83412e9a50
commit
71b46c3d5f
@ -343,6 +343,7 @@ type
|
|||||||
protected
|
protected
|
||||||
function HandleNextPartInBracket(APart: TFpPascalExpressionPart): TFpPascalExpressionPart; override;
|
function HandleNextPartInBracket(APart: TFpPascalExpressionPart): TFpPascalExpressionPart; override;
|
||||||
function DoGetResultValue: TFpValue; override;
|
function DoGetResultValue: TFpValue; override;
|
||||||
|
function HandleSeparator(ASeparatorType: TSeparatorType; var APart: TFpPascalExpressionPart): Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFpPascalExpressionPartBracketArgumentList }
|
{ TFpPascalExpressionPartBracketArgumentList }
|
||||||
@ -2061,6 +2062,15 @@ begin
|
|||||||
Result.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(nil, 'DoGetResultValue'){$ENDIF};
|
Result.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(nil, 'DoGetResultValue'){$ENDIF};
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFpPascalExpressionPartBracketSubExpression.HandleSeparator(
|
||||||
|
ASeparatorType: TSeparatorType; var APart: TFpPascalExpressionPart): Boolean;
|
||||||
|
begin
|
||||||
|
if IsClosed then
|
||||||
|
inherited HandleSeparator(ASeparatorType, APart)
|
||||||
|
else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFpPascalExpressionPartIdentifier }
|
{ TFpPascalExpressionPartIdentifier }
|
||||||
|
|
||||||
function TFpPascalExpressionPartIdentifier.DoGetIsTypeCast: Boolean;
|
function TFpPascalExpressionPartIdentifier.DoGetIsTypeCast: Boolean;
|
||||||
|
@ -6,7 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, fpcunit, testutils, testregistry, FpPascalParser,
|
Classes, SysUtils, fpcunit, testutils, testregistry, FpPascalParser,
|
||||||
FpErrorMessages, FpDbgInfo,
|
FpErrorMessages, FpDbgInfo, FpdMemoryTools,
|
||||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif};
|
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif};
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -38,10 +38,10 @@ procedure TTestPascalParser.CreateExpr(t: string; ExpValid: Boolean;
|
|||||||
SkipExpValid: Boolean);
|
SkipExpValid: Boolean);
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
ctx: TFpDbgSimpleLocationContext;
|
ctx: TFpDbgLocationContext; // TFpDbgSimpleLocationContext
|
||||||
sc: TFpDbgSymbolScope;
|
sc: TFpDbgSymbolScope;
|
||||||
begin
|
begin
|
||||||
ctx := TFpDbgSimpleLocationContext.Create(nil, 0, 4, 0, 0);
|
ctx := TFpDbgLocationContext.Create();
|
||||||
sc := TFpDbgSymbolScope.Create(ctx);
|
sc := TFpDbgSymbolScope.Create(ctx);
|
||||||
FreeAndNil(CurrentTestExprObj);
|
FreeAndNil(CurrentTestExprObj);
|
||||||
CurrentTestExprText := t;
|
CurrentTestExprText := t;
|
||||||
@ -51,7 +51,6 @@ DebugLn(CurrentTestExprObj.DebugDump);
|
|||||||
s := ErrorHandler.ErrorAsString(CurrentTestExprObj.Error);
|
s := ErrorHandler.ErrorAsString(CurrentTestExprObj.Error);
|
||||||
AssertEquals('Valid '+s+ ' # '+CurrentTestExprText, ExpValid, CurrentTestExprObj.Valid);
|
AssertEquals('Valid '+s+ ' # '+CurrentTestExprText, ExpValid, CurrentTestExprObj.Valid);
|
||||||
end;
|
end;
|
||||||
ctx.ReleaseReference;
|
|
||||||
sc.ReleaseReference;
|
sc.ReleaseReference;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -274,6 +273,12 @@ begin
|
|||||||
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
||||||
TestExpr([1], TFpPascalExpressionPartIdentifier, 'a', 0);
|
TestExpr([1], TFpPascalExpressionPartIdentifier, 'a', 0);
|
||||||
|
|
||||||
|
CreateExpr('f((a))', True);
|
||||||
|
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 2);
|
||||||
|
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
||||||
|
TestExpr([1], TFpPascalExpressionPartBracketSubExpression, '(', 1);
|
||||||
|
TestExpr([1,0], TFpPascalExpressionPartIdentifier, 'a', 0);
|
||||||
|
|
||||||
CreateExpr('f(a)(b)', True);
|
CreateExpr('f(a)(b)', True);
|
||||||
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 2);
|
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 2);
|
||||||
TestExpr([0], TFpPascalExpressionPartBracketArgumentList, '(', 2);
|
TestExpr([0], TFpPascalExpressionPartBracketArgumentList, '(', 2);
|
||||||
@ -291,6 +296,20 @@ begin
|
|||||||
TestExpr([1], TFpPascalExpressionPartIdentifier, 'a', 0);
|
TestExpr([1], TFpPascalExpressionPartIdentifier, 'a', 0);
|
||||||
TestExpr([2], TFpPascalExpressionPartIdentifier, 'b', 0);
|
TestExpr([2], TFpPascalExpressionPartIdentifier, 'b', 0);
|
||||||
|
|
||||||
|
CreateExpr('f((a),b)', True);
|
||||||
|
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 3);
|
||||||
|
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
||||||
|
TestExpr([1], TFpPascalExpressionPartBracketSubExpression, '(', 1);
|
||||||
|
TestExpr([1,0], TFpPascalExpressionPartIdentifier, 'a', 0);
|
||||||
|
TestExpr([2], TFpPascalExpressionPartIdentifier, 'b', 0);
|
||||||
|
|
||||||
|
CreateExpr('f(a,(b))', True);
|
||||||
|
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 3);
|
||||||
|
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
||||||
|
TestExpr([1], TFpPascalExpressionPartIdentifier, 'a', 0);
|
||||||
|
TestExpr([2], TFpPascalExpressionPartBracketSubExpression, '(', 1);
|
||||||
|
TestExpr([2,0], TFpPascalExpressionPartIdentifier, 'b', 0);
|
||||||
|
|
||||||
CreateExpr('f(-a, -b)', True);
|
CreateExpr('f(-a, -b)', True);
|
||||||
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 3);
|
TestExpr([], TFpPascalExpressionPartBracketArgumentList, '(', 3);
|
||||||
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
TestExpr([0], TFpPascalExpressionPartIdentifier, 'f', 0);
|
||||||
@ -630,10 +649,13 @@ begin
|
|||||||
TestExpr('#%3', fpErrPasParserExpectedNumber_p);
|
TestExpr('#%3', fpErrPasParserExpectedNumber_p);
|
||||||
|
|
||||||
TestExpr('''abc''[]', fpErrPasParserMissingIndexExpression);
|
TestExpr('''abc''[]', fpErrPasParserMissingIndexExpression);
|
||||||
TestExpr('''abc''[#1]', [fpErrPasParserIndexError_Wrapper, fpErrExpectedOrdinalVal_p]);
|
//TestExpr('''abc''[#1]', [fpErrPasParserIndexError_Wrapper, fpErrExpectedOrdinalVal_p]);
|
||||||
TestExpr('''abc''[99]', [fpErrPasParserIndexError_Wrapper, fpErrIndexOutOfRange]);
|
TestExpr('''abc''[99]', [fpErrPasParserIndexError_Wrapper, fpErrIndexOutOfRange]);
|
||||||
TestExpr('1[99]', [fpErrPasParserIndexError_Wrapper, fpErrTypeNotIndexable]);
|
TestExpr('1[99]', [fpErrPasParserIndexError_Wrapper, fpErrTypeNotIndexable]);
|
||||||
|
|
||||||
|
CreateExpr('a((a,b)', False, False);
|
||||||
|
CreateExpr('a((a,b,c)', False, False);
|
||||||
|
|
||||||
//TestExpr('@''ab''', fpErrCannotCastToPointer_p);
|
//TestExpr('@''ab''', fpErrCannotCastToPointer_p);
|
||||||
///TestExpr('^T(''ab'')', fpErrCannotCastToPointer_p);
|
///TestExpr('^T(''ab'')', fpErrCannotCastToPointer_p);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user