Skip to content

Commit

Permalink
formatting and update dist target
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsottile committed May 29, 2021
1 parent 2b685eb commit 95e4b34
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SUBDIRS = src examples tests
EXTRA_DIST = Doxyfile README_cmake.txt win32
EXTRA_DIST = Doxyfile README.md README_cmake.txt win32

ACLOCAL_AMFLAGS = -I m4
118 changes: 74 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
sfsexp
======

This library is 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 designed to provide a minimal set of functions and data 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](https://dl.acm.org/doi/10.5555/792762.793324) high-speed cluster monitoring system from the LANL Advanced Computing Laboratory. The usefulness and lack of choice in available, open source s-expression libraries around 2003 motivated the independent (from supermon) release of this library.
This library is 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 designed to provide a minimal set of functions and
data 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](https://dl.acm.org/doi/10.5555/792762.793324) high-speed
cluster monitoring system from the LANL Advanced Computing
Laboratory. The usefulness and lack of choice in available, open
source s-expression libraries around 2003 motivated the independent
(from supermon) release of this library.

## Building

(Attention Windows Users: If you are using cygwin, this section applies as
cygwin looks pretty much like unix for compilation. Visual Studio users see
the note at the end and look inside the win32 directory.)
(Attention Windows Users: If you are using cygwin, this section
applies as cygwin looks pretty much like unix for compilation. Visual
Studio users see the note at the end and look inside the win32
directory.)

Configure the sources via autoconf.

```
% ./configure
```

Currently, the only feature that can be enabled via autoconf is to enable any
debugging code in the library by specifying "--enable-debug". Other features
such as disabling memory management by the library are toggled by setting
appropriate options in the CFLAGS:
Currently, the only feature that can be enabled via autoconf is to
enable any debugging code in the library by specifying
"--enable-debug". Other features such as disabling memory management
by the library are toggled by setting appropriate options in the
CFLAGS:

```
% CFLAGS=-D_NO_MEMORY_MANAGEMENT_ ./configure
Expand All @@ -35,21 +57,22 @@ After building, just invoke make:
% make
```

What comes out is a library called "libsexp.a". If you wish to copy the
headers and libraries to an installation location, you should then say:
What comes out is a library called "libsexp.a". If you wish to copy
the headers and libraries to an installation location, you should then
say:

```
% make install
```

At the current time, this is not recommended if the installation prefix is
/usr or /usr/local, since the headers do not go into an isolated subdirectory.
In the future, we will hopefully have a single consolidated header that
encapsulates all of the headers currently included in the library. If you do
not want to aim your project that uses the library into the library source and
build directories directly, creating a separate installation prefix and
installing there is recommended. For example, from the root of the sexpr
tree:
At the current time, this is not recommended if the installation
prefix is /usr or /usr/local, since the headers do not go into an
isolated subdirectory. In the future, we will hopefully have a single
consolidated header that encapsulates all of the headers currently
included in the library. If you do not want to aim your project that
uses the library into the library source and build directories
directly, creating a separate installation prefix and installing there
is recommended. For example, from the root of the sexpr tree:

```
% mkdir installTree
Expand All @@ -58,29 +81,31 @@ tree:
% make install
```

If you want the docs, make sure you have doxygen installed and that the
DOXYGEN variable in the Makefile.in in this directory points at the right
place. Re-run autoconf to regenerate the makefiles, and then type:
If you want the docs, make sure you have doxygen installed and that
the DOXYGEN variable in the Makefile.in in this directory points at
the right place. Re-run autoconf to regenerate the makefiles, and
then type:

```
% make doc
```

## Usage notes

In any code that wants to use this, just include "sexp.h". That contains the
one data structure, enumeration, and five functions for manipulating and
parsing strings and s-expressions. Compilation typically will look like:
In any code that wants to use this, just include "sexp.h". That
contains the one data structure, enumeration, and five functions for
manipulating and parsing strings and s-expressions. Compilation
typically will look like:

```
% cc -I/path/to/sexp/include -L/path/to/sexp/library \
-o foo foo.o -lsexp
```

The critical parts are to ensure that the include path aims at the path
containing the library headers, the library path aims at the path containing
the compiled binary libraries, and the library is linked in with the
executable.
The critical parts are to ensure that the include path aims at the
path containing the library headers, the library path aims at the path
containing the compiled binary libraries, and the library is linked in
with the executable.

The API is well-documented in the header files, esp.
[sexp.h](src/sexp.h) and [sexp_ops.h](src/sexp_ops.h). The latter
Expand All @@ -106,9 +131,9 @@ you will get error `SEXP_ERR_INCOMPLETE`, meaning "parsing is
incomplete and needs more data to complete it."
([sexp_errors.h](src/sexp_errors.h)). This can easily happen if you
are reading data encoded as sexps. For example, it's not uncommon for
a big hunk o' data to be encoded as a single sexp in a file. One way to
handle this situation is to get the file size, dynamically allocate a
buffer big enought to hold it, and then use `parse_sexp`. Here's a
a big hunk o' data to be encoded as a single sexp in a file. One way
to handle this situation is to get the file size, dynamically allocate
a buffer big enought to hold it, and then use `parse_sexp`. Here's a
minimal example (error checking omitted):

```
Expand Down Expand Up @@ -159,22 +184,27 @@ looks something like this:

## Windows users

Please look in the win32/ subdirectory. Note that as of 9/2013, this has not
been looked at nor tested in a number of years. If you try to use it and find
it broken, fixes and updates to bring it up to speed with modern Windows
development environments would be appreciated!
Please look in the win32/ subdirectory. Note that as of 9/2013, this
has not been looked at nor tested in a number of years. If you try to
use it and find it broken, fixes and updates to bring it up to speed
with modern Windows development environments would be appreciated!

## Credits

The library is by Matt Sottile. Steve James of Linux Labs has contributed bug
fixes and features while developing for the related Supermon project. Sung-Eun
Choi and Paul Ruth have contributed many bug reports as the library has grown.
Erik Hendriks contributed the malloc debugging tools now used when building
with the -D_DEBUG_MALLOCS_ option. Brad Green contributed code (in win32/)
and testing for the Windows Visual Studio build target. Others who have
The library is by Matt Sottile. Steve James of Linux Labs has
contributed bug fixes and features while developing for the related
Supermon project. Sung-Eun Choi and Paul Ruth have contributed many
bug reports as the library has grown. Erik Hendriks contributed the
malloc debugging tools now used when building with the
-D_DEBUG_MALLOCS_ option. Brad Green contributed code (in win32/) and
testing for the Windows Visual Studio build target. Others who have
contributed can be found in the Github repository contributor list.

### Funding acknowledgement

This work was funded by the Department of Energy, Office of Science. The original development was performed at the Los Alamos National Laboratory between 2002 and 2007. It is currently maintained independently of any funding source as a service to the community (plus, it's fun to work on).
This work was funded by the Department of Energy, Office of
Science. The original development was performed at the Los Alamos
National Laboratory between 2002 and 2007. It is currently maintained
independently of any funding source as a service to the community
(plus, it's fun to work on).

0 comments on commit 95e4b34

Please sign in to comment.