Small, Fast S-Expression Library
A small and quick S-expression parsing library.

Introduction

This library was created to provide s-expression parsing and manipulation facilities to C and C++ programs. The primary goals were speed and efficiency - low memory impact, and the highest speed we could achieve in parsing. Suprisingly, no other libraries on the net were found that were not bloated with features or involved embedding a full-fledged LISP or Scheme interpreter into our programs. So, this library evolved to fill this gap. As such, it does not guarantee that every valid LISP expression is parseable, and many features that are not required aren't implemented. See Rivest's S-expression library for an example of a much more featureful library.

What features does this library include? At the heart of the code is a continuation-based parser implementing a basic parser state machine. Continuations allow users to accumulate multiple streams of characters, and parse each stream simultaneously. A continuation allows the parser to stop midstream, start working on a new expression, and return to the first without corruption of complex state management in the users code. No threads, no forking, nothing more than a data structure that must be passed in and captured as data becomes available to parse. Once an expression has been parsed, a simple structure is returned that represents the "abstract syntax tree" of the parsed expression. For the majority of users, the parser and this data structure will be all that they will ever need to see. For convenience reasons, other functions such as I/O wrappers and AST traversal routines have been included, but they are not required if users don't wish to use them.

Credits

SFSEXP: Small, Fast S-Expression Library version 1.2, October 2007
Written by Matthew Sottile (mjsot.nosp@m.tile.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

License Information

Copyright (2003-2006). The Regents of the University of California. This material was produced under U.S. Government contract W-7405-ENG-36 for Los Alamos National Laboratory, which is operated by the University of California for the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from LANL.

Additionally, this library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U SA

LA-CC-04-094