Grammar.GLR.Runtime (IchorRuntime v0.1.0)

Copy Markdown View Source

The GSS-driving shift-reduce/fork loop itself, shared by the interpreted Grammar.GLR (which wraps a Grammar.LRTable's plain action/goto maps into closures) and Grammar.Native.GLR (which passes compiled per-state functions instead) -- extracted so both reuse the exact same, already-proven algorithm. The graph-structured stack itself (node merging, multi-path reduce enumeration -- Grammar.GLR.GSS) is inherently a runtime, input-driven data structure that can't compile away no matter which engine calls into it; only how a caller looks up actions/goto for a state varies.

Summary

Functions

Runs the GSS shift-reduce/fork loop over stream, starting from start_state, dispatching every lookup through action_fn/goto_fn.

Types

action_fn()

@type action_fn() :: (Grammar.LRTable.state_id(), atom() ->
                  [Grammar.LRTable.action()])

goto_fn()

@type goto_fn() :: (Grammar.LRTable.state_id(), atom() ->
                Grammar.LRTable.state_id() | nil)

Functions

run(action_fn, goto_fn, productions, start_state, end_symbol, stream)

@spec run(
  action_fn(),
  goto_fn(),
  %{required(non_neg_integer()) => Grammar.LRTable.Production.t()},
  Grammar.LRTable.state_id(),
  atom(),
  tuple()
) :: {:ok, non_neg_integer(), map()} | {:error, Ichor.Error.t()}

Runs the GSS shift-reduce/fork loop over stream, starting from start_state, dispatching every lookup through action_fn/goto_fn.