# `Dmn.Compiler.Box`
[🔗](https://github.com/FeeJai/BDM/blob/dmn-v0.1.0/apps/dmn/lib/dmn/compiler/box.ex#L1)

The boxed expression that a part of a unit came from: what the source map (`Dmn.Compiler.Source`) knows of a range of the
virtual source besides the element and the place in it.

Every node of the tree of a unit has a span, and the span is in a part of the source, so every node, whether it was parsed from
a text or built from the syntax of a box, can be asked for its box (`Dmn.Compiler.Source.box/2`). A part that is in no box (the
declaration of a variable, the wrapper of a unit) has none.

| Field | Is |
| ----- | -- |
| `kind` | `:literal_expression`, `:decision_table`, `:context`, `:function`, `:invocation`, `:relation`, `:list`, `:conditional`, `:filter`, `:for`, `:some` or `:every` |
| `id`, `label`, `line` | those of the box in the model (`nil` where the model has none) |
| `type_ref` | the type the box declares for its value |
| `boolean_part` | the part of the box that DMN 1.6 says MUST resolve to a boolean (10.2.1.8 to 10.2.1.10): `:if` of a conditional, `:match` of a filter, `:satisfies` of `some` and `every`, and `nil` for the others |

`boolean_part` is what the specification asks of the box, and the compiler holds the box to it: the node a box makes is marked
`boxed: true` (`Dmn.Compiler.Tree.boxed/1`), and a condition that is a value other than a boolean and `null` is `null` with an error
for the whole node (D-212 of `feel`, as the TCK has it: 1150 #003, 1151 #004 and #005, 1153 #006). The source map says which box a
part is in, and the flag in the node is what the passes of `feel`, which cannot ask the map, read.

# `kind`

```elixir
@type kind() ::
  :literal_expression
  | :decision_table
  | :context
  | :function
  | :invocation
  | :relation
  | :list
  | :conditional
  | :filter
  | :for
  | :some
  | :every
```

# `t`

```elixir
@type t() :: %Dmn.Compiler.Box{
  boolean_part: :if | :match | :satisfies | nil,
  id: String.t() | nil,
  kind: kind(),
  label: String.t() | nil,
  line: pos_integer() | nil,
  type_ref: String.t() | nil
}
```

# `of`

```elixir
@spec of(Dmn.Model.Expressions.t() | nil) :: t() | nil
```

The box of a boxed expression of the model, or `nil` for `nil`.

    iex> box = Dmn.Compiler.Box.of(%Dmn.Model.Expressions.Iterator{kind: :some, id: "q1"})
    iex> {box.kind, box.id, box.boolean_part}
    {:some, "q1", :satisfies}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
