-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththegerk_expression_setup.cpp
33 lines (28 loc) · 1.16 KB
/
thegerk_expression_setup.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
#include 'thegerk.h'
#include 'thegerk_expression.cpp'
#include 'thegerk_operand.cpp'
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
void expression::setup(const string& input, const vector<variable>& vars)
{
//Find last oppeartion to do and split apart string around.
const int seperator = locationOfLastOperation(input);
//split into substrings and feed to operands
right.setup(input.substr(seperator + 1, string::npos), vars);
if(!isUnary(input[separtor])) //if it is unary don't set up left side
left.setup(input.substr(0, seperator), vars);
//set up operator
Operator = input[seperator];
//look at what is in the left string, is it empty, does it just have parentheses?
if(isUnary(input[seperator]))
{
cout << "Remove me for final program!\nI'm located in: void expression::setup(const string& input, const vector<variable>& vars)" << endl;
cout << "Full string: \"" << input << '\"' << endl;
cout << "Left string: \"" << input.substr(0, seperator) << '\"' << endl;
cout << "Opeartor: " << input[seperator] << endl;
cout << "Right string: \"" < input.substr(seperator + 1, string::npos) << '\"' << endl;
pause();
}
}