This is a basic implementation of the shunting-yard algorithm
in the elixir programming language. The ShuntingYard module converts infix
(algebraic) notation to postfix
(reverse-polish) notation, including dice rolling (d) and modulo (%)
operators.
iex> ShuntingYard.to_rpn("(1+2)*(3+4)")
[1, 2, "+", 3, 4, "+", "*"]
iex> ShuntingYard.to_ast("(1+2)*(3+4)")
{"*", {"+", 1, 2}, {"+", 3, 4}}Copyright (c) 2018 Kevin McAbee