-
Notifications
You must be signed in to change notification settings - Fork 1
/
ast.h
59 lines (50 loc) · 1.22 KB
/
ast.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "objects.h"
#ifndef AST_H
#define AST_H
typedef enum
{
Assign,
Assign_List,
BinOp,
Load,
Nil
} Operation;
struct ByAst_Node
{
Operation operation;
struct ByAst_Node *param1;
struct ByAst_Node *param2;
struct ByAst_Node *param3;
int test;
Data name, value;
};
// struct ByAst_Node *traverse(struct ByAst_Node *node)
// {
// switch (node->operation)
// {
// case Assign:
// return assign();
// default:
// return node->value;
// }
// }
#endif /* AST_H */
// int main()
// {
// struct ByAst_Node *head = (struct ByAst_Node *)malloc(sizeof(struct ByAst_Node));
// head->operation = Assign;
// head->param1 = (struct ByAst_Node *)malloc(sizeof(struct ByAst_Node));
// head->param1->operation = Nil;
// head->param1->param1 = NULL;
// head->param1->param2 = NULL;
// strcpy(head->param1->name.char_value, "x");
// head->param2 = (struct ByAst_Node *)malloc(sizeof(struct ByAst_Node));
// head->param2->operation = Nil;
// head->param2->param1 = NULL;
// head->param2->param2 = NULL;
// head->param2->value.int_value = 5;
// traverse(head);
// }