exfmt v0.2.2 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.

Link to this section 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

Link to this section Functions

Link to this macro infix_ops() (macro)
infix_ops(term) :: [atom]

A compile time list of all the infix operator atoms.

Link to this function wrap?(arg1, side, ctx)

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