Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. stack<Expression_Tree*> stack;
  2.  
  3. for(int i = 0; i < curr_postfix.size(); ++i) {
  4.     if(isdigit(curr_postfix[i])) {
  5.         cout << " kom till isdigit " << endl;
  6.         char c = curr_postfix[i];
  7.         int num = c;
  8.         Expression_Tree* temp = new Integer(c);
  9.         stack.push(temp);
  10.         delete temp;
  11.     }  
  12.     if(isalpha(curr_postfix[i])) {
  13.         cout << " kom till isalpha " << endl;
  14.         stringstream ss;
  15.         string s;
  16.         char str = curr_postfix[i];
  17.         ss << str;
  18.         ss >> s;
  19.         Expression_Tree* temp = new Variable(s);
  20.         stack.push(temp);
  21.         delete temp;
  22.     }
  23.     if(curr_postfix[i] == '+') {
  24.         cout << " kom till + " << endl;
  25.         Expression_Tree* left;
  26.         Expression_Tree* right;
  27.         cout << " kom till slut av + " << endl;
  28.         left = stack.top();
  29.         stack.pop();
  30.         right = stack.top();
  31.         stack.pop();
  32.         Expression_Tree* temp = new Plus(left, right);
  33.         stack.push(temp);
  34.         delete temp;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement