-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval-upmc.h
More file actions
57 lines (37 loc) · 1.15 KB
/
Copy patheval-upmc.h
File metadata and controls
57 lines (37 loc) · 1.15 KB
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
/*
* Author : Roven Gabriel <nevor@nevor.net>
* student at Université Pierre et Marie Curie, Paris, France
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* Utility routines.
*/
#ifndef EVAL_UPMC_H
#define EVAL_UPMC_H
enum kind_en { Nothing, Variable, Plus, Minus, Mult, Div, Integer };
union value {
int num; // for Integer
char* var;
};
struct ast_st {
enum kind_en kind;
struct ast_st* left;
struct ast_st* right;
union value value;
};
struct ast_st* new_node(void);
struct ast_st* make_integer(int value);
struct ast_st* make_variable(char* name);
struct ast_st* make_plus(struct ast_st* left, struct ast_st* right);
struct ast_st* make_minus(struct ast_st* left, struct ast_st* right);
struct ast_st* make_mult(struct ast_st* left, struct ast_st* right);
struct ast_st* make_div(struct ast_st* left, struct ast_st* right);
struct ast_st*
parseStr(const char * str);
int
evalArith(struct ast_st* ast);
void
getLeftRightValue(struct ast_st* ast, int* left_value, int* right_value);
struct ast_st*
simplifyAst(struct ast_st* ast);
#endif