# `Grammar.VM.Linker`
[🔗](https://github.com/joetjen/ichor/blob/v0.3.0/lib/grammar/vm/linker.ex#L1)

Turns `[{name, ops}]` -- one label-relative op list per token or rule,
as produced by `Grammar.VM.Compiler` -- into a single linked
`Grammar.VM.Program`.

Each op list may contain two kinds of placeholder alongside real
instructions: `{:label, n}` (a jump target local to that op list) and
the real instructions `{:jmp, n}` / `{:choice, n}` / `{:commit, n}` /
`{:back_commit, n}` / `{:test_progress, n}` that reference one.
`{:call, name}` is a *different*
kind of forward reference -- to another token/rule's own entry point,
by name, resolved against every op list at once (that's the whole
reason linking happens globally instead of per-name: `:call` needs to
reach targets compiled by a different, unrelated `compile/1` call).
`{:custom, module, function, dep_names}` (a `Grammar.IR.Custom`
`@native(...)` node) resolves the same way, except it names *several*
targets at once -- one per declared dependency -- ending up as
`{:custom, module, function, %{dep_name => entry_index}}`.

# `link`

```elixir
@spec link([{atom(), [term()]}]) :: Grammar.VM.Program.t()
```

Concatenates every `{name, ops}` pair (in the given order) into one
instruction tuple, resolving local labels and `:call` targets alike in
a single position-tracking pass.

---

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