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
24 atom(const std::string
& n
) : name(n
) {
29 boost::shared_ptr
<object
> car
;
30 boost::shared_ptr
<object
> cdr
;
32 cons(boost::shared_ptr
<object
> first
, boost::shared_ptr
<object
> second
) : car(first
), cdr(second
) {
37 typedef boost::function
< boost::shared_ptr
<object
> (boost::shared_ptr
<object
>,boost::shared_ptr
<object
>) > lisp_func
;
42 func(const lisp_func
& f
) : fn(f
) {
48 boost::shared_ptr
<object
> args
;
49 boost::shared_ptr
<object
> sexp
;
51 lambda(boost::shared_ptr
<object
> a
, boost::shared_ptr
<object
> s
) : args(a
), sexp(s
) {
56 typedef boost::variant
< atom
, cons
, func
, lambda
> base_object
;
58 struct object
: public base_object
{
59 object(base_object
&b
) : base_object(b
) {
62 object(const std::string
&s
) : base_object(atom(s
)) {
65 object(const lisp::cons
& c
) : base_object(c
) {
68 object(const lisp::lambda
& l
) : base_object(l
) {
71 object(const lisp::lisp_func
& f
) : base_object(f
) {