You've already forked lazarus-ccr
some bugs fixed
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@401 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -6,9 +6,6 @@
|
|||||||
objc parsing unit
|
objc parsing unit
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: remove last ';' skipping. must be added lately
|
|
||||||
|
|
||||||
|
|
||||||
unit ObjCParserTypes;
|
unit ObjCParserTypes;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -143,6 +140,8 @@ type
|
|||||||
procedure DoParse(AParser: TTextParser); override;
|
procedure DoParse(AParser: TTextParser); override;
|
||||||
public
|
public
|
||||||
_Name : AnsiString;
|
_Name : AnsiString;
|
||||||
|
//todo: remove
|
||||||
|
_isPointer : Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTypeDef }
|
{ TTypeDef }
|
||||||
@ -265,8 +264,19 @@ function ScanTo(const s: AnsiString; var index: Integer; const ch: TCharSet): An
|
|||||||
|
|
||||||
function ParseTypeDef(Owner: TEntity; AParser: TTextParser): TEntity;
|
function ParseTypeDef(Owner: TEntity; AParser: TTextParser): TEntity;
|
||||||
|
|
||||||
|
procedure FreeEntity(Item: TEntity);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
procedure FreeEntity(Item: TEntity);
|
||||||
|
var
|
||||||
|
i : Integer;
|
||||||
|
begin
|
||||||
|
for i := 0 to Item.Items.Count - 1 do
|
||||||
|
FreeEntity(TEntity(Item.Items[i]));
|
||||||
|
Item.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetTypeNameFromEntity(Entity: TEntity): AnsiString;
|
function GetTypeNameFromEntity(Entity: TEntity): AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
@ -941,8 +951,11 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
nm : AnsiString;
|
nm : AnsiString;
|
||||||
tt : TTokenType;
|
tt : TTokenType;
|
||||||
|
brac : Integer;
|
||||||
begin
|
begin
|
||||||
|
//todo: better code. it's just a work around
|
||||||
// i := AParser.Index;
|
// i := AParser.Index;
|
||||||
|
brac := 0;
|
||||||
Result := '';
|
Result := '';
|
||||||
while AParser.FindNextToken(nm, tt) do begin
|
while AParser.FindNextToken(nm, tt) do begin
|
||||||
if (tt = tt_Numeric) or (tt = tt_Ident) then begin
|
if (tt = tt_Numeric) or (tt = tt_Ident) then begin
|
||||||
@ -950,14 +963,21 @@ begin
|
|||||||
i := AParser.Index;
|
i := AParser.Index;
|
||||||
if not ParseCOperator(AParser, nm) then begin
|
if not ParseCOperator(AParser, nm) then begin
|
||||||
AParser.Index := i;
|
AParser.Index := i;
|
||||||
Exit;
|
Break;
|
||||||
end else
|
end else
|
||||||
Result := Result + ' ' + nm + ' ';
|
Result := Result + ' ' + nm + ' ';
|
||||||
|
end else if (tt = tt_Symbol) then begin
|
||||||
|
if nm ='(' then inc(brac)
|
||||||
|
else if nm = ')' then dec(brac);
|
||||||
end else begin
|
end else begin
|
||||||
//i := AParser.Index;
|
//i := AParser.Index;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if brac > 0 then
|
||||||
|
while (brac > 0) and (AParser.FindNextToken(nm, tt)) do
|
||||||
|
if nm = ')' then
|
||||||
|
dec(brac);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TEnumValue }
|
{ TEnumValue }
|
||||||
@ -997,6 +1017,7 @@ begin
|
|||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
if s <> 'typedef' then Exit;
|
if s <> 'typedef' then Exit;
|
||||||
_Type := ParseTypeDef(Self, AParser);
|
_Type := ParseTypeDef(Self, AParser);
|
||||||
|
|
||||||
AParser.FindNextToken(_TypeName, tt);
|
AParser.FindNextToken(_TypeName, tt);
|
||||||
_inherited := GetTypeNameFromEntity(_Type);
|
_inherited := GetTypeNameFromEntity(_Type);
|
||||||
AParser.FindNextToken(s, tt); // skip last ';';
|
AParser.FindNextToken(s, tt); // skip last ';';
|
||||||
@ -1011,6 +1032,7 @@ var
|
|||||||
tt : TTokenType;
|
tt : TTokenType;
|
||||||
i : Integer;
|
i : Integer;
|
||||||
st : TStructField;
|
st : TStructField;
|
||||||
|
prev : TStructField;
|
||||||
begin
|
begin
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
if s <> 'struct' then Exit;
|
if s <> 'struct' then Exit;
|
||||||
@ -1019,21 +1041,36 @@ begin
|
|||||||
if (tt = tt_Ident) then begin
|
if (tt = tt_Ident) then begin
|
||||||
_Name := s;
|
_Name := s;
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
AParser.Index := i;
|
i := AParser.TokenPos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (tt <> tt_Symbol) and (s <> '{') then begin
|
if not ((tt = tt_Symbol) and (s = '{')) then begin
|
||||||
AParser.Index := i;
|
if (tt = tt_Symbol) and (s = '*')
|
||||||
|
then _isPointer := true
|
||||||
|
else AParser.Index := i;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
|
prev := nil;
|
||||||
while s <> '}' do begin
|
while s <> '}' do begin
|
||||||
//i := AParser.TokenPos;
|
//i := AParser.TokenPos;
|
||||||
st := TStructField.Create(Self);
|
st := TStructField.Create(Self);
|
||||||
|
if not Assigned(prev) then begin
|
||||||
st.Parse(AParser);
|
st.Parse(AParser);
|
||||||
|
end else begin
|
||||||
|
AParser.FindNextToken(st._Name, tt);
|
||||||
|
st._TypeName := prev._TypeName;
|
||||||
|
end;
|
||||||
|
|
||||||
Items.Add(st);
|
Items.Add(st);
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
|
if s = ',' then prev := st
|
||||||
|
else prev := nil;
|
||||||
|
if s = ';' then begin
|
||||||
|
AParser.FindNextToken(s, tt);
|
||||||
|
if s <> '}' then AParser.Index := AParser.TokenPos;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//no skipping last ';', because after structure a variable can be defined
|
//no skipping last ';', because after structure a variable can be defined
|
||||||
@ -1059,7 +1096,10 @@ begin
|
|||||||
if Assigned(_Type) then Exit;
|
if Assigned(_Type) then Exit;
|
||||||
_TypeName := GetTypeNameFromEntity(_Type);
|
_TypeName := GetTypeNameFromEntity(_Type);
|
||||||
|
|
||||||
if not (AParser.FindNextToken(_Name, tt)) or (tt <> tt_Ident) then Exit;
|
if not (AParser.FindNextToken(s, tt)) or (tt <> tt_Ident) then begin
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
if (tt = tt_Symbol) and (s = ':') then begin
|
if (tt = tt_Symbol) and (s = ':') then begin
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
|
Reference in New Issue
Block a user