-
Notifications
You must be signed in to change notification settings - Fork 0
/
statement.h
66 lines (52 loc) · 1.15 KB
/
statement.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 STATEMENT_H
#define STATEMENT_H
#include <bits/stdc++.h>
#include "exp.h"
enum StatementType
{
LET,
PRINT,
INPUT,
IF,
GOTO,
ENDSTATE,
REM
};
class Statement
{
public:
Statement() = default;
Statement(int stmtNum,std::string stmt);
virtual ~Statement() = default;
virtual void execute(RuntimeState & rState) = 0;
virtual std::string toString();
int getStatementNum() const;
protected:
int statementNumber;
std::string statementText;
StatementType type;
};
class LetStatement : public Statement
{
public:
LetStatement();
LetStatement(int stmtNum, std::string var, Expression *exp, std::string stmt);
~LetStatement() override;
void execute(RuntimeState & rState) override;
std::string toString() override;
private:
std::string variable;
Expression *exp;
};
class PrintStatement : public Statement
{
public:
PrintStatement();
PrintStatement(int stmtNum, Expression *exp, std::string stmt);
~PrintStatement() override;
void execute(RuntimeState & rState) override;
std::string toString() override;
private:
Expression *exp;
};
#endif // STATEMENT_H