Expression.Eval (expression v2.1.0)
Expression.Eval is responsible for taking an abstract syntax tree (AST) as generated by Expression.Parser and evaluating it.
At a high level, an AST consists of a Keyword list with two top-level
keys, either :text or :expression.
Expression.eval!/3 will return the output for each entry in the Keyword
list. :text entries are returned as regular strings. :expression entries
are returned as typed values.
The returned value is a list containing each.
Example
iex(1)> Expression.Eval.eval!([text: "hello"], %{}) ["hello"] iex(2)> Expression.Eval.eval!([text: "hello", expression: [literal: 1]], %{}) ["hello", 1] iex(3)> Expression.Eval.eval!([ ...(3)> text: "hello", ...(3)> expression: [literal: 1], ...(3)> text: "ok", ...(3)> expression: [literal: true] ...(3)> ], %{}) ["hello", 1, "ok", true]