elt Struct Reference

#include <sexp.h>


Data Fields

elt_t ty
char * val
size_t val_allocated
size_t val_used
eltlist
eltnext
atom_t aty
char * bindata
size_t binlength


Detailed Description

An s-expression is represented as a linked structure of elements, where each element is either an atom or list. An atom corresponds to a string, while a list corresponds to an s-expression. The following grammar represents our definition of an s-expression:

 sexpr  ::= ( sx )
 sx     ::= atom sxtail | sexpr sxtail | 'sexpr sxtail | 'atom sxtail | NULL
 sxtail ::= sx | NULL
 atom   ::= quoted | value
 quoted ::= "ws_string"
 value  ::= nws_string
 

An atom can either be a quoted string, which is a string containing whitespace (possibly) surrounded by double quotes, or a non-whitespace string that does not require surrounding quotes. An element representing an atom will have a type of value and data stored in the val field. An element of type list represents an s-expression corresponding to sexpr in the grammar, and will have a pointer to the head of the appropriate s-expression. Details regarding these fields and their values given with the fields themselves. Notice that a single quote can appear directly before an s-expression or atom, similar to the use in LISP.


Field Documentation

atom_t aty
 

For elements that represent values, this field will specify the specific type of value that it represents. This can be used by functions to determine how this value should be printed (ie: how it should be quoted) or interpreted (ie: interpreting s-expressions that are prefixed with a tick-mark.). This value also indicates whether or not the programmer should look in the val field or bindata field for the atom data.

char* bindata
 

For elements that represent binary blobs, this field will point to a memory location where the data resides. The length of this memory blob is the next field. char* implies byte sized elements. This is only used in INLINE_BINARY parser mode. IMPORTANT NOTE: The data in this field is freed on a destroy_sexp() call, so users should copy it to memory they allocate if they wish it to persist after the sexp_t has been freed.

size_t binlength
 

The length of the data pointed at by bindata in bytes.

struct elt* list
 

If the type of the element is SEXP_LIST, this field will contain a pointer to the head element of the list.

struct elt* next
 

The next field is a pointer to the next element in the current expression. If this element is the last element in the s-expression, this field will be NULL.

elt_t ty
 

The element has a type that determines how the structure is used. If the type is SEXP_VALUE, then a programmer knows that either the val field or bindata field is meaningful dependin on the value of the aty field, and contains the data associated with this element of the s-expression. If the type is SEXP_LIST, then the list field contains a pointer to the s-expression element representing the head of the list. For each case, the field for the opposite case contains no meaningful data and using them in any way is likely to cause an error.

char* val
 

If the type of the element is SEXP_VALUE and the aty field is not SEXP_BINARY, this field will contain the actual data represented by this element.

size_t val_allocated
 

Number of bytes allocated for val.

size_t val_used
 

Number of bytes used in val (<= val_allocated).


Generated on Thu Oct 25 01:19:37 2007 for Small, Fast S-Expression Library by  doxygen 1.4.6