/Expression-Translator

Infix to Prefix and Infix to Postfix conversion

Primary LanguageC++

Expression Translator:
	Infix to Postfix
	Infix to Prefix

[As a classwork of Compiler Design Course - Spring 2017]

Constraints:
    1) Each number should be a digit between 0-9.
    2) Only addition(+), subtraction(-), multiplication(*) and division(/) is allowed.
    3) Parenthesis of this form "()" is allowed.
    4) An operator is required between "()" and another operand
    5) Spaces in input will be removed.

Details of Production:

Infix to Postfix:

expr -> term rest
term -> factor factor_rest
rest -> + factor print(+) rest
        - factor print(-) rest
factor_rest ->  * factor print(*) factor_rest
                / factor print(*) factor_rest
factor -> digit | (expr)
digit -> 0|1|2|.....|9 print digit

--------------------------------------

Infix to Prefix:

expr -> term rest
term -> factor factor_rest
rest -> + factor rest print(+)
        - factor rest print(-)
factor_rest ->  * factor factor_rest print(*)
                / factor factor_rest print(*)
factor -> digit | (expr)
digit -> 0|1|2|.....|9 print digit

Note: print the reverse order of the prefix string