-
Notifications
You must be signed in to change notification settings - Fork 0
/
value.h
66 lines (58 loc) · 2.16 KB
/
value.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
60
61
62
63
64
65
66
#ifndef VALUE_H
#define VALUE_H
#include <QString>
#include <QtMath>
#include "exceptions.h"
class Value {
public:
Value();
virtual QString type() const = 0;
virtual QString toString() const = 0;
virtual ~Value();
virtual const Value* operator+(const Value& other) const = 0;
virtual const Value* operator-(const Value& other) const = 0;
virtual const Value* operator*(const Value& other) const = 0;
virtual const Value* operator/(const Value& other) const = 0;
virtual const Value* pow(const Value& other) const = 0;
virtual bool operator<(const Value& other) const = 0;
virtual bool operator>(const Value& other) const = 0;
virtual bool operator==(const Value& other) const = 0;
virtual QString ast() const = 0;
};
class IntegerValue: public Value {
private:
int value;
public:
IntegerValue(int v);
QString type() const override;
QString toString() const override;
const Value* operator+(const Value& other) const override;
const Value* operator-(const Value& other) const override;
const Value* operator*(const Value& other) const override;
const Value* operator/(const Value& other) const override;
const Value* pow(const Value& other) const override;
bool operator<(const Value& other) const override;
bool operator>(const Value& other) const override;
bool operator==(const Value& other) const override;
QString ast() const override;
~IntegerValue();
};
class StringValue: public Value {
private:
QString value;
public:
StringValue(QString v);
QString type() const override;
QString toString() const override;
const Value* operator+(const Value& other) const override;
const Value* operator-(const Value& other) const override;
const Value* operator*(const Value& other) const override;
const Value* operator/(const Value& other) const override;
const Value* pow(const Value& other) const override;
bool operator<(const Value& other) const override;
bool operator>(const Value& other) const override;
bool operator==(const Value& other) const override;
QString ast() const override;
~StringValue();
};
#endif // VALUE_H