Re: Prolog and evaluating expressions

Nils M Holm <>
Fri, 5 Oct 2007 16:08:02 +0200

          From comp.compilers

Related articles
Prolog and evaluating expressions (James Sison) (2007-10-04)
Re: Prolog and evaluating expressions (Nils M Holm) (2007-10-05)
| List of all articles for this month |

From: Nils M Holm <>
Newsgroups: comp.compilers
Date: Fri, 5 Oct 2007 16:08:02 +0200
Organization: Compilers Central
Keywords: prolog
Posted-Date: 05 Oct 2007 13:54:56 EDT

James Sison <> wrote:
> I'm trying to write this prolog interpreter but i encountered a
> problem. Let's say i'm evaluating a rule and i found a possible
> solution. How will i store my current position in the parse tree of
> the rule if i'm going back to it when i backtrack? I'm thinking of
> using a stack but then, i have no idea how to use it for this
> application. Do you guys have any opinions on the matter?

Using a stack or, more generally, recursion is a natural solution to
this problem. It might be best to study one of the tiny Prolog
interpreters that you can find on the Web. In case you are not opposed
to Scheme/LISP, here is a very tiny one:

Nils M Holm <> --

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.