-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdbasic.h
122 lines (94 loc) · 1.89 KB
/
dbasic.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
*
* Authors: John Jones and Russell Toris
* Version: March. 28, 2010
*/
#define COMMAND_LENGTH 80
#define VARIABLES 20
#define STRING_SIZE 255
#define VARIABLE_NAME_SIZE 20
#define INSTRUCTIONS 50
#define NTERMINATORS 10
#define NBOOLOPS 3
typedef char byte;
enum mode {
TEXT,
GRAPHICS
};
enum error {
GENERAL,
SYNTAX,
OVERFLOW,
DIVISION,
SYSTEM
};
enum arithOp {
EQUAL,
ADD,
SUBTRACT,
MULTIPLY,
DIVIDE
};
enum boolOp {
BEQUAL,
LESS,
GREATER,
LESSEQUAL,
GREATEREQUAL
};
union variableData {
int intValue;
int boolValue;
char stringValue[STRING_SIZE];
};
enum datatype {
NONE,
UNDEFINED,
INT,
STRING,
BOOLEAN
};
struct variable {
char name[VARIABLE_NAME_SIZE];
enum datatype type;
union variableData data;
};
struct instruction {
int number;
char inst[COMMAND_LENGTH];
};
char* terminators = " \0=+-*/<>";
char* boolops = "=<>";
void help();
void load(char* file);
void store(char* file);
void init_variables();
void init_program();
int variableIndex(char* variable);
void interp_command(char* command);
void read_input(char* command);
int insertCommand(int l,char* command);
void run();
void list();
void error(enum error e,char* message);
int parseInteger(char* code,int* buffer);
int parseString(char* code,char* buffer);
int parseVariable(char* code,char* buffer);
int output(char* code);
int input(char* code,enum datatype type);
int assignmentExpression(char* code);
int expression(char* code,struct variable *var);
int booleanExpression(char* code,struct variable *var);
int isTeriminator(char c);
int isBoolop(char c);
int ifthenBlock(char* code);
int whileBlock(char* code);
int gotoLine(char* code);
void sleepCode(char* code);
int orderedPair(char* code,struct variable *x,struct variable *y);
void colorCode(char* code);
void plotCode(char* code);
void lineCode(char* code);
void rectCode(char* code);
void circleCode(char* circle);
void enableInterrupts();