
8 Mar
2011
8 Mar
'11
1:31 a.m.
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