Infix to Postfix and unary/binary operators
Posted
by Jaapjan
on Stack Overflow
See other posts from Stack Overflow
or by Jaapjan
Published on 2010-03-12T10:06:15Z
Indexed on
2010/03/12
10:07 UTC
Read the original article
Hit count: 370
I have a piece of code that converts an infix expression to an expression tree in memory. This works just fine. There's just one small trouble. I just connect work out how to involve the unary operators correctly (the right associative ones).
With the following infix expression :
+1 + +2 - -3 - -4
I would expect an RPN of:
1+2++3-4--
Yet, none of the online infix-post converters I can find handle this example in the way I would expect. Does anyone have a clear explanation of handling right associative operators, specifically the binary ones that can be mistaken for the unary ones?
© Stack Overflow or respective owner