Boost logo

Boost :

Subject: Re: [boost] [spirit] alert when backtracking?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2011-03-07 20:31:11


On 03/07/11 17:45, Hartmut Kaiser wrote:
>> is there any way to detect at runtime or compile time whether Boost.Spirit
>> needs backtracking? It would be nice to be alerted to the fact that the
>> grammar is not LL(1) and thus has potential for optimization.
>
> Spirit.Qi backtracks only when using alternatives. That's easy enough to
> spot by looking at the granmmar.
>

Does spirit backtrack at *every* alternative even if the grammar is
LL(1)? IOW, spirit does *not* look ahead 1 token (as an LL(1) parser
would) to decide which alternative has to be chosen. Instead, it just
keeps trying the alternatives until 1 succeeds, and if none succeed
then it backtracks to the last alternative that has not been
exhaustively tried. Is that about right?

-Larry


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