title: Postfix to infix with unary/binary operators
body: <p>I am trying to make a converter from postfix to infix notation and need some help. There is already <a href="https://stackoverflow.com/questions/2431863/infix-to-postfix-and-unary-binary-operators">a question about infix-to-postfix conversion</a>, which gives an example I am failing to convert back. (Note: a minus sign is missing there!)</p>
  
  <p>The following is the output of my converter, where the 1st "column" is postfix input, the 2nd is my infix output, and the 3rd is what I probably should get(?):</p>
  
  <pre><code>2 -                      =   - 2                           =?    - 2                       true
  1 + 2 +                  =   + 1 + 2                       =?    + 1 + 2                   true
  1 + 2 + +                =   + (+ 1 + 2)                   =?    + 1 + + 2                 false
  1 + 2 + + 3 - - 4 - -    =   - (- (+ (+ 1 + 2) - 3) - 4)   =?    + 1 + + 2 - - 3 - - 4     false
  </code></pre>
  
  <p>Do you think that it is possible to solve this problem, or the last two lines are actually converted correctly? How would you write algorithm to solve this problem?</p>
  
  <p>Please, assume that more operators (not only <code>+</code> and <code>-</code>) can be set as both unary and binary, where unary operators have higher precedence than binary ones.</p>
  
  <h3>References</h3>
  
  <ol>
  <li><a href="http://www.rubyquiz.com/quiz148.html" rel="nofollow noreferrer">Ruby Quiz #148: Postfix to Infix</a>, also via <a href="http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/1fc1b43a91b6ceed" rel="nofollow noreferrer">Google Groups</a></li>
  <li><a href="http://en.literateprograms.org/Shunting_yard_algorithm_(Perl)" rel="nofollow noreferrer">Shunting-yard algorithm (C, Python, Perl) with unary operator support</a> on LiteratePrograms</li>
  </ol>