sexpr is a library intended for developers who wish to manipulate (read, parse, modify, and create) symbolic expressions from C or C++ programs. A symbolic expression, or s-expression, is essentially a LISP-like expression such as (a (b c)). S-expressions are able to represent complex, structured data without requiring additional meta-data describing the structure. They are recursively defined: an s-expression is a list of either atoms or s-expressions. In the example above, the expression contains an atom "a" and an s-expression, which in turn contains two atoms, "b" and "c". They are simple, useful, and well understood.
This library is intended to be a minimal set of functions and structures for the four functions listed above: reading s-expressions (I/O), parsing strings containing them into an AST equivalent, modifying the AST representation, and converting the AST back into a well formatted string. The primary goals are efficiency and simplicity. This library forms the basis of the data representation and transmission protocol for the supermon high-speed cluster monitoring system from the LANL ACL. The usefulness and lack of choice in available, open source s-expression libraries motivated the independent (from supermon) release of this library. Although the number of potential users represents a rather small community, the author felt it was a valuable contribution. As of March 2005, this library has actually received more interest in terms of downloads and page views than it's parent project!
What's New in This Release:
· introduction of sexp_errors.h, corresponding sexp_errcode_t type,
the library errno variable "sexp_errno" and the "error" field in the
pcont_t structure. This is the biggest revision to the library. Instead
of asserting or fprintf() and exiting, the library attempts to gracefully
return to the caller providing error cause information via the
sexp_errno and error fields.
· Removed deprecated functions, removed testers for corresponding
functions. Functions removed were cons, car and cdr.
· event-based parsing is removed for now from the main source files.
callbacks still exist, but the full parser based on events was
removed. the original implementation essentially required a
duplicate parse_sexp() function, which seemed like a recipe for
version skew and disaster. this limits the ability to parse
infinite streams of s-expressions, but I'd rather get it right than
to have the suboptimal solution in the distribution. the code is
still available in the src/event_temp.c file, but not in the main
· Cleaned up makefiles
· Updates to documentation.
· Fixed memory management routines to properly cast return value of
malloc, realloc, calloc for C++. These are not required for C (and are
bad practice in C), but C++ needs them.
· new_sexp_atom requires explicit type to avoid defaulting to SEXP_BASIC.
· assertions and fprintf() calls removed to clean up how the library handles
errors, especially when integrating with projects that would prefer a
library call not to assert and die or spew fprintf messages.
· patched a few places where NULL checks were not occurring to avoid
· cleaned up read_one_sexp() function.
· fixed bugs related to LIMITMEMORY mode.
· fixed bug in sexp_destroy() where frees could occur on non-malloc'd
· revised comments and documentation to reflect my new location at
the University of Oregon, Computer Science Department after departing
Los Alamos National Laboratory in September 2007.
· new tester added to exercise some of the new error handling features.
Note: Many thanks to Herb Maeder for contributions and comments related to error handling and various cleanup topics.