// ------------------------------------------------------------
//  Copyright (C) 2002-2003 Michael Zeilfelder
//  e-mail: info@michaelzeilfelder.de
//
//  This program is published under the terms of the GNU
//  General Public License version 2 as published by the Free
//  Software Foundation.
// ------------------------------------------------------------
// Class for function handling in Lisp and
// some default functions which are always set by the Lisp
// interpreter (like quote and some math functions).
// ------------------------------------------------------------
#ifndef _LISPFUNCS_H
#define _LISPFUNCS_H

#include <string>

// forward declarations
class LispInterpreter;
class LispNode;

typedef LispNode* (*LispCallPtr) (LispInterpreter&, LispNode*);
class LispFunction
{
public:
    LispFunction( string name_, LispCallPtr fn_) : m_function(fn_), m_name(name_) {}
    LispNode* Call(LispInterpreter& lisp_, LispNode *node_ )    { return m_function(lisp_, node_); }
    bool IsName( const string& string_)                         {   return m_name.compare(string_) == 0 ? true : false; }

private:
    LispCallPtr m_function;
    string m_name;
};

LispNode* LispAdd( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispSub( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispMul( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispDiv( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispQuote( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispCar( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispCdr( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispEval( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispCons( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispSetf( LispInterpreter &lisp_, LispNode *node_);
LispNode* LispDefun( LispInterpreter &lisp_, LispNode *node_);

#endif // _LISPFUNCS_H
