mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 21:09:27 +02:00
* Delphi allows TEnum.in
This commit is contained in:
parent
be5e84715c
commit
fc6fc67295
@ -2627,6 +2627,8 @@ var
|
|||||||
SrcPos, ScrPos: TPasSourcePos;
|
SrcPos, ScrPos: TPasSourcePos;
|
||||||
ProcType: TProcType;
|
ProcType: TProcType;
|
||||||
ProcExpr: TProcedureExpr;
|
ProcExpr: TProcedureExpr;
|
||||||
|
AllowKWAsSubIdent : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
CanSpecialize:=aCannot;
|
CanSpecialize:=aCannot;
|
||||||
@ -2723,7 +2725,7 @@ begin
|
|||||||
else
|
else
|
||||||
ParseExcExpectedIdentifier;
|
ParseExcExpectedIdentifier;
|
||||||
end;
|
end;
|
||||||
|
AllowKWAsSubIdent:=(msDelphi in CurrentModeswitches);
|
||||||
Result:=Last;
|
Result:=Last;
|
||||||
ISE:=nil;
|
ISE:=nil;
|
||||||
NextToken;
|
NextToken;
|
||||||
@ -2754,6 +2756,17 @@ begin
|
|||||||
Func:=Expr;
|
Func:=Expr;
|
||||||
NextToken;
|
NextToken;
|
||||||
end
|
end
|
||||||
|
else if AllowKWAsSubIdent and (Curtoken>=tkabsolute) and (Curtoken<=tkXor) then
|
||||||
|
begin
|
||||||
|
// Delphi allows keywords as identifier e.g. TEnum.In, but only for enums.
|
||||||
|
// Unfortunately, we do not know at this point if the previous identifier is an enum, so we allow it always.
|
||||||
|
// Not ideal :/
|
||||||
|
aName:=aName+'.'+CurTokenString;
|
||||||
|
Expr:=CreatePrimitiveExpr(AParent,pekIdent,CurTokenString);
|
||||||
|
AddToBinaryExprChain(Result,Expr,eopSubIdent,ScrPos);
|
||||||
|
Func:=Expr;
|
||||||
|
NextToken;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
UngetToken;
|
UngetToken;
|
||||||
@ -2947,6 +2960,7 @@ const
|
|||||||
Var
|
Var
|
||||||
AllowedBinaryOps : Set of TToken;
|
AllowedBinaryOps : Set of TToken;
|
||||||
SrcPos: TPasSourcePos;
|
SrcPos: TPasSourcePos;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
AllowedBinaryOps:=BinaryOP;
|
AllowedBinaryOps:=BinaryOP;
|
||||||
if Not AllowEqual then
|
if Not AllowEqual then
|
||||||
|
@ -5,7 +5,7 @@ unit tcexprparser;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, fpcunit, testregistry, tcbaseparser, pastree, PScanner;
|
Classes, SysUtils, fpcunit, testregistry, tcbaseparser, pastree, pparser, PScanner;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -110,6 +110,8 @@ type
|
|||||||
Procedure TestAPlusBBracketDotC;
|
Procedure TestAPlusBBracketDotC;
|
||||||
Procedure TestADotBDotC;
|
Procedure TestADotBDotC;
|
||||||
Procedure TestADotBBracketC;
|
Procedure TestADotBBracketC;
|
||||||
|
procedure TestADotKeyWord;
|
||||||
|
procedure TestADotKeyWordOnlyDelphi;
|
||||||
Procedure TestSelfDotBBracketC;
|
Procedure TestSelfDotBBracketC;
|
||||||
Procedure TestAasBDotCBracketFuncParams;
|
Procedure TestAasBDotCBracketFuncParams;
|
||||||
Procedure TestRange;
|
Procedure TestRange;
|
||||||
@ -1236,6 +1238,27 @@ begin
|
|||||||
AssertExpression('right b',PlusB.Right,pekIdent,'b');
|
AssertExpression('right b',PlusB.Right,pekIdent,'b');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestExpressions.TestADotKeyWord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Add('{$MODE DELPHI}');
|
||||||
|
Add('Type TEnum = (&in,&of);');
|
||||||
|
Add('Var a : TEnum;');
|
||||||
|
Add('begin');
|
||||||
|
Add(' a:=Tenum.in;');
|
||||||
|
ParseExpression;
|
||||||
|
AssertExpression('Binary identifier',TheExpr,pekBinary,TBinaryExpr);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestExpressions.TestADotKeyWordOnlyDelphi;
|
||||||
|
begin
|
||||||
|
Add('Type TEnum = (&in,&of);');
|
||||||
|
Add('Var a : TEnum;');
|
||||||
|
Add('begin');
|
||||||
|
Add(' a:=Tenum.in;');
|
||||||
|
AssertException(EParserError,@ParseExpression);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestExpressions.TestADotBDotC;
|
procedure TTestExpressions.TestADotBDotC;
|
||||||
var
|
var
|
||||||
B, SubB: TBinaryExpr;
|
B, SubB: TBinaryExpr;
|
||||||
|
Loading…
Reference in New Issue
Block a user