Hi,
I am wondering thy elixir added parens at the end not just simply changed \* to + and + to \*
Interactive Elixir (1.19.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 5 * 3 + 7
22
iex(2)> ast = quote do: 5 + 3 * 7
{:+, [context: Elixir, imports: [{1, Kernel}, {2, Kernel}]],
[5, {:*, [context: Elixir, imports: [{2, Kernel}]], [3, 7]}]}
iex(3)> new_ast = Macro.prewalk(ast, fn
{:+, meta, children} -> {:*, meta, children}
{:*, meta, children} -> {:+, meta, children}
other -> other
end)
{:*, [context: Elixir, imports: [{1, Kernel}, {2, Kernel}]],
[5, {:+, [context: Elixir, imports: [{2, Kernel}]], [3, 7]}]}
iex(4)> Code.eval_quoted(ast)
{26, []}
iex(5)> Code.eval_quoted(new_ast)
{50, []}
iex(6)> Macro.to_string(ast)
"5 + 3 * 7"
iex(7)> Macro.to_string(new_ast)
"5 * (3 + 7)"
iex(8)>






















