Re: Speedup of regexp required for Tcl-Scanner



Whatever. It's not clear whether you are requesting assistance for
optimization of your regexps or trying to draw attention to an
unexpected algorithmic worst case.

In any case, from a macroscopic look, I have the impression that
you're trying to reimplement line-oriented prefix parsing (considering
the frequency of ^ and \n in your regexp) within an awkward block-
based parsing loop. I'd suggest instead:

while {[gets stdin line]>=0} {
switch -regexp -- $line {
{^Someprefix} {...}
...
}
}

-Alex


I can't use line based parsing with switch, as I might catch two
different regexp on the same line. Anyway with some ideas gathered
here we get a performance boost from about 50 seconds to one or two
seconds for a 5Mb file. The principle idea is to find a template where
a Flex-like input file can't be used to fill this to generate a
scanner.

regards,
detlef
.



Relevant Pages