-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastTree.c
More file actions
32 lines (27 loc) · 705 Bytes
/
astTree.c
File metadata and controls
32 lines (27 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stackTree.h"
TypeList createTypeList(varTypes vtype)
{
TypeList tlist = (TypeList) malloc(sizeof(struct typeList));
tlist->vtype = vtype;
tlist->next = NULL;
return tlist;
}
AstNode createAstNode(TreeNode t)
{
AstNode a = (AstNode)malloc(sizeof(struct astNode));
a->parent = NULL;
a->right = NULL;
a->child = NULL;
a->t = t->grammar_node->t;
if(a->t == 0){
a->s.term_type = t->grammar_node->s.term_type;
}
else if (a->t == 1) {
a->s.nonterm_type = t->grammar_node->s.nonterm_type;
}
strncpy(a->value, t->value, MAX_FLOAT_LEN+1);
a->globalFlg = 0;
a->line_number = t->line;
a->tlist = NULL;
return a;
}