|
@@ -302,7 +302,7 @@ type
|
|
function CreateBinaryExpr(AParent : TPasElement; xleft, xright: TPasExpr; AOpCode: TExprOpCode): TBinaryExpr; overload;
|
|
function CreateBinaryExpr(AParent : TPasElement; xleft, xright: TPasExpr; AOpCode: TExprOpCode): TBinaryExpr; overload;
|
|
function CreateBinaryExpr(AParent : TPasElement; xleft, xright: TPasExpr; AOpCode: TExprOpCode; const ASrcPos: TPasSourcePos): TBinaryExpr; overload;
|
|
function CreateBinaryExpr(AParent : TPasElement; xleft, xright: TPasExpr; AOpCode: TExprOpCode; const ASrcPos: TPasSourcePos): TBinaryExpr; overload;
|
|
procedure AddToBinaryExprChain(var ChainFirst: TPasExpr;
|
|
procedure AddToBinaryExprChain(var ChainFirst: TPasExpr;
|
|
- Element: TPasExpr; AOpCode: TExprOpCode);
|
|
|
|
|
|
+ Element: TPasExpr; AOpCode: TExprOpCode; const ASrcPos: TPasSourcePos);
|
|
procedure AddParamsToBinaryExprChain(var ChainFirst: TPasExpr;
|
|
procedure AddParamsToBinaryExprChain(var ChainFirst: TPasExpr;
|
|
Params: TParamsExpr);
|
|
Params: TParamsExpr);
|
|
{$IFDEF VerbosePasParser}
|
|
{$IFDEF VerbosePasParser}
|
|
@@ -1270,6 +1270,7 @@ Var
|
|
Name : String;
|
|
Name : String;
|
|
ST : TPasSpecializeType;
|
|
ST : TPasSpecializeType;
|
|
Expr: TPasExpr;
|
|
Expr: TPasExpr;
|
|
|
|
+ SrcPos: TPasSourcePos;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
@@ -1283,10 +1284,12 @@ begin
|
|
NextToken;
|
|
NextToken;
|
|
while CurToken=tkDot do
|
|
while CurToken=tkDot do
|
|
begin
|
|
begin
|
|
|
|
+ SrcPos:=CurTokenPos;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
Name := Name+'.'+CurTokenString;
|
|
Name := Name+'.'+CurTokenString;
|
|
if IsFull then
|
|
if IsFull then
|
|
- AddToBinaryExprChain(Expr,CreatePrimitiveExpr(Parent,pekIdent,CurTokenString),eopSubIdent);
|
|
|
|
|
|
+ AddToBinaryExprChain(Expr,CreatePrimitiveExpr(Parent,pekIdent,CurTokenString),
|
|
|
|
+ eopSubIdent,SrcPos);
|
|
NextToken;
|
|
NextToken;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1294,7 +1297,7 @@ begin
|
|
if IsFull and (CurToken=tkSemicolon) or isCurTokenHint then // Type A = B;
|
|
if IsFull and (CurToken=tkSemicolon) or isCurTokenHint then // Type A = B;
|
|
begin
|
|
begin
|
|
K:=stkAlias;
|
|
K:=stkAlias;
|
|
- UnGetToken; // ToDo: dotted identifier
|
|
|
|
|
|
+ UnGetToken;
|
|
end
|
|
end
|
|
else if IsFull and (CurToken=tkSquaredBraceOpen) then
|
|
else if IsFull and (CurToken=tkSquaredBraceOpen) then
|
|
begin
|
|
begin
|
|
@@ -1302,7 +1305,7 @@ begin
|
|
K:=stkString
|
|
K:=stkString
|
|
else
|
|
else
|
|
ParseExcSyntaxError;
|
|
ParseExcSyntaxError;
|
|
- UnGetToken; // ToDo: dotted identifier
|
|
|
|
|
|
+ UnGetToken;
|
|
end
|
|
end
|
|
else if (CurToken = tkLessThan) then // A = B<t>;
|
|
else if (CurToken = tkLessThan) then // A = B<t>;
|
|
begin
|
|
begin
|
|
@@ -1311,7 +1314,7 @@ begin
|
|
else if (CurToken in [tkBraceOpen,tkDotDot]) then // A: B..C;
|
|
else if (CurToken in [tkBraceOpen,tkDotDot]) then // A: B..C;
|
|
begin
|
|
begin
|
|
K:=stkRange;
|
|
K:=stkRange;
|
|
- UnGetToken; // ToDo: dotted identifier
|
|
|
|
|
|
+ UnGetToken;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
@@ -1320,7 +1323,7 @@ begin
|
|
K:=stkAlias;
|
|
K:=stkAlias;
|
|
if (not (po_resolvestandardtypes in Options)) and (LowerCase(Name)='string') then
|
|
if (not (po_resolvestandardtypes in Options)) and (LowerCase(Name)='string') then
|
|
K:=stkString;
|
|
K:=stkString;
|
|
- UnGetToken; // ToDo: dotted identifier
|
|
|
|
|
|
+ UnGetToken;
|
|
end;
|
|
end;
|
|
|
|
|
|
Case K of
|
|
Case K of
|
|
@@ -1331,7 +1334,7 @@ begin
|
|
end;
|
|
end;
|
|
stkSpecialize:
|
|
stkSpecialize:
|
|
begin
|
|
begin
|
|
- ST := TPasSpecializeType(CreateElement(TPasSpecializeType, TypeName, Parent, CurSourcePos));
|
|
|
|
|
|
+ ST := TPasSpecializeType(CreateElement(TPasSpecializeType, TypeName, Parent, CurTokenPos));
|
|
Ref:=ResolveTypeReference(Name,ST);
|
|
Ref:=ResolveTypeReference(Name,ST);
|
|
ReadSpecializeArguments(ST);
|
|
ReadSpecializeArguments(ST);
|
|
ST.Expr:=Expr;
|
|
ST.Expr:=Expr;
|
|
@@ -2029,7 +2032,7 @@ var
|
|
aName: String;
|
|
aName: String;
|
|
ISE: TInlineSpecializeExpr;
|
|
ISE: TInlineSpecializeExpr;
|
|
ST: TPasSpecializeType;
|
|
ST: TPasSpecializeType;
|
|
- SrcPos: TPasSourcePos;
|
|
|
|
|
|
+ SrcPos, ScrPos: TPasSourcePos;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
@@ -2109,12 +2112,13 @@ begin
|
|
case CurToken of
|
|
case CurToken of
|
|
tkDot:
|
|
tkDot:
|
|
begin
|
|
begin
|
|
|
|
+ ScrPos:=CurTokenPos;
|
|
NextToken;
|
|
NextToken;
|
|
if CurToken in [tkIdentifier,tktrue,tkfalse,tkself] then // true and false are sub identifiers as well
|
|
if CurToken in [tkIdentifier,tktrue,tkfalse,tkself] then // true and false are sub identifiers as well
|
|
begin
|
|
begin
|
|
aName:=aName+'.'+CurTokenString;
|
|
aName:=aName+'.'+CurTokenString;
|
|
expr:=CreatePrimitiveExpr(AParent,pekIdent,CurTokenString);
|
|
expr:=CreatePrimitiveExpr(AParent,pekIdent,CurTokenString);
|
|
- AddToBinaryExprChain(Result,expr,eopSubIdent);
|
|
|
|
|
|
+ AddToBinaryExprChain(Result,expr,eopSubIdent,ScrPos);
|
|
func:=expr;
|
|
func:=expr;
|
|
NextToken;
|
|
NextToken;
|
|
end
|
|
end
|
|
@@ -3314,7 +3318,7 @@ var
|
|
NameExpr: TPasExpr;
|
|
NameExpr: TPasExpr;
|
|
InFileExpr: TPrimitiveExpr;
|
|
InFileExpr: TPrimitiveExpr;
|
|
FreeExpr: Boolean;
|
|
FreeExpr: Boolean;
|
|
- NamePos: TPasSourcePos;
|
|
|
|
|
|
+ NamePos, SrcPos: TPasSourcePos;
|
|
begin
|
|
begin
|
|
CheckImplicitUsedUnits(ASection);
|
|
CheckImplicitUsedUnits(ASection);
|
|
|
|
|
|
@@ -3330,10 +3334,12 @@ begin
|
|
NextToken;
|
|
NextToken;
|
|
while CurToken = tkDot do
|
|
while CurToken = tkDot do
|
|
begin
|
|
begin
|
|
|
|
+ SrcPos:=CurTokenPos;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
aName:=CurTokenString;
|
|
aName:=CurTokenString;
|
|
AUnitName := AUnitName + '.' + aName;
|
|
AUnitName := AUnitName + '.' + aName;
|
|
- AddToBinaryExprChain(NameExpr,CreatePrimitiveExpr(ASection,pekString,aName),eopSubIdent);
|
|
|
|
|
|
+ AddToBinaryExprChain(NameExpr,
|
|
|
|
+ CreatePrimitiveExpr(ASection,pekString,aName),eopSubIdent,SrcPos);
|
|
NextToken;
|
|
NextToken;
|
|
end;
|
|
end;
|
|
if (CurToken=tkin) then
|
|
if (CurToken=tkin) then
|
|
@@ -3522,6 +3528,8 @@ end;
|
|
|
|
|
|
function TPasParser.ReadDottedIdentifier(Parent: TPasElement; out
|
|
function TPasParser.ReadDottedIdentifier(Parent: TPasElement; out
|
|
Expr: TPasExpr; NeedAsString: boolean): String;
|
|
Expr: TPasExpr; NeedAsString: boolean): String;
|
|
|
|
+var
|
|
|
|
+ SrcPos: TPasSourcePos;
|
|
begin
|
|
begin
|
|
Expr:=nil;
|
|
Expr:=nil;
|
|
if NeedAsString then
|
|
if NeedAsString then
|
|
@@ -3533,10 +3541,12 @@ begin
|
|
NextToken;
|
|
NextToken;
|
|
while CurToken=tkDot do
|
|
while CurToken=tkDot do
|
|
begin
|
|
begin
|
|
|
|
+ SrcPos:=CurTokenPos;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
if NeedAsString then
|
|
if NeedAsString then
|
|
Result := Result+'.'+CurTokenString;
|
|
Result := Result+'.'+CurTokenString;
|
|
- AddToBinaryExprChain(Expr,CreatePrimitiveExpr(Parent,pekIdent,CurTokenString),eopSubIdent);
|
|
|
|
|
|
+ AddToBinaryExprChain(Expr,CreatePrimitiveExpr(Parent,pekIdent,CurTokenString),
|
|
|
|
+ eopSubIdent,SrcPos);
|
|
NextToken;
|
|
NextToken;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -4501,6 +4511,7 @@ function TPasParser.ParseProperty(Parent: TPasElement; const AName: String;
|
|
var
|
|
var
|
|
Params: TParamsExpr;
|
|
Params: TParamsExpr;
|
|
Param: TPasExpr;
|
|
Param: TPasExpr;
|
|
|
|
+ SrcPos: TPasSourcePos;
|
|
begin
|
|
begin
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
Result := CurTokenString;
|
|
Result := CurTokenString;
|
|
@@ -4510,9 +4521,11 @@ function TPasParser.ParseProperty(Parent: TPasElement; const AName: String;
|
|
repeat
|
|
repeat
|
|
NextToken;
|
|
NextToken;
|
|
if CurToken <> tkDot then break;
|
|
if CurToken <> tkDot then break;
|
|
|
|
+ SrcPos:=CurTokenPos;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
Result := Result + '.' + CurTokenString;
|
|
Result := Result + '.' + CurTokenString;
|
|
- AddToBinaryExprChain(Expr,CreatePrimitiveExpr(aParent,pekIdent,CurTokenString),eopSubIdent);
|
|
|
|
|
|
+ AddToBinaryExprChain(Expr,CreatePrimitiveExpr(aParent,pekIdent,CurTokenString),
|
|
|
|
+ eopSubIdent,SrcPos);
|
|
until false;
|
|
until false;
|
|
|
|
|
|
// read optional array index
|
|
// read optional array index
|
|
@@ -4545,9 +4558,11 @@ function TPasParser.ParseProperty(Parent: TPasElement; const AName: String;
|
|
UngetToken;
|
|
UngetToken;
|
|
break;
|
|
break;
|
|
end;
|
|
end;
|
|
|
|
+ SrcPos:=CurTokenPos;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
Result := Result + '.' + CurTokenString;
|
|
Result := Result + '.' + CurTokenString;
|
|
- AddToBinaryExprChain(Expr,CreatePrimitiveExpr(aParent,pekIdent,CurTokenString),eopSubIdent);
|
|
|
|
|
|
+ AddToBinaryExprChain(Expr,CreatePrimitiveExpr(aParent,pekIdent,CurTokenString),
|
|
|
|
+ eopSubIdent,SrcPos);
|
|
until false;
|
|
until false;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -4980,9 +4995,10 @@ begin
|
|
end;
|
|
end;
|
|
tkDot:
|
|
tkDot:
|
|
begin
|
|
begin
|
|
|
|
+ SrcPos:=CurTokenPos;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
AddToBinaryExprChain(Left,
|
|
AddToBinaryExprChain(Left,
|
|
- CreatePrimitiveExpr(El,pekIdent,CurTokenString), eopSubIdent);
|
|
|
|
|
|
+ CreatePrimitiveExpr(El,pekIdent,CurTokenString), eopSubIdent,SrcPos);
|
|
TPasImplForLoop(El).VariableName:=Left;
|
|
TPasImplForLoop(El).VariableName:=Left;
|
|
end;
|
|
end;
|
|
else
|
|
else
|
|
@@ -6105,7 +6121,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TPasParser.AddToBinaryExprChain(var ChainFirst: TPasExpr;
|
|
procedure TPasParser.AddToBinaryExprChain(var ChainFirst: TPasExpr;
|
|
- Element: TPasExpr; AOpCode: TExprOpCode);
|
|
|
|
|
|
+ Element: TPasExpr; AOpCode: TExprOpCode; const ASrcPos: TPasSourcePos);
|
|
begin
|
|
begin
|
|
if Element=nil then
|
|
if Element=nil then
|
|
exit
|
|
exit
|
|
@@ -6117,7 +6133,7 @@ begin
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
// create new binary, old becomes left, Element right
|
|
// create new binary, old becomes left, Element right
|
|
- ChainFirst:=CreateBinaryExpr(ChainFirst.Parent,ChainFirst,Element,AOpCode);
|
|
|
|
|
|
+ ChainFirst:=CreateBinaryExpr(ChainFirst.Parent,ChainFirst,Element,AOpCode,ASrcPos);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|