-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj.h
46 lines (39 loc) · 744 Bytes
/
obj.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
// obj
#ifndef INFIX_OBJ_H_
#define INFIX_OBJ_H_
#include <string>
using namespace std;
typedef enum {
TYPE_OP,
TYPE_NUM,
} Objtype;
class Obj {
friend class parse;
Objtype type;
union {
int64_t num;
struct {
char op;
int prec;
};
};
Obj *rchild;
Obj *lchild;
public:
Obj(int);
Obj(char *);
~Obj();
bool isValid();
string toStr();
string *prefix();
string *postfix(); // string as postfix
string *infix(); // string as infix
string *tree_print(); // string as infix
void prefix(string *);
void postfix(string *); // string as postfix
void infix(string *); // string as infix
void tree_print(string *);
char *instr(); // returns x86 instruction
int64_t eval(); // evaluate tree
};
#endif // INFIX_OBJ_H