You've already forked lazarus-ccr
chelper: added support for #import preprocessor, and c block objects declaration parsing
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1376 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -19,6 +19,9 @@
|
|||||||
<CharSet Value=""/>
|
<CharSet Value=""/>
|
||||||
<StringTable ProductVersion=""/>
|
<StringTable ProductVersion=""/>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
@ -50,7 +53,7 @@
|
|||||||
<Filename Value="cconvert"/>
|
<Filename Value="cconvert"/>
|
||||||
</Target>
|
</Target>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)/"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
@ -66,9 +69,6 @@
|
|||||||
<GenerateDebugInfo Value="True"/>
|
<GenerateDebugInfo Value="True"/>
|
||||||
<UseLineInfoUnit Value="False"/>
|
<UseLineInfoUnit Value="False"/>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
<Options>
|
|
||||||
<LinkerOptions Value="-macosx_version_min 10.4 "/>
|
|
||||||
</Options>
|
|
||||||
</Linking>
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
<CompilerMessages>
|
<CompilerMessages>
|
||||||
|
@ -76,14 +76,48 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure PrintHelp;
|
||||||
|
begin
|
||||||
|
writeln('cconvert - c to pascal convert utility');
|
||||||
|
writeln('possible options:');
|
||||||
|
writeln(' -all - convert the whole header to pascal, instead of a first entity');
|
||||||
|
writeln(' -o filename - specify the output file. if not specified, outputs to stdout');
|
||||||
|
writeln(' -ro - prevent the configuration file from modifications (adding new types, etc)');
|
||||||
|
writeln(' -cfg filename - specifies the configuration file');
|
||||||
|
writeln(' -defines filename - macros definition file. should be in C-preprocessor format');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ReadParams(var InputFileName: String);
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
s : string;
|
||||||
|
begin
|
||||||
|
for i:=1 to ParamCount do begin
|
||||||
|
s:=LowerCase(ParamStr(i));
|
||||||
|
if (s='-h') or (s='-help') or (s='-?') then begin
|
||||||
|
PrintHelp;
|
||||||
|
Halt;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
InputFileName:=ParamStr(ParamCount);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
inps, outs : TStringList;
|
inps, outs : TStringList;
|
||||||
i : Integer;
|
i : Integer;
|
||||||
p : TPoint;
|
p : TPoint;
|
||||||
cfg : TConvertSettings;
|
cfg : TConvertSettings;
|
||||||
err : TErrorInfo;
|
err : TErrorInfo;
|
||||||
|
fn : String;
|
||||||
begin
|
begin
|
||||||
if ParamCount=0 then Exit;
|
if ParamCount=0 then Exit;
|
||||||
|
ReadParams(fn);
|
||||||
|
if not FileExists(fn) then begin
|
||||||
|
writeln('file doesn''t exist: ', fn);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
inps := TStringList.Create;
|
inps := TStringList.Create;
|
||||||
outs := TStringList.Create;
|
outs := TStringList.Create;
|
||||||
|
|
||||||
|
@ -721,9 +721,9 @@ begin
|
|||||||
idx := Index;
|
idx := Index;
|
||||||
i := idx+1;
|
i := idx+1;
|
||||||
ScanWhile(Buf, i, WhiteSpaceChars);
|
ScanWhile(Buf, i, WhiteSpaceChars);
|
||||||
s := ScanTo(Buf, i, WhiteSpaceChars);
|
s := ScanTo(Buf, i, SpaceEolnChars);
|
||||||
if s='define' then df := TCPrepDefine.Create(idx)
|
if s='define' then df := TCPrepDefine.Create(idx)
|
||||||
else if s = 'include' then df := TCPrepInclude.Create(idx)
|
else if (s='include') or (s='import') then df := TCPrepInclude.Create(idx)
|
||||||
else if s='else' then df := TCPrepInclude.Create(idx)
|
else if s='else' then df := TCPrepInclude.Create(idx)
|
||||||
else if s='endif' then df := TCPrepEndif.Create(idx)
|
else if s='endif' then df := TCPrepEndif.Create(idx)
|
||||||
else if s='pragma' then df := TCPrepPragma.Create(idx)
|
else if s='pragma' then df := TCPrepPragma.Create(idx)
|
||||||
@ -739,12 +739,9 @@ begin
|
|||||||
Result := df.Parse(Self);
|
Result := df.Parse(Self);
|
||||||
Comments.Add(df);
|
Comments.Add(df);
|
||||||
if Assigned(OnPrecompile) then OnPrecompile(Self, df);
|
if Assigned(OnPrecompile) then OnPrecompile(Self, df);
|
||||||
end;
|
end else
|
||||||
|
SetError('cannot handle preprocessor: "'+s+'"');
|
||||||
|
|
||||||
if not Result then begin
|
|
||||||
SetError('cannot handle preprocessor');
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
finally
|
finally
|
||||||
ProcessingMacro := false;
|
ProcessingMacro := false;
|
||||||
end;
|
end;
|
||||||
@ -1168,8 +1165,6 @@ begin
|
|||||||
try
|
try
|
||||||
AParser.TokenTable.Symbols := AParser.TokenTable.Symbols + ['"'];
|
AParser.TokenTable.Symbols := AParser.TokenTable.Symbols + ['"'];
|
||||||
|
|
||||||
//i := AParser.TokenPos;
|
|
||||||
|
|
||||||
AParser.FindNextToken(s, tt);
|
AParser.FindNextToken(s, tt);
|
||||||
Result := (s = '"') or (s = '<');
|
Result := (s = '"') or (s = '<');
|
||||||
if not Result then Exit;
|
if not Result then Exit;
|
||||||
@ -1182,7 +1177,6 @@ begin
|
|||||||
if (s = '/') or (s = '\') or (tt = tt_Ident) then
|
if (s = '/') or (s = '\') or (tt = tt_Ident) then
|
||||||
Included := Included + s;
|
Included := Included + s;
|
||||||
until (tt =tt_Symbol) and ((s <> '\') or (s <> '/'));
|
until (tt =tt_Symbol) and ((s <> '\') or (s <> '/'));
|
||||||
|
|
||||||
Result := s = exp;
|
Result := s = exp;
|
||||||
SkipLine(AParser.buf, AParser.Index);
|
SkipLine(AParser.buf, AParser.Index);
|
||||||
finally
|
finally
|
||||||
@ -1689,7 +1683,7 @@ begin
|
|||||||
Parser.NextToken;
|
Parser.NextToken;
|
||||||
id:=ParseNamePart(Parser);
|
id:=ParseNamePart(Parser);
|
||||||
ConsumeToken(Parser, ')');
|
ConsumeToken(Parser, ')');
|
||||||
end else if Parser.TokenType=tt_Ident then begin
|
end else if (Parser.TokenType=tt_Ident) or (Parser.Token='^') then begin
|
||||||
id:=TNamePart.Create(nk_Ident);
|
id:=TNamePart.Create(nk_Ident);
|
||||||
id.id:=Parser.Token;
|
id.id:=Parser.Token;
|
||||||
Parser.NextToken;
|
Parser.NextToken;
|
||||||
|
Reference in New Issue
Block a user