Parsing/RPN to infix conversion: Difference between revisions

m
mNo edit summary
Line 2,111:
prev = pop!(infix)
push!(infix, Expr(:call, Symbol(tok), prev, last))
println("Current step: $infix")
end
end
Line 2,116 ⟶ 2,117:
end
 
println("The final infix result: ", parseRPNstring("3 4 2 * 1 5 - 2 3 ^ ^ / +"), "\n")
println("The final infix result: ", parseRPNstring("1 2 + 3 4 + ^ 5 6 + ^"))
</lang>
{{output}}
<pre>
Current step: Any[:("3", + :("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
Current step: Any["3", :((("14" +* "2"), ^ :("31" +- "4")) ^ ("5" + "6"))]
Current step: Any["3", :("4" * "2"), :("1" - "5"), :("2" ^ "3")]
Current step: Any["3", :("4" * "2"), :(("1" - "5") ^ ("2" ^ "3"))]
Current step: Any["3", :(("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
Current step: Any[:("3" + ("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
The final infix result: Any[:("3" + ("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
 
Current step: Any[:("1" + "2")]
Current step: Any[:("1" + "2"), :("3" + "4")]
Current step: Any[:(("1" + "2") ^ ("3" + "4"))]
Current step: Any[:(("1" + "2") ^ ("3" + "4")), :("5" + "6")]
Current step: Any[:((("1" + "2") ^ ("3" + "4")) ^ ("5" + "6"))]
The final infix result: Any[:((("1" + "2") ^ ("3" + "4")) ^ ("5" + "6"))]
</pre>
 
4,102

edits