Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-02-07 11:04:04


Thorsten Ottosen wrote:
> Thorsten Ottosen skrev:
>> Hi Eric,
>>
>> (Apologies in advance for such a stupid question.)
>
> I case it helps, then below is my complete function.

The single most important thing you can do, both to reduce stack space
and improve parse times, is to eliminate backtracking where you can with
the keep() directive. For instance, in a lot of places you have *space
>> X, where X cannot match a whitespace character and space is an
sregex defined as _s | _ln. Replace it with keep(*_s) or keep(+_s).
It'll mean the same thing, use up vastly less stack and be *much* more
efficient.

And a tip: when you quantify something simple (e.g., a single char
matcher) like +_s it is implemented iteratively. When you quantify
something that can match a variable number of characters like +space or
+(_s | _ln) it is implemented recursively.

HTH,

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk