# `Grammar.Native.Lossless`
[🔗](https://github.com/joetjen/ichor/blob/v0.7.0/lib/grammar/native/lossless.ex#L1)

What `lossless: true` adds to a generated LR or GLR parser
(`design/lossless-mode.md`): `parse_lossless/1,2` and
`run_lossless/1,2`, over a shift-reduce run that records the rules
(`Grammar.LR.Lossless`, or `Grammar.GLR.Runtime.run/7` building with
`Ichor.Syntax.Record.reduced/3`).

The two engines differ only in that run, so it is handed in as quoted
code; the rest -- trimming, placing an error against the input,
weaving the tree, evaluating the value -- is one definition for both,
and the same as each engine's ordinary `parse/2` and `run/2` do.

# `action_defs`

```elixir
@spec action_defs(Grammar.LRTable.t(), atom()) :: [Macro.t()]
```

`fn_name/2` clauses answering a state and a lookahead terminal with
the table's list of actions (`[]` for none) -- the lookup
`Grammar.LR.Lossless` takes, which the generated LR parser otherwise
has no need of, its states being compiled into functions.

# `shift_reduce_defs`

```elixir
@spec shift_reduce_defs(Aether.Grammar.t(), module(), Macro.t()) :: Macro.t()
```

The generated functions. `run` is quoted code evaluating, with
`stream_var/0` bound to the trimmed token tuple, to `{:ok, pos,
raw_captures}` with the records inside, or `{:error, error}`.

# `stream_var`

```elixir
@spec stream_var() :: Macro.t()
```

The variable the trimmed token tuple is bound to, for `run` to read:
unhygienic, since `run` is quoted in another module.

---

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