Removing old files
[lispp.git] / lisp.h
blob6f776d643333584aa0b0aa617409ad209686795b
1 #ifndef LISP_H_INCLUDED
2 #define LISP_H_INCLUDED
4 namespace lisp {
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
10 * expression. */
12 struct object;
14 enum kind {
15 e_ATOM = 0,
16 e_CONS,
17 e_FUNC,
18 e_LAMBDA
21 struct atom {
22 std::string name;
24 atom(const std::string& n) : name(n) {
28 struct cons {
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;
39 struct func {
40 lisp_func fn;
42 func(const lisp_func& f) : fn(f) {
47 struct lambda {
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) {
78 #endif