ceptr
|
Semantic trees are the basic data building block for ceptr. More...
Files | |
file | label.c |
Implementation of label tabels for semantic reference to parts of semantic trees. | |
file | label.h |
Label tables map human readable text strings to parts of semantic trees. | |
file | mtree.c |
semantic tree matrix implementation | |
file | mtree.h |
semantic tree matrix header file `` | |
file | tree.c |
semantic tree pointer implementation | |
file | tree.h |
semantic trees header file | |
Macros | |
#define | TREE_CHILDREN_BLOCK 5 |
#define | TREE_PATH_TERMINATOR 0xFFFFFFFF |
#define | _t_new(p, sy, su, s) __t_new(p,sy,su,s,0) |
#define | _t_newc(parent, symbol, c) __t_newc(parent,symbol,c,0) |
#define | _t_newi(p, sy, su) __t_newi(p,sy,su,0) |
#define | _t_newi64(p, sy, su) __t_newi64(p,sy,su,0) |
#define | _t_news(parent, symbol, surface) __t_news(parent,symbol,surface,0) |
#define | _t_new_str(parent, symbol, str) __t_new_str(parent,symbol,str,0) |
#define | _t_newr(p, s) __t_newr(p,s,0) |
#define | _t_fill_template(t, i) __t_fill_template(t,i,false) |
#define | _t_find(t, sym) __t_find(t,sym,1) |
#define | DO_KIDS(t, x) {int i,_c=_t_children(t);for(i=1;i<=_c;i++){x;}} |
#define | root_check(c) if (c->structure.parent != 0) {raise_error("can't add a node that isn't a root!");} |
Functions | |
T * | __t_new (T *t, Symbol symbol, void *surface, size_t size, bool is_run_node) |
T * | __t_newc (T *t, Symbol symbol, char c, bool is_run_node) |
T * | __t_newi (T *parent, Symbol symbol, int surface, bool is_run_node) |
T * | __t_newi64 (T *parent, Symbol symbol, long surface, bool is_run_node) |
T * | __t_news (T *parent, Symbol symbol, SemanticID surface, bool is_run_node) |
T * | _t_newt (T *parent, Symbol symbol, T *t) |
T * | __t_new_str (T *parent, Symbol symbol, char *str, bool is_run_node) |
T * | _t_new_root (Symbol symbol) |
T * | __t_newr (T *parent, Symbol symbol, bool is_run_node) |
T * | _t_new_receptor (T *parent, Symbol symbol, Receptor *r) |
T * | _t_new_scape (T *parent, Symbol symbol, Scape *s) |
T * | _t_new_cptr (T *parent, Symbol symbol, void *s) |
T * | _t_newp (T *parent, Symbol symbol, Process surface) |
void | _t_add (T *t, T *c) |
void | _t_detach_by_ptr (T *t, T *c) |
T * | _t_detach_by_idx (T *t, int i) |
void | _t_replace (T *t, int i, T *r) |
void | _t_replace_node (T *t, T *r) |
T * | _t_swap (T *t, int i, T *r) |
void | _t_insert_at (T *t, int *path, T *i) |
void | _t_morph (T *dst, T *src) |
void | __t_morph (T *t, Symbol s, void *surface, size_t length, int allocate) |
void | __t_free_children (T *t) |
void | __t_free (T *t) |
void | _t_free (T *t) |
T * | _t_clone (T *t) |
T * | _t_rclone (T *t) |
T * | _t_build (SemTable *sem, T *t,...) |
T * | _t_build2 (SemTable *sem, T *t,...) |
T * | __t_tokenize (char *s) |
T * | _t_parse (SemTable *sem, T *parent, char *s,...) |
bool | __t_fill_template (T *template, T *items, bool as_run_node) |
int | _t_children (T *t) |
void * | _t_surface (T *t) |
Symbol | _t_symbol (T *t) |
size_t | _t_size (T *t) |
T * | _t_parent (T *t) |
T * | _t_child (T *t, int i) |
T * | _t_root (T *t) |
T * | _t_next_sibling (T *t) |
int | _t_node_index (T *t) |
T * | __t_find (T *t, Symbol sym, int start_child) |
int | _t_path_equal (int *p1, int *p2) |
int | _t_path_depth (int *p) |
void | _t_pathcpy (int *dst_p, int *src_p) |
T * | _t_get (T *t, int *p) |
T * | _t_getv (T *t,...) |
int * | _t_get_path (T *t) |
void * | _t_get_surface (T *t, int *p) |
char * | _t_sprint_path (int *fp, char *buf) |
T * | _t_path_walk (T *t, int **pathP, int *lenP) |
TreeHash | _t_hash (SemTable *sem, T *t) |
int | _t_hash_equal (TreeHash h1, TreeHash h2) |
UUIDt | __uuid_gen () |
int | __uuid_equal (UUIDt *u1, UUIDt *u2) |
size_t | __t_serialize (SemTable *sem, T *t, void **bufferP, size_t offset, size_t current_size, int compact) |
void | _t_serialize (SemTable *sem, T *t, void **surfaceP, size_t *sizeP) |
T * | _t_unserialize (SemTable *sem, void **surfaceP, size_t *lengthP, T *t) |
char * | _t2rawjson (SemTable *sem, T *t, int level, char *buf) |
char * | _t2json (SemTable *sem, T *t, int level, char *buf) |
int | _t_write (SemTable *sem, T *t, Stream *stream) |
Semantic trees are the basic data building block for ceptr.
Everything in ceptr is built out of semantic trees. In ceptr all data is assumed to be meaningfull, not just structured.
replace SLOTS in a template with the replacement values from links in a SEMANTIC_MAP tree ;
[in,out] | template | the tree with SLOTs to be filled |
[in] | sem_map | mappings used to fill the template |
Examples (from test suite):
T* __t_find | ( | T * | t, |
SemanticID | sym, | ||
int | start_child | ||
) |
search the children of a tree for symbol matching sym
[in] | t | the tree |
[in] | sym | the SemanticID to search for |
[in] | start_child | index of the child at which to start the search |
Convert the surface of a node
Frees the original surface value if it was allocated.
[in] | t | Node to be morphed |
[in] | s | Symbol to change the surface to |
[in] | surface | data to copy into the surface |
[in] | size | of data |
[in] | allocate | boolean to know whether to allocate surface or copy the surface as an int |
Examples (from test suite):
Create a new tree node
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | pointer to node's data |
[in] | size | size in bytes of the surface |
Create a new tree node with a cstring surface
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | string value to store in the surface |
Create a new tree node with an char surface
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | char value to store in the surface |
Create a new tree node with an integer surface
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | integer value to store in the surface |
Create a new tree node with an long surface
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | long integer value to store in the surface |
T* __t_news | ( | T * | parent, |
Symbol | symbol, | ||
SemanticID | surface, | ||
bool | is_run_node | ||
) |
Create a new tree node with a SemanticID surface
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | semanticID value to store in the surface |
size_t __t_serialize | ( | SemTable * | sem, |
T * | t, | ||
void ** | bufferP, | ||
size_t | offset, | ||
size_t | current_size, | ||
int | compact | ||
) |
Serialize a tree by recursive descent.
[in] | d | definitions |
[in] | t | tree to be serialized |
[in] | bufferP | a pointer to a malloced ptr of "current_size" which will be realloced if serialized tree is bigger than initial buffer allocation. |
[in] | offset | current offset into buffer at which to put serialized data |
[in] | current_size | size of buffer |
[in] | compact | boolean to indicate whether to add in extra information |
dump tree in JSON format
[in] | sem | the semantic context |
[in] | t | the tree to dump |
[in] | level | current level used for recursion (call with 0) |
[in,out] | buf | buffer to dump into |
Examples (from test suite):
dump tree in raw JSON format
[in] | sem | the semantic context |
[in] | t | the tree to dump |
[in] | level | current level used for recursion (call with 0) |
[in,out] | buf | buffer to dump into |
Examples (from test suite):
helper for building trees in c
[in] | sem | current semantic contexts |
[in] | parent | the tree to add the built tree onto (can be NULL) |
[in] | ... | varargs directing the building of the tree. See examples |
another helper for building trees in c
[in] | sem | current semantic contexts |
[in] | parent | the tree to add the built tree onto (can be NULL) |
[in] | ... | varargs directing the building of the tree. See examples |
int _t_children | ( | T * | t | ) |
make a copy of a tree
[in] | t | tree to clone |
Examples (from test suite):
Detatch the specified child from a node and return it
[in] | t | node to detach from |
[in] | i | index of the child to detach |
Examples (from test suite):
void _t_free | ( | T * | t | ) |
get a node by path
[in] | t | the tree to search |
[in] | p | the path to search for |
Examples (from test suite):
int* _t_get_path | ( | T * | t | ) |
return the tree path of a given node
this function allocates a buffer to hold a path of the given node which it calculates by walkinga back up the tree
[in] | t | tree node |
Examples (from test suite):
void* _t_get_surface | ( | T * | t, |
int * | p | ||
) |
get the surface of a node by path
[in] | t | the tree to search |
[in] | p | the path to search for |
Examples (from test suite):
get a node by path using variable arguments.
[in] | t | the tree to search |
note: the last argument MUST be TREE_PATH_TERMINATOR
Examples (from test suite):
reduce a tree to a hash value
[in] | symbols | declarations of symbols |
[in] | structures | definitions of structures |
[in] | t | the tree to hash |
Examples (from test suite):
int _t_hash_equal | ( | TreeHash | h1, |
TreeHash | h2 | ||
) |
Insert a tree at a given tree path position
[in] | t | tree on which to operate |
[in] | p | path to position in tree to inesert |
[in] | i | tree to insert |
Examples (from test suite):
Convert the surface of one node to that of another
Frees the original surface value if it was allocated.
[in] | dst | Node to be morphed |
[in] | src | Node type that dst should be morephed to |
Examples (from test suite):
Create a new tree node with a stream as it's surface
when cleaning up we'll need to know that this is a stream
[in] | parent | parent node for the node to be created. |
[in] | symbol | semantic symbol for the node to be create |
[in] | s | stream |
Examples (from test suite):
Create a new tree node with a receptor as it's surface
this is just like _t_newt except that it uses a different flag because when cleaning up we'll need to know that this is a full receptor, not just a plain tree
[in] | parent | parent node for the node to be created. |
[in] | symbol | semantic symbol for the node to be create |
[in] | r | receptor |
Examples (from test suite):
Create a new tree node with a scape as it's surface
when cleaning up we'll need to know that this is a scape
[in] | parent | parent node for the node to be created. |
[in] | symbol | semantic symbol for the node to be create |
[in] | s | scape |
Examples (from test suite):
Create a new tree node with a tree as it's surface
[in] | parent | parent node for the node to be created. Can be 0 if this is a root node |
[in] | symbol | semantic symbol for the node to be create |
[in] | surface | pointer to tree to store as an orthogonal tree in the surface |
int _t_node_index | ( | T * | t | ) |
int _t_path_depth | ( | int * | p | ) |
return the depth of a given path
[in] | p | path |
Examples (from test suite):
int _t_path_equal | ( | int * | p1, |
int * | p2 | ||
) |
compare equality of two paths
[in] | p1 | first path |
[in] | p2 | second path |
Examples (from test suite):
walk a tree using a path as a "cursor"
the initial call to _t_path_walk can pass in NULL as the pointer, in which case the routine will allocate a buffer of size indicated in *lenP which should be a multiple of sizeof(int). Subsequent calls expect *lenP to be the current size of the buffer which will be reallocated if needed.
[in] | t | the tree to walk |
[in,out] | pathP | the pointer to the path cursor to walk from (allocates buffer if non provided) |
[in,out] | lenP | the path buffer size (used to calculate whether a realloc is needed) |
Examples (from test suite):
void _t_pathcpy | ( | int * | dst_p, |
int * | src_p | ||
) |
copy a path
[in,out] | dst_p | pointer to buffer holding destination path |
[in] | src_p | path |
Examples (from test suite):
Replace the specified child with the given node.
[in] | t | parent node on which to operate |
[in] | i | index to child be replaced |
[in] | r | node to replace |
Examples (from test suite):
Replace the a node with the given node.
[in] | t | node to be replaced |
[in] | r | node to replace |
Examples (from test suite):
Serialize a tree.
[in] | d | definitions |
[in] | t | tree to be serialized |
[in,out] | surfaceP | a pointer to a buffer that will be malloced |
[in,out] | lengthP | the serialized length of the tree |
Examples (from test suite):
size_t _t_size | ( | T * | t | ) |
char* _t_sprint_path | ( | int * | fp, |
char * | buf | ||
) |
print a path to a string
[in] | p | the path to print |
[in,out] | buf | buffer to copy the string text to |
Examples (from test suite):
void* _t_surface | ( | T * | t | ) |
Swap out the specified child for the given node.
[in] | t | input node on which to operate |
[in] | i | index to child be replaced |
[in] | r | node to replace |
Examples (from test suite):