Skip to content
P. Todd Decker edited this page Jan 12, 2016 · 4 revisions

Note: This is the first attempt at organizing into modules and I'm not entirely happy with the approach. Also, the code is verbose for the purposes of clarity and learning. But, the redundant and single-use functions will be refactored out.

Credit: The initial pass at this is highly based upon the work of Peter Michaux. My major changes are noted in the README.md and ptscheme.c files.

Major code components

  • environments - Provides functions supporting the list s-expression environments and variable storage. 'init_environment()' gets everything going by creating an empty environment and global environment singletons. 'setup_enviornment()' populates a new environment with the primitive procedures. 'define_variable()', 'set_variable_value()', and 'lookup_variable_value()' provide neutered CRUD (no delete) operations on environment variables. The remaining functions are helpers.
  • hashtable - Provides functions to add symbols to, and retrieve them from, a hash table.
  • lispbool, lispchar, lispint, lispfloat, and lispstr - Provide a factory function and testors for the booleans, characters, integers, real numbers, and strings respectively.
  • lisperr - Provides an error object type used by the basic error control approach currently implemented.
  • lisppair - Provides functions to build list pairs and return their parts.
  • memmanager - Provides memory management functions which, at the current time, are none other than grabbing more space. Also, allocating space for strings is spread through the code and needs to be consolidated into this module too. Eventually, functions will be expanded out to provide garbage collection.
  • primitives - Provides functions to support the implementation of the currently supported primitives. Also, 'populate_environment()' populates these primitives into a passed environment. There is a lot of redundancy and verbosity in here that will be cleaned up.
  • symbols - Provides singleton factories for all the primitive symbols currently supported. The redundancy in here needs to be removed too.
  • replread, repleval, replprint -
    • replread - provides a basic hand-coded recursive descent parser and helper functions. Grown organically, I'm sure it can be optimized
    • repleval - implements the native C-based eval engine pattered after the meta-evaluator in SICP. Tons of credit goes to Peter Michaux for his work in pulling this together.
    • replprint - a basic recursive print capability used to complete the REPL loop
  • ptscheme - the main() which sets up the initial environment and implements the REPL itself. Also, ptscheme.h provides the definition for the object structure used through the implementation
Clone this wiki locally