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

A text of the model, parsed as FEEL and put in the source of the unit.

The text is added to the virtual source (`Dmn.Compiler.Source`) with its origin, parsed with the names that are in scope where it
stands, and its tree is moved to where its text is. What cannot be parsed is not an error of the whole model: it is a diagnostic of
the element it is in, and the fragment is `null` (an expression) or a rule that never matches (an input entry), as DMN has an
expression that cannot be evaluated give `null` (7.3.8).

The state that is threaded through the compiler is a map with the `:source`, the `:issues` found so far, and the `:box` that is
being compiled (`Dmn.Compiler.Box`, `nil` outside a box): every part put in the source, a text or glue, is put with it, and so is
every issue.

# `origin_path`

```elixir
@type origin_path() :: [term()]
```

# `state`

```elixir
@type state() :: %{
  source: Dmn.Compiler.Source.t(),
  issues: [Dmn.Diagnostic.t()],
  box: Dmn.Compiler.Box.t() | nil,
  tables: %{optional(origin_path()) =&gt; Dmn.Model.DecisionTable.t()}
}
```

# `expression`

```elixir
@spec expression(
  String.t() | nil,
  String.t() | nil,
  Dmn.Compiler.Env.t(),
  state(),
  origin_path()
) ::
  {Feel.AST.expression(), state()}
```

The tree of the text as an expression. An empty text, or none, is `null`; a text that is not FEEL, or cannot be parsed, is `null`
and a diagnostic.

# `glue`

```elixir
@spec glue(state(), Dmn.Compiler.Env.t(), origin_path()) ::
  {Feel.Diagnostic.span(), state()}
```

The zero-width span of the part of the model at `path`, for the nodes of the tree that stand for it and have no text.

# `issue`

```elixir
@spec issue(
  state(),
  Feel.Diagnostic.severity(),
  atom(),
  String.t(),
  Dmn.Compiler.Env.t(),
  origin_path(),
  keyword()
) :: state()
```

Records a diagnostic of the element, at a place in it.

# `new_state`

```elixir
@spec new_state() :: state()
```

The state of a unit that has compiled nothing.

# `unary_tests`

```elixir
@spec unary_tests(
  String.t() | nil,
  String.t() | nil,
  Dmn.Compiler.Env.t(),
  state(),
  origin_path()
) ::
  {:ok, Feel.AST.unary_tests(), state()} | {:empty, state()} | {:error, state()}
```

The tree of the text as a list of unary tests: `{:ok, tree, state}`, `{:empty, state}` for no text (a test that any value
satisfies), `{:error, state}` for a text that cannot be read.

---

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