(Edit: Sorry, just realised that this should have been in the 'Ported from Delphi' sub-folder - If a mod could move it that would be good. Ta, FM)
I'm struggling to find a way of using Perl compatible regular expressions in a project.
The closest I have got is to download
TPerlRegEx from
http://www.regexbuddy.com/delphi.html - it's a Delphi wrapper around a C++ PCRE library apparently.
I've extracted the archive and put it where Lazarus and the fpc can find it, and I've converted one of the .pas files via the Lazarus Tools menu.
The other .pas file, however won't convert.
I've added PerlregEx to the
uses clause of the units that I want to use the regular expressions in (I need to use replace functionality so the built in RegEx support isn't really enough, I don't think) and the reference to the second .pas file seems to get picked up correctly but the compiler fails with the following messages:
C:\lazarus\components\perlregex\pcre.pas(623,22) Fatal: Syntax error, ":" expected but ";" foundIf I change the ; characters for : then I get the following errors:
C:\lazarus\components\perlregex\pcre.pas(623,32) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(624,33) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(625,31) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(626,45) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(627,39) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(628,33) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(629,29) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(630,40) Error: Can't declare local procedure as EXTERNAL
C:\lazarus\components\perlregex\pcre.pas(631,45) Error: Can't declare local procedure as EXTERNAL
C:\lazarus\components\perlregex\pcre.pas(632,23) Fatal: Syntax error, ":" expected but ";" found
How can I get these Delphi units to compile correctly in my project?
I've also tried adding:
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}to the pcre.pas (the conversion added it to PerlRegEx.pas automatically) but then I get a whole bunch of other errors:
C:\lazarus\components\perlregex\pcre.pas(627,32) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(627,10) Error: function header doesn't match the previous declaration "pcre_compile:<erroneous type>;"
C:\lazarus\components\perlregex\pcre.pas(378,10) Hint: Found declaration: pcre_compile(const PChar,LongInt,const PPAnsiChar,PInteger,const PChar):^real_pcre;
C:\lazarus\components\perlregex\pcre.pas(628,33) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(629,31) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(630,45) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(631,39) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(632,33) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(633,29) Error: Identifier not found "external"
C:\lazarus\components\perlregex\pcre.pas(634,40) Error: Can't declare local procedure as EXTERNAL
C:\lazarus\components\perlregex\pcre.pas(635,45) Error: Can't declare local procedure as EXTERNAL
C:\lazarus\components\perlregex\pcre.pas(636,33) Error: Can't declare local procedure as EXTERNAL
C:\lazarus\components\perlregex\pcre.pas(636,10) Error: No function result type specified for function "pcre_fullinfo"
C:\lazarus\components\perlregex\pcre.pas(637,44) Error: Can't declare local procedure as EXTERNAL
(I've removed a lot of duplicated and similar errors to keep the message post shorter).
Any help gratefully received.
Thanks,
FM