Re: C regexp package that can save compiled expressions?

Carl Barron <cbarron413@adelphia.net>
15 Aug 2004 22:21:18 -0400

          From comp.compilers

Related articles
C regexp package that can save compiled expressions? johnl@iecc.com (John R Levine) (2004-08-13)
Re: C regexp package that can save compiled expressions? gneuner2@comcast.net (George Neuner) (2004-08-15)
Re: C regexp package that can save compiled expressions? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-08-15)
Re: C regexp package that can save compiled expressions? cbarron413@adelphia.net (Carl Barron) (2004-08-15)
Re: C regexp package that can save compiled expressions? cdc@maxnet.co.nz (Carl Cerecke) (2004-08-15)
| List of all articles for this month |
From: Carl Barron <cbarron413@adelphia.net>
Newsgroups: comp.compilers
Date: 15 Aug 2004 22:21:18 -0400
Organization: Compilers Central
References: 04-08-090
Keywords: lex, comment
Posted-Date: 15 Aug 2004 22:21:18 EDT

John R Levine <johnl@iecc.com> wrote:


> So are there C regexp routines with a separate compiler? There used to be
> one shipped with some versions of Unix, but I can't find it any more. The
> standard regexp libraries are based on Henry Spencer's which compiles but
> not into code you can dump out and reload.


  The Spencer regexp code I am looking at is located at
http://www.boutell.com/ftp-materials/spencer-regexp/?C=N&O=A


It seems to compile the code twice once to get the size of the
compiled code and a second pass to compile the actual code. In between
it mallocs sizeof(regexp) + regsize bytes for the code to be written
to, between the passes. Regsize is a static long so it appears that a
short function can be added to regexp.c namely unsigned long
reg_data_size() {return sizeof(regexp) + regsize;}


Then simple file format containing the size of the program and the
dump of the block [you now have the length of the code produced.]
Should work, but I did not try it:)


Further see that catalog of free compilers,... periodically mentioned
in this newsgroup there is /was a C++ program creating a C function to
recognize a regular expression. Fewer bells and whistles than flex,
but if generated code is ok, it might be smaller and faster...
[That's re2c, which someone else also suggested. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.