exfmt v0.0.0 Exfmt.AST.Infix

Handling the conversion of infix operators to Algebgra.

We need to be especially careful when rendering infix operators because we may need to render them differently depending on what the parent call is.

For example, if we had the AST {:*, [], [{:+, [] [1, 2}, 3]} we might nievely render it like so:

1 + 2 * 3

However :* binds more tightly than :+, so it should actually be rendered with parens like so:

(1 + 2) * 3

Failure to do render with parens results in the :* and :+ operators to swap positions in the AST.

Summary

Functions

A compile time list of all the infix operator atoms

Determine whether an infix operator is to be wrapped in parens in order to render correctly

Functions

infix_ops() (macro)
infix_ops(term) :: [atom]

A compile time list of all the infix operator atoms.

wrap?(arg1, side, ctx)

Determine whether an infix operator is to be wrapped in parens in order to render correctly.