You've already forked lazarus-ccr
chelper: cleanup error message generator. added obj-c class bit sized fields support
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3983 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -28,7 +28,7 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
Err_Ident = 'Identifier';
|
Err_Ident = 'Identifier';
|
||||||
Err_Expect = '%s, excepted, but "%s" found';
|
Err_Expect = 'Token "%s" excepted, but "%s" found';
|
||||||
Err_BadPrecompile = 'Bad precompile directive';
|
Err_BadPrecompile = 'Bad precompile directive';
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -322,7 +322,7 @@ type
|
|||||||
TCustomEntityProc = function (Parent: TEntity; Parser: TTextParser): TEntity;
|
TCustomEntityProc = function (Parent: TEntity; Parser: TTextParser): TEntity;
|
||||||
|
|
||||||
procedure ErrorExpect(Parser: TTextParser; const Expect: AnsiString);
|
procedure ErrorExpect(Parser: TTextParser; const Expect: AnsiString);
|
||||||
function ConsumeToken(Parser: TTextParser; const Token: AnsiString): Boolean;
|
function ConsumeToken(Parser: TTextParser; const Token: AnsiString; const comment: string = ''): Boolean;
|
||||||
function ConsumeIdentifier(Parser: TTextParser; var Id: AnsiString): Boolean;
|
function ConsumeIdentifier(Parser: TTextParser; var Id: AnsiString): Boolean;
|
||||||
|
|
||||||
function ParseCType(Parser: TTextParser): TEntity;
|
function ParseCType(Parser: TTextParser): TEntity;
|
||||||
@ -424,6 +424,7 @@ end;
|
|||||||
|
|
||||||
function ErrExpectStr(const Expected, Found: AnsiString): AnsiString;
|
function ErrExpectStr(const Expected, Found: AnsiString): AnsiString;
|
||||||
begin
|
begin
|
||||||
|
//todo: duplication ?
|
||||||
Result := Format(Err_Expect, [Expected, Found]);
|
Result := Format(Err_Expect, [Expected, Found]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1556,14 +1557,15 @@ end;
|
|||||||
|
|
||||||
procedure ErrorExpect(Parser:TTextParser;const Expect:AnsiString);
|
procedure ErrorExpect(Parser:TTextParser;const Expect:AnsiString);
|
||||||
begin
|
begin
|
||||||
Parser.SetError('expected: "'+ Expect + '" but "'+Parser.Token+'" found');
|
//todo: duplication ?
|
||||||
|
Parser.SetError( ErrExpectStr( Expect, Parser.Token) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ConsumeToken(Parser:TTextParser;const Token:AnsiString):Boolean;
|
function ConsumeToken(Parser:TTextParser;const Token: AnsiString; const comment: string):Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=Parser.Token=Token;
|
Result:=Parser.Token=Token;
|
||||||
if Result then Parser.NextToken
|
if Result then Parser.NextToken
|
||||||
else Parser.SetError('Token expected: '+Token);
|
else Parser.SetError( ErrExpectStr( Token, Parser.Token)+comment);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ConsumeIdentifier(Parser: TTextParser; var Id: AnsiString): Boolean;
|
function ConsumeIdentifier(Parser: TTextParser; var Id: AnsiString): Boolean;
|
||||||
|
@ -71,6 +71,8 @@ type
|
|||||||
public
|
public
|
||||||
scope : TObjCScope;
|
scope : TObjCScope;
|
||||||
v : TVarFuncEntity;
|
v : TVarFuncEntity;
|
||||||
|
bits : TExpression;
|
||||||
|
isbitted : Boolean;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -179,6 +181,8 @@ var
|
|||||||
iv : TObjCInstVar;
|
iv : TObjCInstVar;
|
||||||
s : AnsiString;
|
s : AnsiString;
|
||||||
scope : TObjCScope;
|
scope : TObjCScope;
|
||||||
|
isbitted : Boolean;
|
||||||
|
bits : TExpression;
|
||||||
begin
|
begin
|
||||||
Result:=True;
|
Result:=True;
|
||||||
if AParser.Token<>'{' then Exit;
|
if AParser.Token<>'{' then Exit;
|
||||||
@ -201,10 +205,21 @@ begin
|
|||||||
AParser.NextToken;
|
AParser.NextToken;
|
||||||
end else begin
|
end else begin
|
||||||
v:=TVarFuncEntity.Create(AParser.TokenPos);
|
v:=TVarFuncEntity.Create(AParser.TokenPos);
|
||||||
if not ParseNames(AParser, v.RetType, v.Names, [';']) then Exit;
|
if not ParseNames(AParser, v.RetType, v.Names, [';',':']) then Exit;
|
||||||
|
|
||||||
|
if AParser.Token=':' then begin
|
||||||
|
AParser.NextToken;
|
||||||
|
isbitted:=True;
|
||||||
|
bits:=ParseCExpr(AParser);
|
||||||
|
end else begin
|
||||||
|
isbitted:=false;
|
||||||
|
bits:=nil;
|
||||||
|
end;
|
||||||
iv:=TObjCInstVar.Create(v.Offset);
|
iv:=TObjCInstVar.Create(v.Offset);
|
||||||
iv.v:=v;
|
iv.v:=v;
|
||||||
iv.scope:=scope;
|
iv.scope:=scope;
|
||||||
|
iv.isbitted:=isbitted;
|
||||||
|
iv.bits:=bits;
|
||||||
Vars.Add(iv);
|
Vars.Add(iv);
|
||||||
if AParser.Token=';' then AParser.NextToken;
|
if AParser.Token=';' then AParser.NextToken;
|
||||||
end;
|
end;
|
||||||
@ -219,6 +234,7 @@ var
|
|||||||
itf : TObjCInterface;
|
itf : TObjCInterface;
|
||||||
i : Integer;
|
i : Integer;
|
||||||
nm : AnsiString;
|
nm : AnsiString;
|
||||||
|
ent : TEntity;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if AParser.Token<>'@interface' then Exit;
|
if AParser.Token<>'@interface' then Exit;
|
||||||
@ -258,6 +274,14 @@ begin
|
|||||||
AParser.NextToken;
|
AParser.NextToken;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ todo: typedef could be found within class
|
||||||
|
while APArser.Token='typedef' do begin
|
||||||
|
ent := ParseTypeDef(APArser );
|
||||||
|
if not Assigned(ent) then Exit;
|
||||||
|
itf.Vars.Add(ent);
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
ParseInstVars(AParser, itf.Vars);
|
ParseInstVars(AParser, itf.Vars);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -428,6 +452,7 @@ begin
|
|||||||
if ConsumeToken(AParser,'...') then m.VarParams:=True
|
if ConsumeToken(AParser,'...') then m.VarParams:=True
|
||||||
else ErrorExpect(AParser, '...');
|
else ErrorExpect(AParser, '...');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not ConsumeToken(AParser, ';') then Exit;
|
if not ConsumeToken(AParser, ';') then Exit;
|
||||||
|
|
||||||
Result:=m;
|
Result:=m;
|
||||||
@ -506,6 +531,7 @@ end;
|
|||||||
destructor TObjCInstVar.Destroy;
|
destructor TObjCInstVar.Destroy;
|
||||||
begin
|
begin
|
||||||
v.Free;
|
v.Free;
|
||||||
|
bits.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user