/*
 * Copyright The Sett Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.thesett.aima.logic.fol.prolog;

import java.io.PrintStream;

import com.thesett.aima.logic.fol.interpreter.ResolutionInterpreter;

/**
 * PrologInterpreter builds an interactive resolving interpreter using the interpreted Prolog resolution engine
 * {@link PrologEngine}.
 *
 * <pre><p/><table id="crc"><caption>CRC Card</caption>
 * <tr><th> Responsibilities <th> Collaborations
 * <tr><td> Create an interpreter for Prolog. <td> {@link PrologEngine}
 * </table></pre>
 *
 * @author Rupert Smith
 */
public class PrologInterpreter
{
    /** Used for debugging purposes. */
    /* private static final Logger log = Logger.getLogger(PrologInterpreter.class.getName()); */

    /**
     * Creates the interpreter and launches its top-level run loop.
     *
     * @param args The command line arguments.
     */
    public static void main(String[] args)
    {
        try
        {
            PrologEngine engine = new PrologEngine();
            engine.reset();

            ResolutionInterpreter<PrologCompiledClause, PrologCompiledClause> interpreter =
                new ResolutionInterpreter<PrologCompiledClause, PrologCompiledClause>(engine);

            interpreter.interpreterLoop();
        }
        catch (Exception e)
        {
            /*log.log(Level.SEVERE, e.getMessage(), e);*/
            e.printStackTrace(new PrintStream(System.err));
            System.exit(-1);
        }
    }
}

@@ -696,41 +696,375 @@
 fol.
-interpreter.ResolutionInterpreter
+Clause;%0Aimport com.thesett.aima.logic.fol.Parser;%0Aimport com.thesett.aima.logic.fol.VariableAndFunctorInterner;%0Aimport com.thesett.aima.logic.fol.VariableAndFunctorInternerImpl;%0Aimport com.thesett.aima.logic.fol.interpreter.InteractiveParser;%0Aimport com.thesett.aima.logic.fol.interpreter.ResolutionInterpreter;%0Aimport com.thesett.aima.logic.fol.isoprologparser.Token
 ;%0A%0A/
@@ -1804,32 +1804,404 @@
   try%0A        %7B%0A
+            VariableAndFunctorInterner interner =%0A                new VariableAndFunctorInternerImpl(%22Prolog_Variable_Namespace%22, %22Prolog_Functor_Namespace%22);%0A            PrologCompiler compiler = new PrologCompiler(interner);%0A            PrologResolver resolver = new PrologResolver(interner);%0A            Parser%3CClause, Token%3E parser = new InteractiveParser(interner);%0A%0A
             Prol
@@ -2235,16 +2235,52 @@
 gEngine(
+parser, interner, compiler, resolver
 );%0A     

Set up the Prolog interpreter with the improved interactive top-level.