-
Notifications
You must be signed in to change notification settings - Fork 0
/
expression.h
51 lines (46 loc) · 918 Bytes
/
expression.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
#ifndef EXPRESSION_H
#define EXPRESSION_H
#include <QString>
class Expression
{
public:
Expression();
virtual ~Expression();
virtual int eval();
virtual QString expType();
};
class ConstantExp: public Expression
{
public:
ConstantExp(int v);
~ConstantExp()override;
int eval()override;
QString expType()override;
private:
int value;
};
class IdentifierExp: public Expression
{
public:
IdentifierExp(QString n,int v);
~IdentifierExp()override;
int eval()override;
QString expType()override;
private:
QString name;
int value;
};
class CompoundExp: public Expression
{
public:
CompoundExp(QString o,Expression *left=nullptr,Expression *right=nullptr);
~CompoundExp()override;
int eval()override;
QString expType()override;
private:
Expression *leftExp;
Expression *rightExp;
int value;
QString op;
};
#endif // EXPRESSION_H