-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpressions.cpp
54 lines (42 loc) · 1.33 KB
/
expressions.cpp
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
/******************************************************************************
* GRIDGEN: Grid Generating Compiler
* By: Andy Stone ([email protected])
* (C) Copyright 2011 Colorado State University
*****************************************************************************/
#include "expressions.hpp"
#include <sstream>
using namespace std;
string Exp::toString() {
ostringstream ss;
switch(mCmd) {
case CMD_IF:
ss << "IF(" << mLeft->toString() << ")";
break;
case CMD_AND:
ss << "AND(" << mLeft->toString() << ", " << mRight->toString()
<< ")";
break;
case CMD_EQ:
ss << "EQ(" << mLeft->toString() << ", " << mRight->toString()
<< ")";
break;
case CMD_IDX:
ss << "IDX(" << mLeft->mCmd << ")";
break;
case CMD_CONST:
ss << "CONST(" << mLeft->mCmd << ")";
break;
case CMD_PARAM:
ss << "PARAM(" << mLeft->mCmd << ")";
break;
case CMD_MINUS:
ss << "MINUS(" << mLeft->toString() << ", " << mRight->toString()
<< ")";
break;
case CMD_PLUS:
ss << "PLUS(" << mLeft->toString() << ", " << mRight->toString()
<< ")";
break;
}
return ss.str();
}