Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. bool expressionFound(istringstream &ss, Node &root)
  2. {
  3.     int leaves;
  4.     char op;
  5.     if (ss.peek() >= 48 && ss.peek() <= 71)
  6.     {
  7.         root.tag = INT_ONLY;
  8.         ss >> leaves;
  9.         root.intValue = leaves;
  10.     }
  11.     else if (ss.peek() == '(')
  12.     {
  13.         root.left = new Node;
  14.         expressionFound(ss, *root.left);
  15.         ss >> op;
  16.         root.tag = SUB_NODE;
  17.         root.op = op;
  18.         root.right = new Node;
  19.         if (expressionFound(ss, *root.right))
  20.         {
  21.             if (ss.peek() == ')')
  22.             {
  23.                 ss >> op;
  24.             }
  25.         }
  26.     }
  27.     return false;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement