1 | /* |
---|
2 | node.h - all the declarations we need to create, put, get, and print |
---|
3 | the nodes of an annotated parse tree. The tree is stored |
---|
4 | as a collection of nodes, with each node containing |
---|
5 | pointers to a list of annotations associated with the |
---|
6 | node and a list of children (for operator nodes). |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef node_h |
---|
10 | #define node_h |
---|
11 | |
---|
12 | typedef struct annot annot_t; |
---|
13 | typedef struct node node_t; |
---|
14 | |
---|
15 | /* this is the implementation of an annotation to a data node */ |
---|
16 | struct annot { |
---|
17 | MP_AnnotType_t type; /* type of the annotation */ |
---|
18 | MP_DictTag_t dtag; /* dictionary in which it is defined */ |
---|
19 | MP_AnnotFlags_t flags; /* flags modifying its meaning */ |
---|
20 | node_t *node; /* ptr to MP tree if valuated */ |
---|
21 | annot_t *next; /* the next annotation in the list */ |
---|
22 | }; |
---|
23 | |
---|
24 | |
---|
25 | /* this is the implementation of a data node */ |
---|
26 | struct node { |
---|
27 | MP_NodeType_t type; /* type of the data field: MP basic type */ |
---|
28 | MP_NumAnnot_t num_annots; |
---|
29 | MP_NumChild_t num_children; /* type == operator : number of children */ |
---|
30 | /* type == raw : # bytes of data */ |
---|
31 | MP_DictTag_t dtag; |
---|
32 | char *data; /* generic pointer to the node's "value" */ |
---|
33 | char *aux; /* generic pointer for "data objects" */ |
---|
34 | /* assumed to be an MP-defined object */ |
---|
35 | annot_t *annot_list; /* the head of the annotation list */ |
---|
36 | node_t **child_list; /* dynamic array of ptrs to child nodes */ |
---|
37 | }; |
---|
38 | |
---|
39 | /* The routines that are available externally. */ |
---|
40 | void print_annot(); |
---|
41 | int print_node(); |
---|
42 | annot_t *m_get_annot(); |
---|
43 | node_t *m_get_node(); |
---|
44 | void free_tree(); |
---|
45 | void free_label_table(); |
---|
46 | |
---|
47 | #endif |
---|