Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
DisambiguationStrategyVTable Struct Reference

Function pointer table for a disambiguation strategy implementation. More...

#include <disambiguation.h>

Data Fields

void(* destroy )(void *strategy_context)
 Tear down the strategy and free all resources.
 
void *(* init )(const struct Extension *const *extensions, uint32_t nextensions)
 Initialize the strategy.
 
bool(* resolve )(void *strategy_context, const ConflictPoint *conflict, struct ParseContext *parse_ctx, int lookahead, StrategyResult *result)
 Resolve a single conflict.
 
void(* update )(void *strategy_context, struct ExtensionRegistry *registry, bool success)
 Provide feedback after a parse completes.
 

Detailed Description

Function pointer table for a disambiguation strategy implementation.

Each strategy provides four callbacks. The opaque strategy_context pointer is strategy-specific state created by init() and freed by destroy().

Definition at line 136 of file disambiguation.h.

Field Documentation

◆ destroy

void(* DisambiguationStrategyVTable::destroy) (void *strategy_context)

Tear down the strategy and free all resources.

Parameters
strategy_contextOpaque pointer returned by init().

Definition at line 188 of file disambiguation.h.

◆ init

void *(* DisambiguationStrategyVTable::init) (const struct Extension *const *extensions, uint32_t nextensions)

Initialize the strategy.

Called once when the DisambiguationContext is created. Receives the loaded extensions so the strategy can precompute any needed metadata (e.g. priority ordering).

Parameters
extensionsArray of loaded Extension pointers.
nextensionsCount of extensions.
Returns
Opaque strategy context pointer, or NULL on failure.

Definition at line 148 of file disambiguation.h.

◆ resolve

bool(* DisambiguationStrategyVTable::resolve) (void *strategy_context, const ConflictPoint *conflict, struct ParseContext *parse_ctx, int lookahead, StrategyResult *result)

Resolve a single conflict.

Parameters
strategy_contextOpaque pointer returned by init().
conflictThe conflict point to resolve.
parse_ctxCurrent parse context (may be NULL if resolution happens before parsing starts).
lookaheadLookahead token code (-1 if not applicable).
[out]resultFilled with the resolution decision.
Return values
trueConflict was resolved.
falseResolution failed.

Definition at line 163 of file disambiguation.h.

◆ update

void(* DisambiguationStrategyVTable::update) (void *strategy_context, struct ExtensionRegistry *registry, bool success)

Provide feedback after a parse completes.

Strategies that learn (e.g. Bayesian) use this to update their models.

Parameters
strategy_contextOpaque pointer returned by init().
registryExtension registry for metadata lookups.
successTrue if the parse succeeded.

Definition at line 179 of file disambiguation.h.


The documentation for this struct was generated from the following file: