-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.c
36 lines (33 loc) · 846 Bytes
/
common.c
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
/**
* Implements functions defined in common.h
*
* Cameron Tauxe
*
* 4 Apr, 2018
*/
#include"common.h"
//operator_to_string implementation
char* operator_to_string(OPERATOR op) {
switch (op) {
case PLUS: return PLUS_STRING;
case MINUS: return MINUS_STRING;
case TIMES: return TIMES_STRING;
case DIVIDE: return DIVIDE_STRING;
case EQ: return EQ_STRING;
case NE: return NE_STRING;
case GE: return GE_STRING;
case LE: return LE_STRING;
case GT: return GT_STRING;
case LT: return LT_STRING;
default: return UNKNOWN_OP_STRING;
}
}
//var_type_to_string implementation
char* var_type_to_string(VAR_TYPE t) {
//this is a little silly with only two types,
//but I like expandability
switch (t) {
case TYPE_INT: return INT_STRING;
default: TYPE_VOID: return VOID_STRING;
}
}