help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scanner takes a long time to build.


From: John Millaway
Subject: Re: Scanner takes a long time to build.
Date: Thu, 25 Jul 2002 14:21:55 -0700 (PDT)

> Paragraph\ .a.{0,10}2.{0,10}C.\ of\ S.\ 1618

That last regex is enough to blow up the DFA. It's not the number of regular
expressions killing your flex file, it's the patterns. Have a look:

Regex                                                   ~DFA Size
-----                                                   ---------
.                                                       ==> [7]
.{0,10}                                                 ==> [16]
.{0,10}x                                                ==> [35]
.{0,10}x.                                               ==> [65]
.{0,10}x.{0,10}                                         ==> [9212]
.{0,10}x.{0,10}y                                        ==> [16917]
.{0,10}x..{0,10}y                                       ==> [23079]
.{0,10}x...{0,10}y                                      ==> [29255]
.{0,10}x....{0,10}y                                     ==> [35455]
Paragraph\ .a.{0,10}2.{0,10}C.\ of\ S.\ 1618            ==> [29790]
Paragraph\ .a[^2\n]{0,10}2.{0,10}C.\ of\ S.\ 1618       ==> [257]
Paragraph\ .a[^2\n]{0,10}2[^C\n]{0,10}C.\ of\ S.\ 1618  ==> [89]

I replaced the first . with [^2\n], and the second . with [^C\n]. This may not
be what you want, but it shows the drastic reduction in DFA size. You'll have
to rethink your regex's. Refer to the O'Reilly book , "Mastering Regular
Expressions". This subject is addressed.

-John


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]