Grammar.Native (Ichor v0.2.0)

Copy Markdown View Source

The compile-time codegen backend: turns a validated %Aether.Grammar{} into quoted Elixir function definitions -- the same two-stage Lexer -> Parser split Grammar.VM compiles to bytecode for, but here as direct function calls a use Ichor, grammar:, actions: caller splices straight into its own module (via Ichor's __using__ macro), skipping bytecode interpretation entirely.

Dispatches to actions_module via a compile-time-known module reference: Ichor.Actions.evaluate/5 is called directly with that module baked in as a literal, never looked up dynamically -- reusing Ichor.Actions's own default-fallback and capture-shape-normalization logic rather than re-deriving it, since the actual speed win is in the match phase (a compiled lexer/parser instead of an interpreted bytecode loop), not in re-implementing evaluation.

Summary

Functions

Generates the full quoted body (lexer + parser + parse/1 + run/1,2) for grammar, dispatching to actions_module.

Functions

generate(grammar, actions_module)

@spec generate(Aether.Grammar.t(), module()) :: Macro.t()

Generates the full quoted body (lexer + parser + parse/1 + run/1,2) for grammar, dispatching to actions_module.