TaPAS  0.2
ccl-parse-tree.h
Go to the documentation of this file.
1 /*
2  * ccl-parse-tree.h -- A generic parse tree
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
22 #ifndef __CCL_PARSE_TREE_H__
23 # define __CCL_PARSE_TREE_H__
24 
25 # include <ccl/ccl-common.h>
26 # include <ccl/ccl-string.h>
27 
28 BEGIN_C_DECLS
29 
34 
42  int int_value;
43 
47  double flt_value;
48 
52  char *string_value;
53 
58 };
59 
69 
87 
92 };
93 
98 
103 
112  int node_type;
113 
118  const char *node_type_string;
119 
125 
132 
136  int line;
137 
142  const char *filename;
143 
148 
154 
161 };
162 
183 extern ccl_parse_tree *
184 ccl_parse_tree_create (int type, const char *type_string,
185  ccl_parse_tree_value_type vtype, int line,
186  const char *filename, ccl_parse_tree *child,
187  ccl_parse_tree *next, ccl_parse_tree *container);
188 
194 extern int
196 
207 extern void
209 
219 extern void
221 
230 extern void
232 
241 extern ccl_parse_tree *
243 
261 extern ccl_parse_tree *
263 
264 END_C_DECLS
265 
266 #endif /* ! __CCL_PARSE_TREE_H__ */
267 
void ccl_parse_tree_delete_node(ccl_parse_tree *t)
Deletes the node t.
Possible values that can decorate a node.
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.
enum ccl_parse_tree_value_type_enum ccl_parse_tree_value_type
Enum that indicates the kind of data that decorates a node.
int ccl_parse_tree_count_siblings(ccl_parse_tree *t)
Returns the number of siblings of the node t.
An integer value stored in the int_value field of a ccl_parse_tree_value.
ccl_parse_tree * ccl_parse_tree_duplicate(ccl_parse_tree *t, ccl_parse_tree **cont)
Duplicate the tree t.
const char * filename
Name of the &quot;file&quot; from which this tree has been read. This field can indicates something else than a...
ccl_ustring id_value
A unique string (not deletable)
int line
Line of the &quot;file&quot; where this tree starts.
No data is attached to the node.
A string value stored in the string_value field of a ccl_parse_tree_value.
ccl_parse_tree * next_in_container
Pointer to the next node the global storage list. This list is used to collect all nodes created duri...
Structure encoding of a parse-tree node.
ccl_parse_tree_value value
A value that decorates this. This value is taken from the union ccl_parse_tree_value according to the...
ccl_parse_tree_value_type_enum
Enum that indicates the kind of data that decorates a node.
int int_value
An integer value.
A floating-point value stored in the flt_value field of a ccl_parse_tree_value.
int node_type
An integer indicating the kind of the node e.g. the name of the non-terminal that generates the sub-t...
Some useful and common macros.
ccl_parse_tree * ccl_parse_tree_reverse_siblings(ccl_parse_tree *t)
Reverses the list of siblings starting at the node t.
Module gathering routines frequently used for the manipulation of string.
char * ccl_ustring
Alias type for strings that are stored in an internal dictionary and then can be used as identifiers ...
Definition: ccl-string.h:34
const char * node_type_string
A human-readable string of the node_type field. Mainly for debugging purposes.
ccl_parse_tree * child
Pointer to the first child of the node (NULL for leaves).
void ccl_parse_tree_delete_tree(ccl_parse_tree *t)
Deletes the tree t and its siblings.
ccl_parse_tree * next
Pointer to the next sibling of the node in the sibling list of the parent node.
char * string_value
An allocated string that must be freed when the tree is deleted.
void ccl_parse_tree_delete_container(ccl_parse_tree *t)
Deletes the nodes in the list t.
double flt_value
A floating point value.
An indentifier value stored in the id_value field of a ccl_parse_tree_value.
ccl_parse_tree_value_type value_type
Field indicating what type of data is stored into the value field.