36#ifndef MULTI_GRAMMAR_H
37#define MULTI_GRAMMAR_H
43#include "parse_context.h"
103 const int *lookahead, uint32_t nlook,
125 uint32_t ext_id,
bool success);
135 const uint32_t *ext_ids, uint32_t n,
float *out_confidence);
ParserSnapshot * lime_dialect_select(const LimeDialectRegistry *reg, const char *name)
Look up the composed snapshot for a dialect name.
bool lime_dialect_parse_sigil(const LimeDialectRegistry *reg, const char *input, ParserSnapshot **out_snap, size_t *out_offset)
Parse a leading @dialect sigil at the start of input.
struct LimeBayesStore LimeBayesStore
Opaque Beta-Bernoulli store keyed by (state, token, ext_id).
LimeDialectRegistry * lime_dialect_registry_create(void)
Create an empty dialect registry.
bool lime_dialect_register(LimeDialectRegistry *reg, const char *name, ParserSnapshot *snap)
Register a composed snapshot under a dialect name.
int lime_bayes_rank(LimeBayesStore *s, uint16_t state, uint16_t token, const uint32_t *ext_ids, uint32_t n, float *out_confidence)
Rank ext_ids at (state, token) by posterior mean.
LimeBayesStore * lime_bayes_create(void)
Create an empty store (entries allocated lazily).
int lime_mg_resolve(const LimeForkCandidate *cands, uint32_t ncands, const int *lookahead, uint32_t nlook, struct LimeBayesStore *bayes, uint16_t bayes_state, uint16_t bayes_token, LimeForkRank *out_ranks)
Resolve a collision by simulating each candidate over the upcoming token stream and ranking the outco...
void lime_bayes_destroy(LimeBayesStore *s)
Destroy a store.
LimeBayesStore * lime_bayes_deserialize(const void *buf, size_t buflen)
Rebuild a store from a blob produced by lime_bayes_serialize.
size_t lime_bayes_serialize(const LimeBayesStore *s, void *buf, size_t buflen)
Serialize the store to a flat blob for host-side persistence.
void lime_bayes_observe(LimeBayesStore *s, uint16_t state, uint16_t token, uint32_t ext_id, bool success)
Record that ext_id won at (state, token) and the parse success-ceeded – updates that arm's Beta poste...
struct LimeDialectRegistry LimeDialectRegistry
Opaque name -> composed-snapshot registry.
void lime_dialect_registry_destroy(LimeDialectRegistry *reg)
Destroy the registry.
One candidate grammar for a collision.
int32_t priority
Lower = preferred (final tie-break).
uint32_t ext_id
Extension id (Tier-2 Bayesian key).
const ParserSnapshot * snapshot
Grammar to simulate.
Per-candidate ranking detail (optional output of lime_mg_resolve).
bool tied_winner
True if it tied for first on Tier-1 metrics.
LimeForkTrial trial
How far this candidate got.