mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-16 23:49:23 +01:00
codetools: implemented parsing unsigned shhort
git-svn-id: trunk@14383 -
This commit is contained in:
parent
97a2a2f9e8
commit
b82d0ebf3f
@ -159,6 +159,8 @@ type
|
|||||||
function AtomIsIdentifier: boolean;
|
function AtomIsIdentifier: boolean;
|
||||||
function AtomIsStringConstant: boolean;
|
function AtomIsStringConstant: boolean;
|
||||||
function GetAtom: string;
|
function GetAtom: string;
|
||||||
|
function LastAtomIs(const s: shortstring): boolean;
|
||||||
|
function GetLastAtom: string;
|
||||||
|
|
||||||
procedure Replace(FromPos, ToPos: integer; const NewSrc: string);
|
procedure Replace(FromPos, ToPos: integer; const NewSrc: string);
|
||||||
|
|
||||||
@ -549,6 +551,7 @@ procedure TCCodeParserTool.ReadVariable;
|
|||||||
var
|
var
|
||||||
IsFunction: Boolean;
|
IsFunction: Boolean;
|
||||||
NeedEnd: Boolean;
|
NeedEnd: Boolean;
|
||||||
|
LastIsName: Boolean;
|
||||||
begin
|
begin
|
||||||
DebugLn(['TCCodeParserTool.ReadVariable ']);
|
DebugLn(['TCCodeParserTool.ReadVariable ']);
|
||||||
CreateChildNode(ccnVariable);
|
CreateChildNode(ccnVariable);
|
||||||
@ -573,27 +576,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
CreateChildNode(ccnVariableName);
|
CreateChildNode(ccnVariableName);
|
||||||
|
|
||||||
// possible:
|
// prefixes: signed, unsigned
|
||||||
|
// prefixes and/or names long, short
|
||||||
|
|
||||||
// int, short int, short signed int
|
// int, short int, short signed int
|
||||||
// char, signed char, unsigned char
|
// char, signed char, unsigned char
|
||||||
|
// singed short, unsigned short, short
|
||||||
// long, long long, signed long, signed long long, unsigned long, unsigned long long
|
// long, long long, signed long, signed long long, unsigned long, unsigned long long
|
||||||
|
LastIsName:=false;
|
||||||
repeat
|
repeat
|
||||||
if AtomIs('short') then
|
if AtomIs('signed') or AtomIs('unsigned') then begin
|
||||||
ReadNextAtom
|
LastIsName:=false;
|
||||||
else if AtomIs('signed') then
|
ReadNextAtom;
|
||||||
ReadNextAtom
|
end else if AtomIs('short') or AtomIs('long') then begin
|
||||||
else if AtomIs('unsigned') then
|
LastIsName:=true;
|
||||||
ReadNextAtom
|
|
||||||
else if AtomIs('long') then begin
|
|
||||||
// check if 'long long'
|
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if not (AtomIs('long') or AtomIs('unsigned')) then begin
|
|
||||||
UndoReadNextAtom;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end else
|
end else
|
||||||
break;
|
break;
|
||||||
until false;
|
until false;
|
||||||
|
if LastIsName then
|
||||||
|
UndoReadNextAtom;
|
||||||
|
|
||||||
// read name
|
// read name
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
@ -872,7 +874,7 @@ end;
|
|||||||
|
|
||||||
procedure TCCodeParserTool.ReadNextAtom;
|
procedure TCCodeParserTool.ReadNextAtom;
|
||||||
begin
|
begin
|
||||||
DebugLn(['TCCodeParserTool.ReadNextAtom START ',AtomStart,'-',SrcPos,' ',Src[SrcPos]]);
|
//DebugLn(['TCCodeParserTool.ReadNextAtom START ',AtomStart,'-',SrcPos,' ',Src[SrcPos]]);
|
||||||
LastSrcPos:=SrcPos;
|
LastSrcPos:=SrcPos;
|
||||||
LastAtomStart:=AtomStart;
|
LastAtomStart:=AtomStart;
|
||||||
repeat
|
repeat
|
||||||
@ -991,6 +993,25 @@ begin
|
|||||||
Result:=(AtomStart<SrcLen) and (Src[AtomStart]='"');
|
Result:=(AtomStart<SrcLen) and (Src[AtomStart]='"');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCCodeParserTool.LastAtomIs(const s: shortstring): boolean;
|
||||||
|
var
|
||||||
|
len: Integer;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if LastAtomStart<=LastSrcPos then exit(false);
|
||||||
|
len:=length(s);
|
||||||
|
if (len<>LastSrcPos-LastAtomStart) then exit(false);
|
||||||
|
if LastSrcPos>SrcLen then exit(false);
|
||||||
|
for i:=1 to len do
|
||||||
|
if Src[LastAtomStart+i-1]<>s[i] then exit(false);
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCCodeParserTool.GetLastAtom: string;
|
||||||
|
begin
|
||||||
|
Result:=copy(Src,LastAtomStart,LastSrcPos-LastAtomStart);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCCodeParserTool.GetAtom: string;
|
function TCCodeParserTool.GetAtom: string;
|
||||||
begin
|
begin
|
||||||
Result:=copy(Src,AtomStart,SrcPos-AtomStart);
|
Result:=copy(Src,AtomStart,SrcPos-AtomStart);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user