Applyable | Base class for anything that can be treated as a function. These objects have an apply method. |
Atom | Base class for all objects that represent Lisp atoms. |
Builtin | Class of objects that represent Lisp built-in functions. All functions are instances of this class, except for for the catch function which has its own refinement. |
Catch | Represents the catch built-in function. |
Closure | Abstract base class for closures. |
Context | Represents a context: all identifier definitions. |
DiscRefPtr | Represents a closure: combination of some code to run and a context. |
Error | The error atom. Essentially a Tom's Lisp exception. |
Evaluable | Abstract base class for anything that can be evaluated: can be sent to the Lisp eval function, and have an eval method in the C++ code. All objects visible to the Lisp program are evaluable. |
FuncClosure | A function created by the Lisp program: the result of a lambda call. |
Id | An identifier atom. |
Int | An integer atom. |
MacClosure | A closure for a macro; result of the macro function. |
Nil | The nil atom. |
Pair | A Lisp pair, being a car pointer and a cdr pointer. |
Ptr<T> | Template for a reference-counted pointer. |
RefCtObj | Abstract base class for reference-counted objects. |
RefPtr | Base class for the Ptr template that contains most of its works. |
Str | String atoms. |
atoms.h, atoms.cpp | These files contain definitions of classes for each type of atom: Nil, Str (strings), Id (identifiers), Int (integers) and Error, along with their base class Atom. |
builtin.h, builtin.cpp | The builtin files contain C++ functions to implement each of the Tom's Lisp built-in functions. An object of class Builtin is instantiated for each of these, though the Builtin class itself is defined in func.h. These files define closures, the combination of executable code and a context to run it in. The classes are Closure, and two specializations, FuncClosure and MacClosure, for functions and macros. This file also contains class DiscRefPtr, a specialization of Ptr<Context> that solves some shortcomings in the reference counting mechanism which are peculiar to closures. |
context.h, context.cpp | Here we define the Context object, which represents the values available to a computation. It is essentially a stack of dictionaries mapping strings to values, which are evaluable objects. |
evaluable.h | The Evaluable class is the abstract base of anything that can be sent to the lisp eval function. |
func.h, func.cpp | Here are the objects which can be treated as functions, starting with the abstract base class Applyable, then Builtin and Catch. Catch represents the built-in lisp function catch; all other built-ins are various instantiations of Builtin. The Closures are also Applyable, but they have their own file. A small bit of code for handling the ^C interrupt so that it returns to the interpreter instead of exiting the program. |
main.cpp | The main program. It parses the command line and records the options, creates the base context object, loads the initial definitions file that contains the non-built-in standard functions, does some other miscellaneous initialization, the runs the main read-eval-print loop. |
pair.h, pair.cpp | Contains the class Pair, Lisp's everything data structure. The class contains car and cdr pointers, and appropriate methods. |
read.h, read.cpp | This contains code to read Lisp code and create Lisp data structures from it. It contains scanner and token classes which do not represent Lisp language objects, but are used internally. |
refct.h | Tom's Lisp uses reference counting for garbage collection. Simple; not particularly efficient. It contains RefCtObj, the base class of any reference-counted object, RefPtr, a pointer to a reference-counted object, and the template Ptr<T>, which refines RefPtr to point to type T. |