-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoderunner.h
60 lines (49 loc) · 1.56 KB
/
coderunner.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
#ifndef BASIC_INTERPRETER_CODERUNNER_H
#define BASIC_INTERPRETER_CODERUNNER_H
#include "linecode.h"
#include "Vector.h"
#include <fstream>
//typedef enum{INTERACTION,STORATION,EXECUTION} Mode;
typedef enum{QUIT_ORDER,NORMAL_ORDER,BASIC_CODE} InputType;
#ifndef Execflag
#define Execflag bool
#endif
#ifndef SUCCEED
#define SUCCEED true
#endif
#ifndef FAIL
#define FAIL false
#endif
class Coderunner{
private:
Vector<Linecode> codes;
Vector<NamedVar> vars;
Rank currentLine;
protected:
void writeToFile(const string &name);
void runCode(const Linecode &code);
void assignVar(const Linecode &code);
void printExpression(const Linecode &code);
void inputValue(const Linecode &code) noexcept;
void jumpto(const Linecode &code);
void conditionCtrl(const Linecode &code);
void judgeCondition(const string &expression,Vector<NamedVar> &vars,bool &result);
public:
Coderunner();
~Coderunner(){}
void run();
void runCodes();
void listCodes() noexcept ;
void runFile(const string &filename);
void expressWelcome()noexcept{cout<<"Welcome to BASIC!\n";}
void loadfromFile(const string &filename);
InputType processOrder(const string &lineofcode);
};
//typedef enum {} ExceptType;
struct Exception{
//ExceptType type;
string message;
Exception(const string &s):message(s){}
string what() const {return message;}
};
#endif //BASIC_INTERPRETER_CODERUNNER_H