Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Using RegExp backtracking to implement Prolog? :-)

by BerntB (Deacon)
on Oct 17, 2006 at 18:09 UTC ( [id://578864]=note: print w/replies, xml ) Need Help??


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. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://578864]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-29 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found