in reply to Re: Using RegExp backtracking to implement Prolog? :-)
in thread Using RegExp backtracking to implement Prolog? :-)

Each predicate is compiled down to a method which contains a RE. The subroutine returns true if it succeeds, false otherwise and a specific constant if it has run into a cut.

Matched data etc is stored in the blessed object.

For all predicates, there is a "master" method that dispatches calls to other predicates of the same name, depending on number of parameters.

If a clause referenced a predicate, then code is inserted into the RE which calls the sub. Depending on the return value of the sub, the code fails/succeeds matching.

At least, that was how far I have gotten in my planning.

I don't know how to unsets unification when it do RE backtracking (there is no support for that in the (?{ }) construct?). And I probably have missed other stuff.

This idea probably reminds more than me about the idi.. uhm, heroes which implemented logical circuits in the game of Life. :-)

Update: Please don't flame me if I got the vocabulary wrong; it was a long time ago I read Prolog. :-)