TaPAS  0.2
Data Structures | Typedefs | Enumerations | Functions
ccl-parse-tree.h File Reference

A generic parse tree. More...

#include <ccl/ccl-common.h>
#include <ccl/ccl-string.h>

Go to the source code of this file.

Data Structures

union  ccl_parse_tree_value_union
 Possible values that can decorate a node. More...
 
struct  ccl_parse_tree_st
 Structure encoding of a parse-tree node. More...
 

Typedefs

typedef union
ccl_parse_tree_value_union 
ccl_parse_tree_value
 Possible values that can decorate a node.
 
typedef enum
ccl_parse_tree_value_type_enum 
ccl_parse_tree_value_type
 Enum that indicates the kind of data that decorates a node.
 
typedef struct ccl_parse_tree_st ccl_parse_tree
 Type of a parse-tree node.
 

Enumerations

enum  ccl_parse_tree_value_type_enum {
  CCL_PARSE_TREE_INT,
  CCL_PARSE_TREE_FLOAT,
  CCL_PARSE_TREE_STRING,
  CCL_PARSE_TREE_IDENT,
  CCL_PARSE_TREE_EMPTY
}
 Enum that indicates the kind of data that decorates a node. More...
 

Functions

ccl_parse_treeccl_parse_tree_create (int type, const char *type_string, ccl_parse_tree_value_type vtype, int line, const char *filename, ccl_parse_tree *child, ccl_parse_tree *next, ccl_parse_tree *container)
 Creates a new node. More...
 
int ccl_parse_tree_count_siblings (ccl_parse_tree *t)
 Returns the number of siblings of the node t. More...
 
void ccl_parse_tree_delete_node (ccl_parse_tree *t)
 Deletes the node t. More...
 
void ccl_parse_tree_delete_tree (ccl_parse_tree *t)
 Deletes the tree t and its siblings. More...
 
void ccl_parse_tree_delete_container (ccl_parse_tree *t)
 Deletes the nodes in the list t. More...
 
ccl_parse_treeccl_parse_tree_reverse_siblings (ccl_parse_tree *t)
 Reverses the list of siblings starting at the node t. More...
 
ccl_parse_treeccl_parse_tree_duplicate (ccl_parse_tree *t, ccl_parse_tree **cont)
 Duplicate the tree t. More...
 

Detailed Description

A generic parse tree.

Definition in file ccl-parse-tree.h.

Enumeration Type Documentation

Enum that indicates the kind of data that decorates a node.

Enumerator
CCL_PARSE_TREE_INT 

An integer value stored in the int_value field of a ccl_parse_tree_value.

CCL_PARSE_TREE_FLOAT 

A floating-point value stored in the flt_value field of a ccl_parse_tree_value.

CCL_PARSE_TREE_STRING 

A string value stored in the string_value field of a ccl_parse_tree_value.

CCL_PARSE_TREE_IDENT 

An indentifier value stored in the id_value field of a ccl_parse_tree_value.

CCL_PARSE_TREE_EMPTY 

No data is attached to the node.

Definition at line 63 of file ccl-parse-tree.h.

Function Documentation

int ccl_parse_tree_count_siblings ( ccl_parse_tree t)

Returns the number of siblings of the node t.

Parameters
tthe node to explore
Returns
the number of siblings of the node t
ccl_parse_tree* ccl_parse_tree_create ( int  type,
const char *  type_string,
ccl_parse_tree_value_type  vtype,
int  line,
const char *  filename,
ccl_parse_tree child,
ccl_parse_tree next,
ccl_parse_tree container 
)

Creates a new node.

Parameters
typeidentifier of the kind of node (field node_type)
type_stringa human readable string describing type (field node_type_string)
vtypekind of value stored in this node (field value_type)
linestart line of the sub-tree (field line)
filenamename of the file from which comes the node (field filename)
childpointer to the first child node (field child)
nextpointer to the first sibling (field next)
containerpointer to the next node in the list of created nodes (field next_in_container)
Returns
a new node.
void ccl_parse_tree_delete_container ( ccl_parse_tree t)

Deletes the nodes in the list t.

The function deletes the list starting at t following the chaining made with the next_in_container field.

Parameters
tthe tree
void ccl_parse_tree_delete_node ( ccl_parse_tree t)

Deletes the node t.

The function releases the resources allocated to the node t. Sub-trees and siblings are not deleted. Attached values are deleted according to their value_type.

Parameters
tthe node to delete
Precondition
t != NULL
void ccl_parse_tree_delete_tree ( ccl_parse_tree t)

Deletes the tree t and its siblings.

The function deletes the tree pointed by t and deletes the siblings of t following the next chaining.

Parameters
tthe tree to delete
Precondition
t != NULL
ccl_parse_tree* ccl_parse_tree_duplicate ( ccl_parse_tree t,
ccl_parse_tree **  cont 
)

Duplicate the tree t.

The function duplicates the tree t and its sub-tree. Each value field is duplicated according to its kind of value. The filename is also duplicated but as a ccl_ustring.

If cont is not NULL then each newly created node is chained with *cont using the next_in_container field of t.

Parameters
tthe tree to duplicate
contthe address of a container list
Precondition
t != NULL
Returns
the root of the copy of t
ccl_parse_tree* ccl_parse_tree_reverse_siblings ( ccl_parse_tree t)

Reverses the list of siblings starting at the node t.

The function reverses the list starting a t following the chaining made with the next field.

Parameters
tthe tree