Small, Fast S-Expression Library
|
A collection of useful operations to perform on s-expressions. More...
#include "sexp.h"
Go to the source code of this file.
Macros | |
#define | hd_sexp(s) ((s)->list) |
#define | tl_sexp(s) ((s)->list->next) |
#define | next_sexp(s) ((s)->next) |
#define | reset_pcont(c) ((c)->lastPos = NULL) |
Functions | |
sexp_t * | find_sexp (const char *name, sexp_t *start) |
sexp_t * | bfs_find_sexp (const char *name, sexp_t *start) |
int | sexp_list_length (const sexp_t *sx) |
sexp_t * | copy_sexp (const sexp_t *sx) |
A collection of useful operations to perform on s-expressions.
A set of routines for operating on s-expressions.
#define hd_sexp | ( | s | ) | ((s)->list) |
Return the head of a list s by reference, not copy.
#define next_sexp | ( | s | ) | ((s)->next) |
Return the element following the argument s.
#define reset_pcont | ( | c | ) | ((c)->lastPos = NULL) |
Reset the continuation c by setting the lastPos
pointer to NULL
.
#define tl_sexp | ( | s | ) | ((s)->list->next) |
Return the tail of a list s by reference, not copy.
Breadth first search for s-expressions. Depth first search will find the first occurance of a string in an s-expression by basically finding the earliest occurance in the string representation of the expression itself. Breadth first search will find the first occurance of a string in relation to the structure of the expression itself (IE: the instance with the lowest depth will be found).
name | Value to search for. |
start | Root element of the s-expression to search from. |
Copy an s-expression. This is a deep copy - so the resulting s-expression shares no pointers with the original. The new one can be changed without damaging the contents of the original.
sx | S-expression to copy. |
Find an atom in a sexpression data structure and return a pointer to it. Return NULL if the string doesn't occur anywhere as an atom. This is a depth-first search algorithm.
name | Value to search for. |
start | Root element of the s-expression to search from. |
int sexp_list_length | ( | const sexp_t * | sx | ) |
Given an s-expression, determine the length of the list that it encodes. A null expression has length 0. An atom has length 1. A list has length equal to the number of sexp_t elements from the list head to the end of the ->next linked list from that point.
sx | S-expression input. |