mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-19 19:31:41 +02:00
fcl-passrc: IsValidIdent for fpc 3.0
git-svn-id: trunk@36121 -
This commit is contained in:
parent
eb378c1b94
commit
1d1c310876
@ -1531,6 +1531,9 @@ function ProcNeedsImplProc(Proc: TPasProcedure): boolean;
|
|||||||
function ChompDottedIdentifier(const Identifier: string): string;
|
function ChompDottedIdentifier(const Identifier: string): string;
|
||||||
function FirstDottedIdentifier(const Identifier: string): string;
|
function FirstDottedIdentifier(const Identifier: string): string;
|
||||||
function IsDottedIdentifierPrefix(const Prefix, Identifier: string): boolean;
|
function IsDottedIdentifierPrefix(const Prefix, Identifier: string): boolean;
|
||||||
|
{$IF FPC_FULLVERSION<30101}
|
||||||
|
function IsValidIdent(const Ident: string; AllowDots: Boolean = False; StrictDots: Boolean = False): Boolean;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
function dbgs(const Flags: TPasResolverComputeFlags): string; overload;
|
function dbgs(const Flags: TPasResolverComputeFlags): string; overload;
|
||||||
function dbgs(const a: TResolvedRefAccess): string;
|
function dbgs(const a: TResolvedRefAccess): string;
|
||||||
@ -1839,6 +1842,44 @@ begin
|
|||||||
Result:=(length(Identifier)=l) or (Identifier[l+1]='.');
|
Result:=(length(Identifier)=l) or (Identifier[l+1]='.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IF FPC_FULLVERSION<30101}
|
||||||
|
function IsValidIdent(const Ident: string; AllowDots: Boolean;
|
||||||
|
StrictDots: Boolean): Boolean;
|
||||||
|
const
|
||||||
|
Alpha = ['A'..'Z', 'a'..'z', '_'];
|
||||||
|
AlphaNum = Alpha + ['0'..'9'];
|
||||||
|
Dot = '.';
|
||||||
|
var
|
||||||
|
First: Boolean;
|
||||||
|
I, Len: Integer;
|
||||||
|
begin
|
||||||
|
Len := Length(Ident);
|
||||||
|
if Len < 1 then
|
||||||
|
Exit(False);
|
||||||
|
First := True;
|
||||||
|
for I := 1 to Len do
|
||||||
|
begin
|
||||||
|
if First then
|
||||||
|
begin
|
||||||
|
Result := Ident[I] in Alpha;
|
||||||
|
First := False;
|
||||||
|
end
|
||||||
|
else if AllowDots and (Ident[I] = Dot) then
|
||||||
|
begin
|
||||||
|
if StrictDots then
|
||||||
|
begin
|
||||||
|
Result := I < Len;
|
||||||
|
First := True;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := Ident[I] in AlphaNum;
|
||||||
|
if not Result then
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
function dbgs(const Flags: TPasResolverComputeFlags): string;
|
function dbgs(const Flags: TPasResolverComputeFlags): string;
|
||||||
var
|
var
|
||||||
s: string;
|
s: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user