A system has a notation that would require writing an expression like (A+B)*C
as #MUL(#ADD(A,B),C)
. Is there already an algorithm to do this kind of notation conversion so users can enter in a more conventional way?
In other words an algorithm to convert from infix -> my notation. First issue is I don't know an exact name for my notation... it's similar to reverse-polish but not quite. Every operator is encoded as a function taking arguments.
Shunting-yard algorithm can be used to parse infix notation.
Here's some Lisp that attempts the infix -> prefix transformation. It could serve as a useful starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With