infix to prefix in compiler design

  c++, compiler-construction

few days ago i asked a question here about how to convert infix to prefix and someone was nice enough to answer it but they answered infix to postfix. in the book which i am using(i believe it’s a translation of modern compiler design by dick grune) it give’s the required grammers:

(1) expr -> expr + term | expr – term | term  
(2) term -> term * factor | term / factor | factor  
(3) factor -> digit | (expr)  
(4) digit -> 0 | 1 | 2 | …| 9

we are not allowed to use the stack method which is used in data structure.
infix

9-5+2

and we should get

+-952

Source: Windows Questions C++

LEAVE A COMMENT