Forum > Packages and Libraries
TPerlRegEx
fatmonk:
(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:
--- Code: ---C:\lazarus\components\perlregex\pcre.pas(623,22) Fatal: Syntax error, ":" expected but ";" found
--- End code ---
If I change the ; characters for : then I get the following errors:
--- Code: ---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
--- End code ---
How can I get these Delphi units to compile correctly in my project?
I've also tried adding:
--- Code: ---{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
--- End code ---
to the pcre.pas (the conversion added it to PerlRegEx.pas automatically) but then I get a whole bunch of other errors:
--- Code: ---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
--- End code ---
(I've removed a lot of duplicated and similar errors to keep the message post shorter).
Any help gratefully received.
Thanks,
FM
marcov:
I downloaded the zip, and ran
--- Quote ---fpc -Sd PerlRegEx.pas
Free Pascal Compiler version 2.6.0 [2011/12/25] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling PerlRegEx.pas
Compiling pcre.pas
2108 lines compiled, 0.5 sec
--- End quote ---
So I don't really understand the problem :-)
( -Sd is the commandline equivalent of mode delphi. Did you add the $mode delphi block to both files (perlregex and pcre) after the interface statement? )
fatmonk:
I'm gonna need a bit more than that :P
How did you compile that? Straight from the command line (I haven't played with the fpc command line yet)? In it's own project (the zip doesn't contain a project itself so what kind f Lazarus project was it and how did you add that unit to it?).
Apologies for dumb questions, but having come from Borland C++ Builder about 10 years ago I'm just starting out getting to grips with lazarus and fpc.
Thanks,
FM
BigChimp:
@FM: BTW, did you know there is a regex implementation in FPC? Not complete, but maybe enough for your needs:
http://wiki.lazarus.freepascal.org/Regexpr
Yes, it looks like Marco compiled it straight from the command line: his output shows he compiles PerlRegEx.pas
Leledumbo:
--- Quote ---Yes, it looks like Marco compiled it straight from the command line: his output shows he compiles PerlRegEx.pas
--- End quote ---
And without converting first.
Navigation
[0] Message Index
[#] Next page