1 #ifndef LISP_H_INCLUDED
2 #define LISP_H_INCLUDED
6 /* We begin by defining four types of objects we will be
7 * using. CONS is what we use to hold lists, ATOMs are letters or
8 * digits anything that is not used by LISP, a FUNC holds a
9 * reference to a C function and a LAMBDA holds a lambda
14 // TO DO : ADD SYMBOL, FIXNUM, FLOATNUM
26 atom(const std::string
& n
) : name(n
) {
31 boost::shared_ptr
<object
> car
;
32 boost::shared_ptr
<object
> cdr
;
34 cons(boost::shared_ptr
<object
> first
, boost::shared_ptr
<object
> second
) : car(first
), cdr(second
) {
39 typedef boost::function
< boost::shared_ptr
<object
> (boost::shared_ptr
<object
>,boost::shared_ptr
<object
>) > lisp_func
;
44 func(const lisp_func
& f
) : fn(f
) {
50 boost::shared_ptr
<object
> args
;
51 boost::shared_ptr
<object
> sexp
;
53 lambda(boost::shared_ptr
<object
> a
, boost::shared_ptr
<object
> s
) : args(a
), sexp(s
) {
59 boost::shared_ptr
<object
> value
;
61 symbol(boost::shared_ptr
<object
> v
) : value(v
) {
65 typedef boost::variant
< atom
, cons
, func
, lambda
, symbol
> base_object
;
67 struct object
: public base_object
{
69 object(const base_object
&b
) : base_object(b
) {
73 object(const std::string
&s
) : base_object(atom(s
)) {
79 extern boost::shared_ptr
<object
> tee
;
80 extern boost::shared_ptr
<object
> nil
;