[comp.lang.c] Looking for pattern matchers

a38@nikhefh.nikhef.nl (James Barr) (02/22/91)

Hi,

can anyone point me towards a regular expression matcher
that acts like lex in that you can add a number of different
expressions so that a token is returned on matching a
particular expression. I could do it simply by calling
re_exec or the like sequentially for each expression,
but this is a bit inefficient.  I'd like to be able to
add and remove expressions dynamically.

Cheers,
james


-- 
James Barr                                        ...............       ......
+31 20-592-5104                                   ...........       ..........
James.Barr@nikhef.nl                              ......        ..............
NIKHEF, Kruislaan 409, 1009DB Amsterdam           ..        ..................

jrv@sdimax2.mitre.org (VanZandt) (03/01/91)

In article <1156@nikhefh.nikhef.nl> a38@nikhefh.nikhef.nl (James Barr) writes:
>can anyone point me towards a regular expression matcher
>that acts like lex in that you can add a number of different
>expressions so that a token is returned on matching a
>particular expression. 

Henry Spencer's regular expression routine initializes an array of pointers
corresponding to the open parentheses in the regular expression.  How about
consolidating the REs into one big RE and determining which subexpressions
matched by testing which pointers are set:
   (able)|(baker)|(charlie)

Note: I haven't tried this.

                               - Jim Van Zandt