On 6 June 2015 at 18:57, Jonathan S. Shapiro <[email protected]> wrote:
> Keean: > > Your current C++ combinator library, as I understand it, is a backtracking > implementation. When the parser backtracks, what happens to the discarded > parse results? I imagine that the parser may have assembled AST subtrees to > be discarded, with the result that reclamation isn't trivial. What's the > model? > Yes this is indeed a problem. The neatest solution I have found is to embed Prolog, or in fact just to use Prolog :-) What I do in the C++ combinators, because backtracking is controlled by the 'attempt' parser (its the only place backtracking happens) is save the current state and restore it on backtracking. The current state is threaded like the inherited attributes of an attribute grammar, so if you want backtracking it has to be copyable and assignable. Keean.
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
