-
Notifications
You must be signed in to change notification settings - Fork 1
/
syntaxtree.h
41 lines (36 loc) · 1.01 KB
/
syntaxtree.h
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
32
33
34
35
36
37
38
39
40
41
#ifndef _SYNTAXTREE_H_
#define _SYNTAXTREE_H_
#include "wordtype.h"
#include <stdio.h>
#include <stdlib.h>
#define EMPTY 0
#define SYNTAX 1
#define TYPEINT 2
#define TYPEFLOAT 3
#define TYPESTRING 4
#define OTHER_TYPE 5
#define OTHER 6
struct node {
int type;
int line;
char *name;
union {
int intvalue;
float floatvalue;
char *stringvalue;
} lexical_value;
struct node *rbro_node;
struct node *lson_node;
};
struct node *CreateNode(int type, char *name, struct WordType *word);
struct node *InitTree(char *name, int line, struct node *lnode);
void BuildTrees(struct node **Nodes, int count);
void SetLine(struct node *Node, int line);
void BuildlTree(struct node *Node, struct node *ltree);
void BuildrTree(struct node *Node, struct node *rtree);
void PrintTree(struct node *Node, int spaceNum);
int GetLine(struct node *Node);
char *GetIDName(struct node *Node);
int GetIntValue(struct node *Node);
float GetFloatValue(struct node *Node);
#endif // !_SYNTAXTREE_H_